store: two-scan SH extract (unique keys, then fuse-hit postings) - #668
Conversation
|
Hi @reardencode was observing the CI cargon mutants in-diffs test and saw it was running workspace or something, and was talking to my clanker about it, had some tiered idea, but idk maybe he found some other approach which may help. I will post the response here for you and your clanker to see if we come up good appropriate and improved approach! I hope it is not too confusing! The test seemed to be cancelled after 30 minutes according to the #609 implementation. That why I started asking my clanker what's up. Below are some convo dump sorry! For the purpose of hoping to brainstorm with you & your AI to find a good improvement forward that fits rbitcoin's testing regime Convo dump 1:Observation from
|
7cd2349 to
be17fab
Compare
432935e to
f46a3f1
Compare
Fix for 30m cancel on this PR
Root cause: 313 * ~19s / 2 workers = ~50m of work needed, but Since rbitcoin is public, standard runners are free - sharding doesn't cost Rearden, it just trades wall time for parallelism. Proposed fix - shard the PR diff instead of raising timeout: Change mutants-pr:
strategy:
matrix:
shard: [0,1,2,3]
fail-fast: false
timeout-minutes: 30
steps:
- run: cargo mutants --workspace --in-diff git.diff --shard ${{ matrix.shard }}/4 --sharding slice --jobs 2 --baseline skip --timeout 240
continue-on-error: true
- uses: actions/upload-artifact@v4
with:
name: mutants-pr-${{ matrix.shard }}
path: mutants.out
If you want minimal change, just bump Within Bitcoin specifically, no reputable project shards the PR diff yet - they do the first half of what you're doing.
So Bitcoin Rust projects today are: PR = single The sharding to fix the 30m cancel is from the general Rust ecosystem - If you do 4-way sharded |
f46a3f1 to
1aa095b
Compare
c985c60 to
02ce85e
Compare
1aa095b to
156de27
Compare
|
Sorry it might depends on how many concurrent jobs running! Idk how many exactly.. But if based on below numbers of concurrent... below might be an idea for improvement. But if concurrent jobs are different to what below says, might have different solution ideas -- Based on their current 9 concurrent jobs per PR, conditional 4-way, not always 4-way. Here's why:
rbitcoin is 38 stars, so you rarely have 2 PRs at once right now, but conditional is still better because:
Best final solution for rbitcoin: Keep
That fixes the cancel, keeps concurrency low for normal work, and matches what If you want absolute simplest fix to unblock #668 today: just change |
|
Thanks @Hero-Gamer. Yeah, was thinking something along these lines after seeing that some PRs timed out while others didn't. We'll think about what to do with it and possibly revise the overall PR workflow to be a little bit less concurrent to make space for more mutants runners. |
d3a6c81 to
7f8ec53
Compare
Pass 1 keeps a per-worker identity map (key16 to a pack8 word, 0 = multi) on a contiguous create-fk span, spills SHKSP01 under keys/NN/ at the 1.5 GiB cap, and folds one map into scripthash.head/NN plus multi fuse8. Pass 2 records fuse hits as SHPST01 fk runs and packs 2+ bodies. A previous DONE / 24 B NN unsorted tree is wiped and pass 1 restarts.
Record the identity-map spill layout, the 1.5 GiB worker cap, and resume. Previous SHUNSRT3 unsorted is deleted and pass 1 restarts.
Pass-2 pack rewrote each multi key with its own 8-byte pwrite. Check every slot first, then patch the val image once (1 MiB windows above 512 MiB) so a bad slot cannot tear the file.
insert_post_fk maintains a strictly increasing run, so spill encode, cross-spill fold, and pack no longer clone and sort those vecs.
Seal consumes the per-shard identity map into pack8 records so its buckets are gone before fuse8 and BDZ. mix_key16 xors the two key halves directly.
Each extract worker tallies outputs and fuse hits locally and adds them to the shared atomics after the 64 k-fk batch. Q-70 records the lookup path counters that are still per event.
Pass 2 no longer invents a 32-byte key to reuse the scripthash bulk session. The open key is the slot, and the dummy head records are not kept.
0c9bcab to
80f646e
Compare
Summary
Replaces the one-pass 24 B unsorted
shards (
DONE/SHUNSRT3) with two Class Atxoutscans. NoSCHEMA_VERSIONbump.identity maps (
key16 → pack8,0= multi), capped at 1.5 GiB(
64B/key estimate). After each 64 k-fk batch, spill the largest shardwhile over budget. Spills are
SHKSP01underkeys/NN/(one writer,1-slot queue, tmp+rename, no
sync_all). Merge folds those files intoone map, one walk to
scripthash.head/NN(singlesinline_one, multisEmpty) and
multi/NN.fuse8, then unlinkskeys/NN/.DONE.keysisSHKEYS02. Progress isscanned=finished fks.key16 → Vec<fk>(80n+8f) and spill asSHPST01underpost/NN/.Pack folds one shard, then
slot_for_key16and 2+ bodies. One fk afterfold is
fp_singles.DONE.postisSHPOST02.DONE.keys(including the previousDONE/ 24 BNNlayout, orkeys/NN/post/NNas a file) deletes unsorted andrestarts pass 1. A spill whose magic is not
SHKSP01/SHPST01isCorrupt — wipe
scripthash.unsortedand rematerialize.MphfHead::existsafter pass 1 is not pack-done.
sh_extract_workers()= min(CPUs, max(1, free RAM / 1.5 GiB)).RBITCOIN_SH_MERGE_WORKERSoverrides.Test plan
cargo test -p rbitcoin-store --lib -- scripthashcargo clippy -p rbitcoin-store --all-targets -- -D warnings./scripts/ast-grep.shPerformance
Five commits on top of the extract:
.valis patched as one image (1 MiB windows above 512 MiB). A bad slot does not tear the file.mix_key16xors the two key halves.Lookup-path atomics that are still per event are Q-70 in
docs/quality.md(add_hit_rank, and the once-per-block / getdata / page counters named there).