feat(query): add spill backoff with sleep for low-memory queries under global pressure#19655
Open
dqhl76 wants to merge 5 commits intodatabendlabs:mainfrom
Open
feat(query): add spill backoff with sleep for low-memory queries under global pressure#19655dqhl76 wants to merge 5 commits intodatabendlabs:mainfrom
dqhl76 wants to merge 5 commits intodatabendlabs:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 499dc953ab
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
499dc95 to
87757db
Compare
…r global pressure When global memory pressure triggers spill but the current query's memory usage is low, sleep with exponential backoff before spilling to give other queries a chance to release memory. Rename low_query_threshold to low_query_memory_bytes for clarity and add observability logging.
87757db to
a7145e0
Compare
zhang2014
reviewed
Apr 2, 2026
zhang2014
reviewed
Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
When global memory pressure triggers spilling, low-memory queries can now sleep with exponential backoff before actually spilling. This gives the system time to reclaim memory from heavier queries, avoiding unnecessary spill I/O for lightweight queries that aren't major contributors to memory pressure.
Controlled by two new settings:
spill_global_backoff_max_sleep_ms— Maximum total sleep time (in milliseconds) for one spill decision under global-pressure backoff. Default:2000.min_query_memory_usage— A query is considered low-memory when its memory usage in bytes is at or below this threshold. Default:0(disabled).Backoff uses exponential sleep starting at 200ms, doubling each attempt, capped by the remaining sleep budget. Once the budget is exhausted, the query spills normally.
Tests
Type of change
This change is