sort: improve memory usage for extsort

This commit is contained in:
Michael Debertol
2021-05-07 21:51:31 +02:00
parent c38373946a
commit 8c9faa16b9
+4 -1
View File
@@ -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?