From 499841d2fcf882ff278bb60f99f7d21cb0409f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Garillot?= Date: Wed, 20 Sep 2023 06:16:08 -0400 Subject: [PATCH] fix: speed up hydration --- src/store.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/store.rs b/src/store.rs index 7677ece1a5..b5d48bddac 100644 --- a/src/store.rs +++ b/src/store.rs @@ -2,7 +2,7 @@ use arc_swap::ArcSwap; use elsa::sync::{FrozenMap, FrozenVec}; use elsa::sync_index_set::FrozenIndexSet; use once_cell::sync::OnceCell; -use rayon::prelude::{ParallelBridge, ParallelIterator}; +use rayon::prelude::{IntoParallelRefIterator, ParallelIterator}; use std::fmt; use std::sync::Arc; use std::usize; @@ -1363,19 +1363,24 @@ impl Store { pub fn hydrate_scalar_cache(&self) { self.ensure_constants(); - self.dehydrated.load().iter().par_bridge().for_each(|ptr| { + let dehydrated = self.dehydrated.load().iter().cloned().collect::>(); + + dehydrated.par_iter().for_each(|ptr| { self.hash_expr(ptr).expect("failed to hash_expr"); }); self.dehydrated.swap(Arc::new(FrozenVec::default())); - self.dehydrated_cont + let dehydrated_cont = self + .dehydrated_cont .load() .iter() - .par_bridge() - .for_each(|ptr| { - self.hash_cont(ptr).expect("failed to hash_cont"); - }); + .cloned() + .collect::>(); + + dehydrated_cont.par_iter().for_each(|ptr| { + self.hash_cont(ptr).expect("failed to hash_cont"); + }); self.dehydrated_cont.swap(Arc::new(FrozenVec::default())); }