Repository navigation
fix: spill external-sort runs into one file - #1062
Merged
Merged
Conversation
The external sort of make_edits wrote each sorted run to its own spool file and kept one descriptor per run open during the merge. With enough runs this hits the open-file limit: the release build's container fails `sorts_in_memory_and_on_disk` (1000 runs) with "No file descriptors available (os error 24)", and a large production input could do the same. Now all runs of a spill go into a single temporary file, one lz4 frame after the other. During the merge every run reads its own byte range with positional reads (pread), so a spill holds one descriptor no matter how many runs it writes. records.rs gains read_records and write_records for header-less frames of records, which RecordReader and RecordWriter now share. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ttfb2JL29fRPntpK2EgHuM
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.
Requested by Sascha · project thread
What failed
The release build fails in
cargo auditable test --release --locked:Spill(the external sort inmake_edits) wrote every sorted run to its own file (run-0,run-1, …) and, during the merge, held one open descriptor per run. With a budget of 1 byte the test writes 1000 runs, which exceeds the container's open-file limit. A large production input could hit the same limit.Fix
pread) on one sharedFile, so a spill holds one descriptor regardless of the number of runs.tables::recordsgainsread_records/write_recordsfor header-less record frames;RecordReaderandRecordWriternow use the same code.many_runs_share_one_file_descriptorwrites 5000 runs and checks the descriptor count via/proc/self/fd.Testing
ulimit -n 256before the fix.cargo test --release --lockedpasses in full (lib + integration, with tippecanoe installed) underulimit -n 1024.cargo clippy --release --all-targets --locked -- -D warningsandcargo fmt --checkare clean.Generated by Claude Code