-
Notifications
You must be signed in to change notification settings - Fork 236
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
refactor: Define a general Filter struct #1073
Conversation
@xxuejie is assigned as the chief reviewer |
Have we benched this? My concern is that HashMap (well, std's one is slow but the argument holds) is an optimized architecture with performance guarantees, with newer version of Rust they will get faster with new implementations such as hashbrown. On the other hand, it seems like we don't need strict LRU policy here, in that case adding an LruCache might bring in a lot of unneeded logic. I feel it's better if we just cap the size of the HashMap till we know for sure this won't bring any negative effects. |
In the implementation here, it's not an LRU, just a LinkedHashMap or LinkedHashSet with a capacity. |
Why I am authorized to close the PR? |
Thanks! Let me describe the background of this PR. Recently I am considering "spam attacks", the malicious send lots of spam requests/blocks/transactions. These spams will eat lots of memory since we don't prune timely. So I replace I haven't bench After reading your comment, I review the two fields So I am gonna revert 93a6def018cb7b7966c7df6063fcf625815578a3. Maybe we can keep the first commit and treat it as a refactoring PR? cc @u2 |
lgtm |
refactor: Define a
Filter
structfeat: Use LruCache to avoid memory leakingIf we use native HashMap/HashSet as cache/filter, we have to prevent memory overflow by timely check or else. Replacing HashMap/HashSet with LruCache help us limit the memory usage, and reduce works around pruning staled items.