Repository navigation
Merge sorted minimizer runs within the process's open-file limits - #106
Merged
Merged
Conversation
The external sort of minimizer tuples opened and mapped every sorted run at once in the final merge. Each build thread writes runs of RAM / (2 * threads) bytes, so a large input at the default 8 GiB limit writes about a thousand runs and the merge failed with "cannot open file" under the usual soft limit of 1024 open files. Merge at most max_merge_fan_in runs at a time (1024, and at most half the soft RLIMIT_NOFILE) into longer runs until the rest fit in one final merge. The index is unchanged; one extra pass over the tuples is made only when the runs exceed the fan-in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Instead of capping the fan-in at 1024, raise the soft RLIMIT_NOFILE to the hard limit before merging and merge at most half of min(soft RLIMIT_NOFILE, vm.max_map_count) runs at a time. Builds whose runs fit in those limits keep a single merge pass, as before the bounded merge; extra rounds happen only when the runs exceed them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The constructor returns early when there is nothing to merge and left m_num_files_to_merge uninitialized, which GCC 13 -O3 reports as -Werror=maybe-uninitialized in test_merge_fan_in. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.
minimizers_tuples::merge()opens and memory-maps every sorted run at once. Every build thread writes at least one run, and large inputs write many more. Once there are more runs than RLIMIT_NOFILE allows (the soft limit is often 1024), the build aborts with "cannot open file".This PR:
merge();file_merging_iterator's counters for an empty merge (GCC 13 -O3 maybe-uninitialized).The fan-in comes from the actual limits, not a fixed constant: a constant cap would add merge passes to builds whose runs already fit, such as the 1279-run case below.
New test
test_merge_fan_in:Measurements: master 2ea1f8b vs this branch. Wall time is median (range). The index is byte-identical in every successful run.
salmonella_100 (13.1 M k-mers), -t 32 -g 1, 5 reps:
500 Mbp random, -t 64 -g 1, 3 reps:
500 Mbp random, -t 640 -g 1 (1279 runs), 3 reps:
Peak RSS and peak temporary disk are unchanged: about 2.1 GB RSS and 1.96 GB temp (2× tuple volume) at -t 64, about 2.7 GB RSS at -t 640.