-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Limit warmup memory usage #5524
Closed
Closed
Conversation
This file contains 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
fulmicoton
force-pushed
the
memory_log
branch
3 times, most recently
from
October 25, 2024 06:14
510c653
to
81280a7
Compare
Related: #5312 |
fulmicoton
force-pushed
the
memory_log
branch
from
October 25, 2024 08:45
81280a7
to
1e08a77
Compare
fulmicoton
changed the title
Adds a concept of request_id for logging/correlation purpose.
Adds a trace_id, split search time, and memory user for correlation purpose.
Oct 25, 2024
fulmicoton
force-pushed
the
memory_log
branch
4 times, most recently
from
October 25, 2024 09:16
0749e6f
to
1dd5544
Compare
fulmicoton
force-pushed
the
memory_log
branch
7 times, most recently
from
November 15, 2024 02:46
f971b9d
to
e1b7125
Compare
fulmicoton
changed the title
Adds a trace_id, split search time, and memory user for correlation purpose.
Limit warmup memory usage
Nov 15, 2024
Due to tantivy limitations, searching a split requires downloading all of the required data, and keep them in memory. We call this phase warmup. Before this PR, the only thing that curbed memory usage was the search permits: only N split search may happen concurrently. Unfortunately, the amount of data required here varies vastly. We need a mechanism to measure and avoid running more split search when memory is tight. Just using a semaphore is however not an option. We do not know beforehands how much memory will be required by a split search, so it could easily lead to a dead lock. Instead, this commit builds upon the search permit provider. The search permit provider is in charge of managing a configurable memory budget for this warmup memory. We introduce here a configurable "warmup_single_split_initial_allocation". A new leaf split search cannot be started if this memory is not available. This initial allocation is meant to be greater than what will be actually needed most of the time. The split search then holds this allocation until the end of warmup. After warmup, we can get the actual memory usage by interrogating the warmup cache. We can then update the amount of memory held. (most of the time, this should mean releasing some memory) In addition, in this PR, at this point, we also release the warmup search permit: We still have to perform the actual task of searching, but the thread pool will take care of limiting the number of concurrent task. Closes #5355
Also attach the permit to the actual memory cache to ensure memory is freed at the right moment.
Adding an extra generic field into the cache to optionally allow permit tracking is weird. Instead, we make the directory generic on the type of cache and use a wrapped cache when tracking is necessary.
rdettai
reviewed
Nov 28, 2024
quickwit/quickwit-search/src/root.rs
Outdated
Comment on lines
786
to
792
if is_top_1pct_memory_intensive( | ||
resource_stats.short_lived_cache_num_bytes, | ||
resource_stats.split_num_docs, | ||
) { | ||
// We log at most 5 times per minute. | ||
quickwit_common::rate_limited_info!(limit_per_min=5, split_num_docs=resource_stats.split_num_docs, %search_request.query_ast, short_lived_cached_num_bytes=resource_stats.short_lived_cache_num_bytes, query=%search_request.query_ast, "memory intensive query"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we create a metric as well?
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.
We also measure the amount of memory taken by a split search, and log this.