backup-helper: parallelise prepare hashing + curio import-pieces --result compatibility - #7
Closed
TippyFlitsUK wants to merge 2 commits into
Closed
Conversation
added 2 commits
June 4, 2026 20:14
prepare computes a piece CID for every shard missing one via the pure-JS @filoz/synapse-core/piece hash. That hash is CPU-bound and single-threaded, so on a multi-core node prepare pins one core and leaves the rest idle. Move the hashing into a worker_threads pool sized to --concurrency. Each worker calls the same calculateFromIterable, so output piece CIDs are byte-identical to the single-thread path; only throughput changes. DB writes and shard->piece renames stay on the main thread (sqlite is not shared with workers). Measured on a 64-core machine (~10 MB avg CARs): ~20 MB/s at -c 8, ~69 MB/s at -c 24, ~84 MB/s at -c 32 (knee ~32 on that box). No change to default concurrency or any existing flag.
curio toolbox import-pieces moved its JSON result off stdout into a file passed via a now-required --result <path> flag, and writes that file even on non-zero exit. Against a curio build with that change, runParkingBinary fails with 'ERROR: result is required'. Pass --result <dir>/.parking-result.json, read the JSON from there on both success and failure (surfacing curio's structured error field), and remove the file afterward. Tracks filecoin-project/curio#1264 (commit 7c8297ca). Note that #1264 is currently a draft; if the flag contract shifts before it merges this will need a follow-up.
Owner
|
Closing this, since the the worker_threads commit was added to the PR #8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two independent changes to
backup-helper, kept as separate commits so they can be reviewed (or split) independently:1.
prepare— parallel CommP hashing (perf)preparecomputes a piece CID for every shard missing one, via the pure-JS@filoz/synapse-core/piecehash. That hash is CPU-bound and single-threaded, so on a multi-core nodepreparepins one core and leaves the rest idle.This moves the hashing into a
worker_threadspool sized to--concurrency. Each worker calls the samecalculateFromIterable, so output piece CIDs are byte-identical to the single-thread path — only throughput changes. DB writes and shard→piece renames stay on the main thread (sqlite isn't shared with workers).Measured on a 64-core machine, single dataset (~10 MB average CARs):
--concurrencyKnee around 32 on that box (the per-core JS hash is the ceiling); scales with available cores. Piece-CID output verified identical to the pre-change path.
2.
commit— adapt to curioimport-pieces --result(fix)curio toolbox import-piecesmoved its JSON result off stdout into a file passed via a now-required--result <path>flag, and writes that file even on non-zero exit. Against a curio build with that change,runParkingBinaryfails withERROR: result is required.This passes
--result <dir>/.parking-result.json, reads the JSON from there on both success and failure (surfacing curio's structurederrorfield), and cleans the file up afterward.Tracks filecoin-project/curio#1264 (commit
7c8297ca, "always write in json file").Testing
prepare: run end-to-end on a real customer dataset —failed=0, piece CIDs match the single-thread output.commit: parking step succeeds against a curio build carrying #1264; structured errors propagate on failure.Notes