-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Improve sort buffer sizing heuristics and honor explicit --buffer-size #8833
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
base: main
Are you sure you want to change the base?
Conversation
GNU testsuite comparison:
|
GNU testsuite comparison:
|
GNU testsuite comparison:
|
GNU testsuite comparison:
|
you have to refresh the fuzz/Cargo.lock file |
GNU testsuite comparison:
|
please follow this documentation for the performance work: We would like to see hyperfine results and codspeed benchmark :) |
src/uu/sort/src/sort.rs
Outdated
.filter(|s| matches!(s.settings.mode, SortMode::GeneralNumeric)) | ||
.count(); | ||
|
||
self.precomputed.fast_lexicographic = self.mode == SortMode::Default |
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.
it needs comments, and moved into a function
rlim_max: 0, | ||
}; | ||
match unsafe { getrlimit(RLIMIT_NOFILE, &raw mut limit) } { | ||
match unsafe { libc::getrlimit(RLIMIT_NOFILE, &mut limit) } { |
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.
why this change?
let file_hint = file_size_hint(files); | ||
let mem_hint = available_memory_hint(); | ||
|
||
match (file_hint, mem_hint) { |
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.
the cases need comments here
it is a bit cryptic
quarter.max(max) | ||
} | ||
|
||
#[cfg(target_os = "linux")] |
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.
i was already not convinced in #8802
but
there is probably a better way than parsing /proc/meminfo
esp in the sort.rs code
} | ||
} | ||
|
||
fn ascii_case_insensitive_cmp(a: &[u8], b: &[u8]) -> Ordering { |
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.
why is that necessary ?
path: Option<PathBuf>, | ||
} | ||
|
||
fn handler_state() -> Arc<Mutex<HandlerRegistration>> { |
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.
why ?
.clone() | ||
} | ||
|
||
fn ensure_signal_handler_installed(state: Arc<Mutex<HandlerRegistration>>) -> UResult<()> { |
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.
same, it needs some explanations
CodSpeed Performance ReportMerging #8833 will degrade performances by 2.69%Comparing Summary
Benchmarks breakdown
Footnotes
|
impressive wins :) |
Replaced fixed 1GB buffer size with dynamic calculation based on input file sizes and available memory. Added heuristics to clamp buffer size within 512 KiB to 128 MiB range, preventing overcommitment on constrained systems while optimizing for typical workloads. Updated dependencies and imports to use libc directly for better portability.
- Add sysconf to codespell ignore list to prevent false positives - Remove "NOTE:" from buffer heuristics comment for cleaner style
587a73c
to
287d6c4
Compare
GNU testsuite comparison:
|
Co-authored-by: Sylvestre Ledru <sylvestre@debian.org>
GNU testsuite comparison:
|
Extract logic for determining fast lexicographic and ASCII case-insensitive paths into new methods `can_use_fast_lexicographic()` and `can_use_fast_ascii_insensitive()` for improved code readability and maintainability.
…ion and latest snapshot loading - Added comment explaining the static guard for one-time handler installation per process - Added comment clarifying the need to load current lock/path snapshot for temp dir cleanup
i am planning to merge #8746
|
Improve memory detection on Linux by using libc::sysinfo instead of parsing /proc/meminfo. This provides more direct access to system memory info, calculates available memory as freeram + bufferram, and removes the need for the parse_meminfo_value helper function for better efficiency and accuracy.
Changed the cfg attribute from `target_family = "unix"` to `target_family = "linux"` to more precisely target Linux systems, aligning with the Linux-specific libc usage in the code.
…code This change updates the conditional compilation attribute from `target_family` to `target_os` to accurately target Linux OS-specific code, ensuring proper compilation behavior.
This change modifies the conditional compilation attribute for libc imports in the sort utility to include Android alongside Linux, enabling compatibility with Android platforms that share similar system interfaces.
Removed unnecessary import for _SC_PAGESIZE and _SC_PHYS_PAGES, and prefixed libc constants with 'libc::' in sysconf calls to ensure fully qualified references and avoid potential naming conflicts.
… to dictionary Updated the jargon wordlist in .vscode/cspell.dictionaries/jargon.wordlist.txt to include new technical terms, preventing false positives in spell checking for code-related documentation and comments.
GNU testsuite comparison:
|
Modified conditional compilation in physical_memory_bytes() to skip Unix-specific sysconf calls on Redox OS, ensuring compatibility by returning None for unsupported platforms.
GNU testsuite comparison:
|
GNU testsuite comparison:
|
GNU testsuite comparison:
|
Add automatic buffer-size heuristics (ported from commit a0e77d9). We now size external-sort chunks based on input file sizes and available memory, clamping to 512 KiB–128 MiB so we avoid both tiny buffers and risky overcommit on constrained systems.
Respect user-provided --buffer-size. Only automatically computed sizes are raised to the safety minimum; explicit values are left untouched, which keeps external sorting and --compress-program working even when users choose small buffers.
Performance Comparison (baseline vs. current)
Measurements come from hyperfine --warmup 3 --runs 10; values are means in milliseconds (lower is better).