test: add tests for spill file sizes to verify View GC#21750
Merged
adriangb merged 3 commits intoapache:mainfrom Apr 20, 2026
Merged
test: add tests for spill file sizes to verify View GC#21750adriangb merged 3 commits intoapache:mainfrom
adriangb merged 3 commits intoapache:mainfrom
Conversation
Contributor
Author
|
Currently the 10KB threshold to trigger GC makes it a requirement to replicate that in tests, wonder if we can make it parametermized so that we can controller the threshold to trigger gc. PS : Got to learn about about loser tree while deep diving into spill and sort implementation and a nice talk about it. 😄 |
Made-with: Cursor
7037620 to
d31c248
Compare
Contributor
Author
|
@adriangb please take a look at it. |
adriangb
approved these changes
Apr 20, 2026
Comment on lines
+1432
to
+1435
| let strings: Vec<String> = (0..num_rows) | ||
| .map(|i| format!("this_is_a_long_string_to_ensure_it_is_not_inlined_and_causes_waste_{i}")) | ||
| .collect(); | ||
| let string_array = StringViewArray::from(strings); |
Contributor
There was a problem hiding this comment.
Since we don't need this later I wonder if we can avoid the allocation by feeding an iterator into the StringView or at least drop it immediately to free up memory.
Update StringView and BinaryView spill tests to use iterators instead of intermediate Vec allocations, reducing unnecessary memory overhead during test setup. Made-with: Cursor
Made-with: Cursor
Rich-T-kid
pushed a commit
to Rich-T-kid/datafusion
that referenced
this pull request
Apr 21, 2026
## Summary This PR adds unit tests to verify that `StringView` and `BinaryView` arrays are correctly compacted (garbage collected) before being spilled to disk. The tests address [Issue apache#21683](apache#21683) by: 1. Creating "bloated" batches with large underlying buffers. 2. Slicing them to a small number of rows (1%). 3. Spilling them to disk. 4. Asserting that the resulting file size is small (proving that GC removed the unused "ghost" data). ## Test plan - Run `cargo test -p datafusion-physical-plan --lib spill::mod::tests::test_spill_file_size_gc_verification_string_view` - Run `cargo test -p datafusion-physical-plan --lib spill::mod::tests::test_spill_file_size_gc_verification_binary_view` Made with [Cursor](https://cursor.com)
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.
Summary
This PR adds unit tests to verify that
StringViewandBinaryViewarrays are correctly compacted (garbage collected) before being spilled to disk.The tests address Issue #21683 by:
Test plan
cargo test -p datafusion-physical-plan --lib spill::mod::tests::test_spill_file_size_gc_verification_string_viewcargo test -p datafusion-physical-plan --lib spill::mod::tests::test_spill_file_size_gc_verification_binary_viewMade with Cursor