mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
sort: improve memory usage for extsort
This commit is contained in:
@@ -113,7 +113,7 @@ pub fn ext_sort(
|
||||
|
||||
chunk.push(seq);
|
||||
|
||||
if total_read >= settings.buffer_size {
|
||||
if total_read + chunk.len() * std::mem::size_of::<Line>() >= settings.buffer_size {
|
||||
super::sort_by(&mut chunk, &settings);
|
||||
write_chunk(
|
||||
settings,
|
||||
@@ -136,6 +136,9 @@ pub fn ext_sort(
|
||||
iter.chunks += 1;
|
||||
}
|
||||
|
||||
// We manually drop here to not go over our memory limit when we allocate below.
|
||||
drop(chunk);
|
||||
|
||||
// initialize buffers for each chunk
|
||||
//
|
||||
// Having a right sized buffer for each chunk for smallish values seems silly to me?
|
||||
|
||||
Reference in New Issue
Block a user