Skip to content

fix: record hybrid lookup metrics when results become ready - #1372

Open
MrCroxx wants to merge 1 commit into
mainfrom
codex/fix-hybrid-completion-metrics
Open

MrCroxx wants to merge 1 commit into
mainfrom
codex/fix-hybrid-completion-metrics

Conversation

@MrCroxx

@MrCroxx MrCroxx commented Oct 9, 2026

Copy link
Copy Markdown
Member

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.

Signed-off-by: MrCroxx <mrcroxx.cs@gmail.com>
@codecov

codecov Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
foyer-memory/src/cache.rs 85.71% 3 Missing ⚠️
foyer-memory/src/raw.rs 98.91% 1 Missing ⚠️
foyer/src/hybrid/cache.rs 99.41% 1 Missing ⚠️
Files with missing lines Coverage Δ
foyer-memory/src/inflight.rs 90.55% <100.00%> (+0.46%) ⬆️
foyer-memory/src/raw.rs 93.73% <98.91%> (+1.67%) ⬆️
foyer/src/hybrid/cache.rs 93.38% <99.41%> (+1.75%) ⬆️
foyer-memory/src/cache.rs 71.09% <85.71%> (-1.50%) ⬇️

... and 3 files with indirect coverage changes

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

@MrCroxx MrCroxx self-assigned this Oct 9, 2026
@MrCroxx MrCroxx added bug Something isn't working refactor labels Oct 9, 2026
@MrCroxx MrCroxx added this to the v0.23 milestone Oct 9, 2026

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

bug Something isn't working refactor

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

bug: hybrid hit/miss duration includes caller-side wait; try_unwrap() skips metrics

1 participant