Skip to content

Commit

Permalink
from parallel iterator consumed too much memory
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Oct 29, 2021
1 parent b883e53 commit 8e88408
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions polars/polars-core/src/chunked_array/upstream_traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,20 +272,13 @@ fn collect_into_linked_list<I>(par_iter: I) -> LinkedList<Vec<I::Item>>
where
I: IntoParallelIterator,
{
use crate::POOL;
let it = par_iter.into_par_iter();
if let Some(len) = it.opt_len() {
it.fold(
|| Vec::with_capacity(len / POOL.current_num_threads()),
vec_push,
)
// be careful optimizing allocations. Its hard to figure out the size
// needed
// https://github.com/pola-rs/polars/issues/1562
it.fold(Vec::new, vec_push)
.map(as_list)
.reduce(LinkedList::new, list_append)
} else {
it.fold(Vec::new, vec_push)
.map(as_list)
.reduce(LinkedList::new, list_append)
}
}

fn get_capacity_from_par_results<T>(ll: &LinkedList<Vec<T>>) -> usize {
Expand Down

0 comments on commit 8e88408

Please sign in to comment.