perf(backup-helper): compute prepare CommP across a worker_threads pool - #8
Merged
Merged
Conversation
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. (cherry picked from commit 1de3e21)
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.
work cherry-picked from @TippyFlitsUK PR #7 (commit 1de3e21)
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