-
Couldn't load subscription status.
- Fork 12
arp_handler: use a LRU cache for Dynamic entries #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This introduces an additional dependency on |
When items are dropped from the LRU map, drop them from the main map too. Static entries are not added to the LRU: we never want to drop these. Signed-off-by: Edwin Török <[email protected]>
|
Thanks for your contribution. With this, we store dynamic entries both in the map and in the LRU, is this correct? Certainly the runtime of retrieving an element then only needs to lookup in the map, but we have to keep the LRU and the map in sync. Is this worth it? Another approach would be to keep the map for static entries, and use the LRU for dynamic entries... Did you consider (and benchmark)? |
Or maybe it'd be easier to make the
I don't think it'd change the lookup time (which I expect to matter most for performance). Adding/removing entries is rarer (only when talking to a new host). Another approach would be to remove the |
When the cache is full we drop the dynamic entry with the oldest epoch, if any. This no longer requires an LRU. Signed-off-by: Edwin Török <[email protected]>
|
There is already a timeout for the dynamic entries, so this can be used as a crude approximation instead of the LRU. But for now lets keep it simple. I haven't benchmarked yet, but there is now only a single map lookup on the main query path, and no extra mutation/updates. For now I left the previous approach in the commit history, so we can compare all 3 impl (original, LRU and this one). I probably also need to add a few more tests that uses the new |
|
Hmmhmm, I prefer the version with |
|
Thanks @edwintorok. I cherry-picked the first commit to the main branch. |
CHANGES: * Use LRU cache for Dynamic entries to avoid excessive memory consumption (mirage/arp#35 @edwintorok)
When items are dropped from the LRU map, drop them from the main map too.
Static entries are not added to the LRU: we never want to drop these.