Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/uu/sort/src/sort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ const POSITIVE: &u8 = &b'+';
// reasonably large chunks for typical workloads.
const MIN_AUTOMATIC_BUF_SIZE: usize = 512 * 1024; // 512 KiB
const FALLBACK_AUTOMATIC_BUF_SIZE: usize = 32 * 1024 * 1024; // 32 MiB
// On 32-bit systems, use a smaller max buffer (256 MiB) to avoid allocation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm my understanding, this is only a temporary fix right? I was trying to replicate the behaviour in GNU and it appears they have a mechanism to determine the available memory and gracefully fallback to smaller and smaller amounts that I was not able to get an allocation failure. I'm thinking this would be a good band-aid solution for now but would be good to add a TODO or keep the issue with the description that we're missing some compatibility when it comes to the memory allocation fallbacks

// failures due to limited virtual address space.
#[cfg(target_pointer_width = "32")]
const MAX_AUTOMATIC_BUF_SIZE: usize = 256 * 1024 * 1024; // 256 MiB
#[cfg(not(target_pointer_width = "32"))]
const MAX_AUTOMATIC_BUF_SIZE: usize = 1024 * 1024 * 1024; // 1 GiB

#[derive(Debug, Error)]
Expand Down
Loading