Skip to content

Optimize layered retrieval to reduce per-layer query overhead #23

@BennettSchwartz

Description

@BennettSchwartz

Summary

Retrieval currently performs one store query per memory type layer and then filters in memory, which can become expensive as data grows.

Evidence

  • pkg/retrieval/retrieval.go loops over layers and calls store.ListByType for each.
  • Trust/salience filters are applied after loading records into memory.

Impact

Higher latency and memory pressure on large datasets, especially for broad retrievals.

Proposed work

Introduce an optimized retrieval path that applies filters closer to storage (where possible), or batch-fetches efficiently before trust filtering.

Acceptance criteria

  • Benchmark demonstrates improved retrieval performance for larger datasets.
  • Behavior remains equivalent for trust filtering and final ranking.
  • Add tests/benchmarks covering optimized path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:runtimeDaemon runtime and shutdown behaviorenhancementNew feature or requestpriority:mediumImportant but not urgenttype:tech-debtMaintenance and engineering quality work

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions