ordinals / ord

👁‍🗨 Rare and exotic sats
https://ordinals.com
Creative Commons Zero v1.0 Universal
3.86k stars 1.38k forks source link

More efficient sat-range handling #3963

Closed partialord closed 2 months ago

partialord commented 2 months ago

Keep our arrays of sat ranges in the low-level [u8; 11] format, rather than converting them to (u64, u64) and back. Also, don't mutate the input sat ranges in index_transaction_sats(); this avoids the need for a copy in index_utxo_entries() and also makes that code simpler.

Add a fast path for Sat::common(), which avoids a divide and some branch mispredictions.

These changes save almost 2.5 hours of CPU time. The overall speedup is less, though, because indexing now runs fast enough that bitcoind often can't keep up -- we spend a significant amount of time just waiting for it to send us blocks.

casey commented 2 months ago

LGTM! @raphjaph Want to take a look at this? This drops building a sat-only index from 10 hours to 8.5 hours.