Skip to content
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

Open
arnetheduck opened this issue Jan 4, 2022 · 2 comments
Open

Optimize HashList cache growth #22

arnetheduck opened this issue Jan 4, 2022 · 2 comments

Comments

@arnetheduck
Copy link
Member

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.

@tersec
Copy link
Contributor

tersec commented Jan 4, 2022

Often, the ultimate size is known in advance (e.g., the number of validators), which would provide an optimal allocation strategy.

@arnetheduck
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants