Repository navigation
Open
Labels
P3Backlog: valid, low payoff-per-effortarea:queryQuery execution, planning, fast paths, overlay, result formattingperformancePerformance improvement (release notes: Performance)
Description
Follow-up from #2271, kept separate there on purpose.
Today
The per-row scan keeps whole-graph overlay translations across queries in global_translation_cache (fluree-db-query/src/binary_scan.rs). It was added so a reasoning materialization isn't re-translated on every query. The cache:
- is a process-wide LRU of 4 entries, keyed by
GlobalTranslationKey(ledger, snapshott, overlay content version, store id,to_t, graph, index); - holds per entry a whole graph's overlay translated into index ids (
TranslatedOverlayOps, about 50 B per op), plus untranslated and ephemeral-predicate state; - has no byte bound: an entry is as large as the graph's overlay;
- is not counted toward any configured limit, and nothing in diagnostics reports what it holds;
- keeps an entry until LRU eviction, even after its materialization is gone and no key can hit it again.
#2271 moved the batched lanes' per-predicate translations onto the materialization instead (DerivedFactsOverlay::attachment, fluree-db-query/src/reasoning_ops.rs):
- made lazily and shared by the queries reading that materialization;
- replaced when the store binding changes;
- counted toward the reasoning memory budget beside the derived facts, and declined (per-row) with one WARN when they won't fit;
- dropped with the materialization.
Proposal
Do the same for the scan's reasoning translations. They belong on the materialization, under the same accounting and diagnostics. Three things to settle:
- Scope. Only overlays that include a materialization would move. Plain novelty translations already have the per-segment cache in
LeafletCache(SegmentOps), which counts against the global cache budget. Check whetherglobal_translation_cachestill serves non-reasoning overlays, and whether those uses should stay as they are. - Duplication. A predicate the lanes translate is also inside the scan's whole-graph translation, so one derived extent can be held twice in translated form, plus the raw facts. Consider deriving the lanes' per-predicate ops from the whole-graph translation when it exists, or the reverse.
- Accounting. One reservation and one budget per materialization, covering the facts, the lanes' translations and the scan's translation.
The provisioning contract in docs/query/reasoning.md ("Memory a cached result holds") would then cover the scan's translations too.
Metadata
Metadata
Assignees
Labels
P3Backlog: valid, low payoff-per-effortarea:queryQuery execution, planning, fast paths, overlay, result formattingperformancePerformance improvement (release notes: Performance)
Activity