turbo-persistence: skip BlockCache for uncompressed (mmap-backed) blocks (#92390)
### What?
Skip the `BlockCache` entirely for uncompressed (mmap-backed) SST
blocks, and add a per-file CRC verification bitmap so checksums are
verified at most once per file open for any block.
### Why?
Uncompressed blocks produce an `ArcBytes` with `Backing::Mmap` — just an
`Arc::clone` of the mmap handle plus a pointer into it. No heap
allocation, no decompression. The cost of constructing one (an atomic
refcount increment + pointer copy) is far less than a `BlockCache` hash
+ concurrent-map lookup + potential insertion.
Bypassing the cache for these blocks:
- Reduces lock contention on the shared `BlockCache`
- Avoids polluting the cache with entries that are essentially free to
recreate
- Eliminates redundant mmap reads (the old code peeked at the header,
then re-read it inside `read_block_generic`)
Key blocks (index block + all key blocks) tend to be small and are
frequently accessed. In practice, small key blocks are often stored
uncompressed, so this optimization applies on the hot path.
### How?
**Single mmap read per block access.** `get_or_cache_block` calls
`get_raw_block_slice` exactly once to read the block header (with all
`#[cfg(feature = "strict_checks")]` bounds guards), then branches on
`uncompressed_length`:
- `== 0` (uncompressed): verify CRC via bitmap, return mmap-backed
`ArcBytes` directly
- `> 0` (compressed): check `BlockCache`; on miss, verify CRC via
bitmap, decompress, insert
**CRC verification bitmap.** `StaticSortedFile` now holds a
`Box<[AtomicU64]>` with one bit per block, set once the block's CRC has
been verified. This prevents re-computing the checksum on every access
for uncompressed blocks (which bypass the cache) and for compressed
blocks that were evicted and re-read. `Relaxed` ordering suffices since
racing first-time verifications are idempotent.
**`ArcBlockCacheReader` wrapper.** A `Copy` struct bundling
`&BlockCache` + `&[AtomicU64]` that implements
`ValueBlockCache<ArcBytes>`, threading the bitmap through the existing
generic lookup machinery without changing the trait signature.
**`BlockWeighter` safety net.** The mmap-backed branch now has a
`debug_assert!(!val.is_mmap_backed())` to catch accidental insertion,
with a negligible weight (64) as a defensive fallback in release builds.
<!-- NEXT_JS_LLM_PR -->
---------
Co-authored-by: Tobias Koppers <sokra@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Luke Sandberg <lukesandberg@users.noreply.github.com>