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 warningscargo fmt --all --checkcargo +nightly fmt --all --check -- --config-path rustfmt.nightly.toml
Fixes #1370.
Codecov Report
:x: Patch coverage is
98.32776%with5 linesin your changes missing coverage. Please review.90.55% <100.00%> (+0.46%)93.73% <98.91%> (+1.67%)93.38% <99.41%> (+1.75%)71.09% <85.71%> (-1.50%)... and 3 files with indirect coverage changes
:rocket: New features to boost your workflow: