-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: chain: make chain tipset fetching 1000x faster #10423
Conversation
Timing results on mainnet:
Warming the cache takes ~6 minutes, subsequent queries are less than a second. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. A couple of comments:
- I'd just drop the ARC cache and just use a map. We're likely wasting a lot of time updating the "recency" metrics on that cache every time we use it (and the memory locality is likely really bad).
- I'm somewhat concerned that a single query might take 6 minutes (will timeout on most services). We might want some form of background job to warm the cache. But (a) that can happen later and (b) service providers can likely work around this issue themselves.
If this isn't enough, we can consider implementing a real skiplist (with multiple levels). |
@Stebalien Thanks for the review and the suggestions! I switched to using a map. It appears to have made the warmup slower, which is somewhat unexpected, but subsequent lookups faster. I think that's still a win, in addition to the overall simplicity, so I'm gonna push that up. |
chain/store/index.go
Outdated
return &ChainIndex{ | ||
skipCache: sc, | ||
indexCache: make(map[types.TipSetKey]*lbEntry), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's slower because you're not initializing the map to DefaultChainIndexCacheSize.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also note: I think you can just use lbEntry
by value to save some allocations which should speed things up even more.
fe169b3
to
d53878b
Compare
Related Issues
@jennijuju flagged that we need faster fetching of tipsets by height for Eth tooling support.
Proposed Changes
Additional Info
Checklist
Before you mark the PR ready for review, please make sure that:
<PR type>: <area>: <change being made>
fix: mempool: Introduce a cache for valid signatures
PR type
: fix, feat, build, chore, ci, docs, perf, refactor, revert, style, testarea
, e.g. api, chain, state, market, mempool, multisig, networking, paych, proving, sealing, wallet, deps