Skip to content

schedule leaf searches by (priority, remaining_splits) lexicographically - #6695

Open
Abdul-Andha wants to merge 4 commits into
mainfrom
abdul.andha/query-priority
Open

schedule leaf searches by (priority, remaining_splits) lexicographically#6695
Abdul-Andha wants to merge 4 commits into
mainfrom
abdul.andha/query-priority

Conversation

@Abdul-Andha

@Abdul-Andha Abdul-Andha commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Description

  • Add priority to SearchRequest
  • LeafPermitRequest was ordered by remaining_splits. Now it is ordered by (priority, remaining_splits)
    • This lets a query with more splits and a higher priority (smaller int is higher priority) skip the line against a query with less splits and a lower priority

How was this PR tested?

  • Unit tests
  • test_search_permit_priority_precedes_remaining_splits


// Scheduling priority for leaf search execution. Negative values are allowed,
// and lower values have higher priority. Callers that omit it get priority 0.
optional int32 priority = 21;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
optional int32 priority = 21;
int32 priority = 21;

No need for optional if we want to default to 0. Unless we want to semantically differentiate None from Some(0)

// the raw IntermediateAggregationResults bytes instead.
bool skip_aggregation_finalization = 19;

reserved 20;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why reserve 20?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

20 is used in pomsky. it will be easier to sync if we don't use 20, i think

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then add a comment.

@Abdul-Andha
Abdul-Andha marked this pull request as ready for review August 17, 2026 17:24
@Abdul-Andha
Abdul-Andha requested a review from a team as a code owner August 17, 2026 17:24

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

https://github.com/quickwit-oss/quickwit/blob/8305498a4764978cc4576db53ae0cefc4c5624bd/quickwit-proto/src/codegen/quickwit/quickwit.search.rs#L213-L215
P2 Badge Exclude scheduling priority from the leaf cache key

Because SearchRequest derives Hash/Eq and LeafSearchCache stores the entire request in its CacheKey (leaf_cache.rs:84-114), this new field makes otherwise identical searches with different priorities occupy separate cache entries. Priority affects only scheduling, not search results, so workloads issuing the same query at different priorities lose valid cache hits, increase cache churn, and can make high-priority requests perform unnecessary split searches; normalize priority when constructing the cache key.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

other.priority.cmp(&self.priority).then_with(|| {
other
.single_split_permit_requests
.as_slice()
.len()
.cmp(&self.single_split_permit_requests.as_slice().len())
})

P2 Badge Skip unserviceable priority heads

When the highest-priority request's next split exceeds the currently available memory, this ordering keeps that request at the heap head, and pop_next_request_if_serviceable returns without examining lower-priority requests whose splits would fit. For example, with one warmup slot free and 40 MB available, a promoted 50 MB split blocks a queued 10 MB split, leaving usable capacity idle until another active search releases memory. The scheduler should preserve priority among serviceable requests rather than allowing an unserviceable priority head to block the entire queue.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

task_metadata: Vec<SplitSearchTaskMetadata>,
) -> (Self, Vec<SearchPermitFuture>) {
assert!(!task_metadata.is_empty(), "task_metadata must not be empty");
let priority = task_metadata[0].priority;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it's a bit strange that all tasks must have the same priority, but there's still a per-task priority field

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i agree its a bit strange. i think the alternative is introducing a new struct for per-leafsearch metadata. what do you think?

struct LeafSearchTaskMetadata {
    priority: i32,
    splits: Vec<SplitSearchTaskMetadata>,
}

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.

3 participants