-
Notifications
You must be signed in to change notification settings - Fork 6
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
Optimize HashList
cache growth
#22
Comments
Often, the ultimate size is known in advance (e.g., the number of validators), which would provide an optimal allocation strategy. |
actually, that might be the answer here: a lazy strategy for growing the cache - we don't need the cache until someone asks for a root that is affected by the new entry - queries for all old entries can be routed to the old cache while cache-growing can be delayed until a root affected by the new entries is needed |
Currently, the cache in
HashList
is grown one element at a time - this leads to a lot of reallocation and re-hashing work when adding multiple items to the list, which is pretty common - common enough that I can see it coming up when measuring with a profiler.There are lots of ways to grow lists with different tradeoffs in terms of memory use vs reallocation - based on gut feeling alone, I'd grow it 16 items at a time instead of 1 which likely would fix things for the practical use cases that we have.
The text was updated successfully, but these errors were encountered: