-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: Add config max_temp_directory_size to limit max disk usage for spilling queries
#15520
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
cf1ff47
Add disk limit field inside disk manager
2010YOUY01 c2ed38b
Implement disk usage tracking
2010YOUY01 4a25660
Update datafusion/execution/src/disk_manager.rs
2010YOUY01 3d7554d
Let unit-test use less memory
2010YOUY01 5506637
reduce UT's memory and disk usage to < 1MB
2010YOUY01 ca7ecc9
typo
2010YOUY01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,7 +49,12 @@ impl InProgressSpillFile { | |
| } | ||
| } | ||
|
|
||
| /// Appends a `RecordBatch` to the file, initializing the writer if necessary. | ||
| /// Appends a `RecordBatch` to the spill file, initializing the writer if necessary. | ||
| /// | ||
| /// # Errors | ||
| /// - Returns an error if the file is not active (has been finalized) | ||
| /// - Returns an error if appending would exceed the disk usage limit configured | ||
| /// by `max_temp_directory_size` in `DiskManager` | ||
| pub fn append_batch(&mut self, batch: &RecordBatch) -> Result<()> { | ||
| if self.in_progress_file.is_none() { | ||
| return Err(exec_datafusion_err!( | ||
|
|
@@ -70,6 +75,11 @@ impl InProgressSpillFile { | |
| } | ||
| if let Some(writer) = &mut self.writer { | ||
| let (spilled_rows, spilled_bytes) = writer.write(batch)?; | ||
| if let Some(in_progress_file) = &mut self.in_progress_file { | ||
| in_progress_file.update_disk_usage()?; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is quite nice that this is encapsulated as part of |
||
| } else { | ||
| unreachable!() // Already checked inside current function | ||
| } | ||
|
|
||
| // Update metrics | ||
| self.spill_writer.metrics.spilled_bytes.add(spilled_bytes); | ||
|
|
||
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
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.
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.
do we really need to generate 100MB to test temporary file space? Could we perhaps lower this to something less resource intensive like 1MB (and reduce the argument to
generate_series)?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.
5506637 reduced the disk and memory usage of UT to < 1MB