Skip to content

add predicate cache#6024

Merged
trinity-1686a merged 9 commits intomainfrom
trinity.pointard/predicate-cache
Dec 16, 2025
Merged

add predicate cache#6024
trinity-1686a merged 9 commits intomainfrom
trinity.pointard/predicate-cache

Conversation

@trinity-1686a
Copy link
Contributor

Description

Add a predicate cache which can store the list of documents matching a (sub-)query.
This can be useful when multiple requests share the same fragment of query or the same query with other part of the request being distinct (search after, successive aggregation on the same set of document...)

at the moment we only insert these nodes to speed up search_after, ideally we would let people suggest in their query what might be replayed a bunch (the top level of a query that's going to use pagination, or a part of a query added systematically for access control by some middleware), or detect automatically good candidates for being cached.

///
/// The provided buffer must come from `HitSet::into_buffer`
pub fn from_buffer(buffer: OwnedBytes) -> Self {
let mut this = Self {
Copy link
Collaborator

@fulmicoton-dd fulmicoton-dd Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you went for a posting list format (as opposed to a bit set for instance), it might be nice to reuse tantivy's format and make this a TermScorer. It would add the skip list and might enable some dynamic performance optimization.

(can be done later and requires code in tantivy)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i started with a naive bitset, but moved to a posting list for compactness. There didn't seem to be enough public code in tantivy to use its posting list format from the outside, but i agree with the idea

@trinity-1686a trinity-1686a merged commit dd209a7 into main Dec 16, 2025
8 checks passed
@trinity-1686a trinity-1686a deleted the trinity.pointard/predicate-cache branch December 16, 2025 16:27
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.

2 participants