Skip to content

Commit 402ddf1

Browse files
committed
sort: on 32 bits, decrease the buf max size
See https://bugs.launchpad.net/ubuntu/+source/rust-coreutils/+bug/2137562
1 parent 2a044db commit 402ddf1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/uu/sort/src/sort.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ const POSITIVE: &u8 = &b'+';
123123
// reasonably large chunks for typical workloads.
124124
const MIN_AUTOMATIC_BUF_SIZE: usize = 512 * 1024; // 512 KiB
125125
const FALLBACK_AUTOMATIC_BUF_SIZE: usize = 32 * 1024 * 1024; // 32 MiB
126+
// On 32-bit systems, use a smaller max buffer (256 MiB) to avoid allocation
127+
// failures due to limited virtual address space.
128+
#[cfg(target_pointer_width = "32")]
129+
const MAX_AUTOMATIC_BUF_SIZE: usize = 256 * 1024 * 1024; // 256 MiB
130+
#[cfg(not(target_pointer_width = "32"))]
126131
const MAX_AUTOMATIC_BUF_SIZE: usize = 1024 * 1024 * 1024; // 1 GiB
127132

128133
#[derive(Debug, Error)]

0 commit comments

Comments
 (0)