#1372

fix: record hybrid lookup metrics when results become ready

OpenMrCroxxwants to merge intofrom

Hybrid lookup durations previously ended when the caller polled the result, so application backpressure inflated hit/miss/error latency. Memory hits consumed through try_unwrap() skipped these metrics entirely.

Record synchronous memory hits immediately and asynchronous results before notifying each waiter. Each coalesced request retains its own start time and completion observer, including requests whose futures are dropped. Preserve existing metric names, hit/miss classification, and memory-hit histograms. Observers also cover concurrent insertion and task cancellation, and execute outside shard and inflight locks. The memory-hit path does not allocate a boxed observer.

Add six regression tests covering result consumption, coalesced fetches, dropped futures, disk hits, misses/errors, concurrent insertion, and cancellation. Document that lookup metrics describe completed requests independently of whether their results are consumed.

Validation:

  • cargo test -p foyer -p foyer-memory --lib — 58 passed.
  • cargo test -p foyer -p foyer-memory --lib --features tracing — 58 passed.
  • cargo clippy -p foyer -p foyer-memory --all-targets --features tracing -- -D warnings
  • cargo fmt --all --check
  • cargo +nightly fmt --all --check -- --config-path rustfmt.nightly.toml

Fixes #1370.

Activity

2
codecov[bot]21d ago

Codecov Report

:x: Patch coverage is 98.32776% with 5 lines in your changes missing coverage. Please review.

Files with missing linesCoverage Δ
foyer-memory/src/inflight.rs90.55% <100.00%> (+0.46%):arrow_up:
foyer-memory/src/raw.rs93.73% <98.91%> (+1.67%):arrow_up:
foyer/src/hybrid/cache.rs93.38% <99.41%> (+1.75%):arrow_up:
foyer-memory/src/cache.rs71.09% <85.71%> (-1.50%):arrow_down:

... and 3 files with indirect coverage changes

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.