Skip to content

fix: consult segment cache before registering reads - #10535

Open
gatesn wants to merge 2 commits into
developfrom
ngates/segment-cache-loads
Open

gatesn wants to merge 2 commits into
developfrom
ngates/segment-cache-loads

Conversation

@gatesn

@gatesn gatesn commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Constructing a segment request currently registers the underlying read before checking the cache. When neighboring cached requests have not yet been consumed, Vortex can coalesce them into a physical read and fetch bytes already cached.

Resolve the cache lookup before registering a source read. Eagerly poll one request future so ready cold misses retain registration and read coalescing. Suspend after registration until the caller demands the read, and retain pending cache lookups without restarting them. This avoids a separate owned-lookup future allocation. Cache errors still fall through to the source. No new public APIs or cross-open coordination.

Release benchmark with the real Vortex file coalescer, 16 adjacent 4 KiB segments, and the previous adapter compiled into the same binary as the control:

Case Before After
Cold, concurrent or ordered demand 1 read / 64 KiB 1 read / 64 KiB
Half cached, ordered demand 1 read / 64 KiB 1 read / 32 KiB
Half cached, concurrent demand 1 read / 32 KiB 1 read / 32 KiB
Fully cached 0 reads 0 reads

Physical counts and bytes held across 101 zero-latency repetitions and 9 repetitions with simulated 2 ms storage latency per case. Cold medians with simulated latency were approximately 3.44–3.45 ms before and after. Zero-latency cold medians were 22.8 → 21.1 µs for concurrent demand and 21.5 → 21.5 µs for ordered demand. These are local coalescing measurements, not remote storage or end-to-end scan performance claims. Ready lookups were measured with the built-in cache; a pending custom cache lookup must resolve before its read can be registered.

Regressions cover ready cache hits, eager miss registration without demanding I/O, pending hits/misses without restarting lookups, cold coalescing with concurrent and ordered demand, and cached bytes excluded from ordered coalesced reads. The release benchmark is an explicitly ignored test in vortex-file/tests/segment_cache_coalescing.rs.

Validation: 7 release cache unit cases and 3 release integration/benchmark cases passed. Reproduce with:

cargo test --release -p vortex-layout segments::cache::tests -- --nocapture
cargo test --release -p vortex-file --test segment_cache_coalescing -- --include-ignored --nocapture

@codspeed

codspeed Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 24.86%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ 19 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

ℹ️ 40 benchmarks have no flame graph

The flamegraph could not be generated because we failed to resolve the symbols in the profiling trace. This happens when we fail to harvest information about language frames.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
✅ 2257 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ ℹ️ Simulation test_repeated_scan_scalar_at[int_float] 486.7 µs 368.2 µs +32.21%
⚡ WallTime filter_neon[80] 2.9 µs 2.5 µs +17.91%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ngates/segment-cache-loads (3e13bab) with develop (18aebea)

Open in CodSpeed

Resolve cache lookups before source registration, preserving eager registration for ready misses. Cover cold-read coalescing and cached neighboring segments with regressions and an explicit release benchmark.

Signed-off-by: Nicholas Gates <nick@nickgates.com>
@gatesn
gatesn force-pushed the ngates/segment-cache-loads branch from 08c306e to ddbda1f Compare October 15, 2026 23:50
@gatesn gatesn added the changelog/fix A bug fix label Oct 16, 2026
Signed-off-by: Nicholas Gates <nick@nickgates.com>
@gatesn
gatesn marked this pull request as ready for review October 16, 2026 02:41
@joseph-isaacs

Copy link
Copy Markdown
Contributor

We don't benchmark this anywhere do we?

@robert3005

Copy link
Copy Markdown
Contributor

Do you have a benchmark?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants