-
Notifications
You must be signed in to change notification settings - Fork 48
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
bgpPathACache leaks memory #472
Comments
Hi, thanks for reaching out. The general idea is to deduplicate parts of BGP path attributes when they are the same. Let me get over the issues one by one: bio-rd/route/bgp_path_cache.go Line 31 in 63eef2b
On 2: Yes, that's indeed a bug (that affects ris-mirror, but not ris if I'm not mistaken). The IPs need to be deduplicated themselves first before the PathA is being deduplicated. On 3: As written above. The missing cache eviction is a known issue and a fix welcome. |
As far as I understand the code, your argument about a full table doesn't hold because the cache, as it is at the moment, doesn't do anything usefull. In combination with the second issue it can never match any entry because the ptrs are unique and thus is the hash of the map index. Unfortunately I don't have the possibility to test with a full table so I can't confirm this with data. Let me clarify on the first issue, the duplication of data happens in the map itself, by design of maps. Go just doesn't save the hash of the struct but the entire index & the value, effectively copying th full structure in this particular instance. This happens even when the cache would be working correctly. Adding to this, any identical Pretty much the same applies to IPs being deduplicated in terms of efficiency. What would you like to see happen here? I believe a cache for
|
No. That's only true when IPs ( True is, that the We've intentionally split the BGP attributes into |
Describe the bug
bgpPathACache
causes large memory leaks and is itself not caching anything that can be retrieved. The result is an ever increasing map which consumes all memory until depletion. This is a combination of issues described in detail below.Issue 1 - BGPPathA duplication
p
(typeBGPPathA
) is copied and added to the map index, resulting in a duplication of the contents.bio-rd/route/bgp_path_cache.go
Line 34 in 63eef2b
Issue 2 - impossible cache hit
BGPPathA
contains ptrs that always reference new memory (line 131 & 138). The map index therefore becomes unique for each newBGPPathA
created. No dedup happens here.bio-rd/route/bgp_path.go
Lines 129 to 145 in 63eef2b
Issue 3 - missing cache eviction
Even if this cache would work, there is no mechanism for cache eviction. For very long running instances and many changes, this would always grow until no memory is available anymore.
Steps to Reproduce
run ris-mirror, have route updates, ram go brrr and poof
Expected behavior
ris-mirros shouldn't leak memory and can run for long times
Configuration used
this is config independent as the code path is always used in ris-mirror
Additional context
I've done a lot of profiling on this issue und very confident this is the major source of leaks for ris-mirror. Simply running without cache works very nicely and shows generally better peformance.
Happy to provide a PR to fix this, depening on what solution is preferred. Removing cache seems like a better tradeoff than redesigning the entire cache strategy for probably marginal benefits.
The text was updated successfully, but these errors were encountered: