Checking many pieces at once¶
A long recording is a chain of pieces, each a file that reads alone. A reader can verify one piece or hash one track's chunks in it without reading the others. So a large archive can check its pieces in parallel.
What runs at once¶
ww_tape_fs::check takes the paths of piece files and gives one result per path, in the order given.
verify_eachrunsTapeReader::verifyon each piece, one piece at a time.range_hash_eachrunsTapeReader::range_hashon each piece, one piece at a time.verify_each_parallelandrange_hash_each_parallelgive the same results with the pieces spread over rayon's threads. They exist under the cargo featureparallel.
ww_tape itself keeps no thread pool and builds without the standard library. Only ww_tape_fs takes rayon.
Each piece is folded from the start of its track hash, so the results are each piece's own. They are not one hash of the whole chain. Chaining pieces into the chain's hash still folds every chunk in order, once.
What it gains¶
The bench archive_parallel writes three sets of piece files, each where its operation does real BLAKE3 work. A
chain at Full is verified. A chain at CrcOnly is range-hashed: its index carries no unit hashes, so every chunk's
payload is read and hashed. Unclosed pieces are resumed, which walks each piece from its start.
Every timed pass is preceded by reading each piece once, so both strategies run on warm pages. The two strategies run several times each, alternating which goes first. The tables give the shortest, median and longest run.
| Strategy | Shortest s | Median s | Longest s | GB/s at the median | Speedup at the median |
|---|---|---|---|---|---|
| 20 pieces one at a time | 3.26 | 3.66 | 28.52 | 2.93 | 1.00 |
| 20 pieces in parallel (rayon) | 0.58 | 0.89 | 1.42 | 12.13 | 4.14 |
just bench-archive-parallel on build-1, load average 14.72 before, 14.72 after.
| Strategy | Shortest s | Median s | Longest s | GB/s at the median | Speedup at the median |
|---|---|---|---|---|---|
| 12 pieces one at a time | 2.65 | 2.89 | 3.11 | 2.23 | 1.00 |
| 12 pieces in parallel (rayon) | 0.56 | 0.70 | 0.73 | 9.22 | 4.13 |
just bench-archive-parallel on build-1, load average 15.25 before, 15.25 after.
| Strategy | Shortest s | Median s | Longest s | GB/s at the median | Speedup at the median |
|---|---|---|---|---|---|
| 12 pieces one at a time | 4.36 | 4.73 | 7.96 | 1.02 | 1.00 |
| 12 pieces in parallel (rayon) | 0.96 | 1.00 | 1.26 | 4.82 | 4.71 |
just bench-archive-parallel on build-1, load average 15.03 before, 15.03 after.
BLAKE3's own multithreaded hashing is a ceiling for hashing one piece, not a stand-in. A piece's content hash chains
and substitutes chunk payloads. It is not one buffer to hand to update_rayon.
| Set | GiB | Single-threaded | update_rayon | Ratio |
|---|---|---|---|---|
| verify_chain | 10.00 | 2.29 | 5.09 | 2.23 |
| range_chain | 6.00 | 2.47 | 5.50 | 2.22 |
| resume_pieces | 4.50 | 2.25 | 4.88 | 2.17 |
just bench-archive-parallel on build-1, load average 15.03 before, 7.45 after.
Reading is bound by the storage too. A chain larger than memory is read cold, and its speedup is what the storage serves to several readers at once.
The bench ran on build-1, a virtual machine with 14 logical CPUs (AMD EPYC-Genoa Processor, x86_64) and 35 GiB of memory. It was a release build at opt-level 3 of commit 60db6275, built with the default jobs. The load average ran from 7.45 to 24.76 across the tables.
pub fn verify(&self, i: usize) -> R<Verification, S>
Whether closed piece i holds up as a whole: its bytes before its close record hash to the close's content
hash (each block that reads whole as it is, a chunk's payload by its hash, other bytes as they are,
piece docs); its final index and the blocks walked are the same set: each block walked that
its writer lists has exactly the entries its writer made of it, field for field (offset, length, kind, track,
items, ticks, a chunk's unit hash of its bytes and its range relation's range from its column), but a
byte-identical copy of the listed block before it; each entry names a block walked, or a block that doesn't
read whole in bytes no block explains, ending before the close and before the next block walked; and each
close row states the hash its track's blocks fold to from the head row's, or says it incomplete exactly where
a damaged block kept or the head leaves units out.
pub fn range_hash(
&self,
track_id: TrackId,
owner: OwnerId,
items: Range<ItemNum>,
from: TrackHash,
) -> R<RangeHash, S>
The hash of the whole chunks of track track_id owned by owner that hold an item in items, folded from
from (TrackHash::then) over the pieces in order.