Skip to content

explore: foyer hybrid cache for search (memory + disk)#6319

Draft
fmassot wants to merge 3 commits into
mainfrom
fmassot/foyer-hybrid-cache
Draft

explore: foyer hybrid cache for search (memory + disk)#6319
fmassot wants to merge 3 commits into
mainfrom
fmassot/foyer-hybrid-cache

Conversation

@fmassot
Copy link
Copy Markdown
Collaborator

@fmassot fmassot commented Apr 19, 2026

Summary

Exploration of using foyer as a hybrid (memory + NVMe disk) cache for search caches. When entries are evicted from memory, they spill to local disk instead of being lost.

This is an exploration branch — not production-ready.

@fmassot fmassot force-pushed the fmassot/foyer-hybrid-cache branch 3 times, most recently from d6cfcd1 to 0514712 Compare May 15, 2026 10:35
fmassot and others added 2 commits May 15, 2026 18:30
Adds an optional NVMe disk tier (via foyer) to Quickwit's search caches.
Entries evicted from the in-memory tier spill to local disk instead of
being lost; the next access reads from disk (~0.1ms) instead of going
back to S3 (~50-200ms).

Caches with a hybrid disk tier:
- `partial_request_cache` -> LeafSearchCache::{MemoryOnly, Hybrid}.
- `fast_field_cache` (.fast route in QuickwitCache) -> backed by a new
  FoyerStorageCache implementing the StorageCache trait.
- `split_footer_cache` -> SplitFooterCache::{Memory, Hybrid}.

The `predicate_cache` stays memory-only: its access trait
`quickwit_query::query_ast::PredicateCache` is synchronous (called
inside tantivy scoring hot paths), so a disk tier would require an
async trait migration which is out of scope for this PR.

Config (new fields on `SearcherConfig`, all default 0 = disabled):
- `fast_field_disk_cache_capacity: ByteSize`
- `split_footer_disk_cache_capacity: ByteSize`
- `partial_request_disk_cache_capacity: ByteSize`

A non-zero value on any of these enables the corresponding hybrid
cache. Disk files land under `{data_dir}/search-cache/{fast-field,
split-footer,partial-request}/`. Use a local NVMe mount (EBS contention
will mask the benefit).

Other changes:
- `quickwit-storage::metrics` is now public so `SingleCacheMetrics` is
  accessible from `quickwit-search`.
- `LeafSearchCache::Hybrid` and `SplitFooterCache::Hybrid` report hits
  and misses to the existing Prometheus counters.

Notes:
- The previous single `partial_request_disk_cache_{enabled,capacity}`
  field was misleading: it actually controlled disk capacity for both
  the partial_request cache and the fast_field route. Replaced by the
  three per-cache knobs above.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@fmassot fmassot force-pushed the fmassot/foyer-hybrid-cache branch from 0514712 to 66b8bbf Compare May 16, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant