-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Index is slow #371
Comments
Blocked on cberner/redb#344. |
@virtuallythere, we should benchmark this more, but it seems like there's already a juicy target for optimization, looking at the flamegraph you posted: cberner/redb#344 (comment) We're spending around 40% of the time requesting blocks from bitcoin core, and in that thread and context switch stuff that's parallelizing calculating transaction IDs. That can be merged into one background thread that fetches new blocks and calculates TXIDs for transactions in advance. (Alternatively, if it's faster, we could just not calculate TXIDs ahead of time.) |
@casey Hah, I came to the same conclusion this morning. Here are my thoughts. What we know (from the flamegraphs)
What I think we should do based on that
|
Here's the key results from using https://crates.io/crates/cargo-instruments to profile the indexing of mainnet from blocks 450006 to block 451008 (why the unround numbers you may ask: there seems to be an off by some bug in The command used was:
starting with an index that was at block 450006, so around 1000 blocks indexed. I expect this to give us a pretty representative view of where time goes in indexing mainnet with full blocks. This is using most recent master as of Sep 11 (commit 5987958) |
Working on #500 to help prioritize further optimization efforts. |
Working on issue ordinals#371 Most UTXOs are short-lived so to speed up indexing, we introduce an in-memory HashMap that collects all outpoint-to-ordinal-range mappings since the last DB commit, and serves as a cache. On mainnet this avoids around 80% of the writes to the redb BTree and results in a 2x speedup for indexing at the expense of slightly higher RAM usage. Also introduces more detailed logging and time keeping.
The index is still slow, but this particular issue isn't appearing anymore, so closing in favor of a new issue, #713. |
What we know
The ordinals.com index is syncing very slowly. At the current rate, around 3 seconds per block, it will take about 9 days to sync to chain tip. Previous syncs were more like 36 hours, so this is a severe performance regression.
A possible culprit is the new
OUTPOINT_TO_TXID
table. This table maps outpoints to the txid, if any, that spends them. This is required to improve the error messages when we don't have an outpoint in OUTPOINT_TO_ORDINAL_RANGES table.The database used to top out at around 50GB, but is currently 89 gigs and growing.
Things to try
The text was updated successfully, but these errors were encountered: