Skip to main content

VERIFIED

Static VERIFIED 

Source
static VERIFIED: OnceLock<Mutex<HashMap<PathBuf, FileId>>>
Expand description

What this process has already checksummed, and the file it was.

The CRC is the right thing to do on a first read and pure waste on the second. A published block never changes, so a scan that reopens the same corpus re-hashes bytes this same process already hashed, to answer a question the previous query already answered.

It is worth stating what that is and is not worth, because docs/market.md named this fix on the back of a number that turned out to be a coincidence — 4,380 MiB in 885 ms is ~5 GB/s, which was read as “that is crc32fast’s rate here” and therefore as ~93% of an unpruned scan. Warm, it is nearer 27 GB/s. Measured on both sides of one run instead, re-verification is between a quarter and two fifths of a single block’s read path, and about 1.1x on a full-corpus scan — which is bound by page cache, not by this. The “35-39%, a median of 1.55x” this comment used to carry was three samples of a quantity that moves between 1.14x and 2.21x, and is withdrawn as a median. scan_cost_per_row in query.rs is the run; section 11 of docs/architecture/performance-query.md is the write-up.

The identity is the path plus FileId, never the path alone, because a name in this tree is not a file for life: compact renames a new table over an existing name, and it must re-verify. Entries are keyed by path so a replaced file overwrites its predecessor instead of accumulating beside it.

What this cannot see is a bit that rots under a live file without any of the three fields moving. That is the whole of the trade, and it is the reason the cache is process-scoped rather than persisted: a restart re-verifies everything, so the window is one process lifetime and not the life of the block. The alternative — dropping the CRC, or covering fewer tables — either gives up detection entirely or gives it up for whichever table a query skipped.