Skip to content

Commit c7263ab

Browse files
committed
implement right way of arc unwrap
1 parent a15a32d commit c7263ab

File tree

3 files changed

+13
-22
lines changed

3 files changed

+13
-22
lines changed

ceno_zkvm/src/scheme/utils.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ use ff_ext::ExtensionField;
55
use itertools::Itertools;
66
use multilinear_extensions::{
77
commutative_op_mle_pair_pool,
8-
mle::{DenseMultilinearExtension, FieldType, IntoMLE, MultilinearExtension},
8+
mle::{DenseMultilinearExtension, FieldType, IntoMLE},
99
op_mle_xa_b_pool, op_mle3_range_pool,
1010
util::ceil_log2,
1111
virtual_poly_v2::ArcMultilinearExtension,
1212
};
1313

1414
use ff::Field;
1515

16-
const POOL_CAP: usize = 12;
16+
const POOL_CAP: usize = 3;
1717

1818
use rayon::{
1919
iter::{
@@ -268,15 +268,11 @@ fn try_recycle_arcpoly<E: ExtensionField>(
268268
Cow::Borrowed(_) => (),
269269
Cow::Owned(_) => {
270270
let poly = poly.into_owned();
271-
let poly = poly.dyn_try_unwrap().unwrap();
272-
273-
// let poly = Box::downcast::<MultilinearExtension<E>>(poly).unwrap();
274-
275-
// match poly.evaluations {
276-
// FieldType::Base(vec) => pool_b.return_to_pool(vec),
277-
// FieldType::Ext(vec) => pool_e.return_to_pool(vec),
278-
// _ => unreachable!(),
279-
// };
271+
match poly.arc_try_unwrap().unwrap() {
272+
FieldType::Base(vec) => pool_b.return_to_pool(vec),
273+
FieldType::Ext(vec) => pool_e.return_to_pool(vec),
274+
_ => unreachable!(),
275+
};
280276
}
281277
};
282278
}

ceno_zkvm/src/utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ impl<T> SimpleVecPool<T> {
260260

261261
// Return an item to the pool
262262
pub fn return_to_pool(&mut self, item: T) {
263-
println!("got return!");
264263
self.pool.push_back(item);
265264
}
266265
}

multilinear_extensions/src/mle.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ pub trait MultilinearExtension<E: ExtensionField>: Send + Sync {
6363
}
6464
}
6565

66-
fn dyn_try_unwrap(
67-
self: Arc<Self>,
68-
) -> Option<Box<dyn MultilinearExtension<E, Output = Self::Output> + Send + Sync>>;
66+
fn arc_try_unwrap(self: Arc<Self>) -> Option<FieldType<E>>;
6967
}
7068

7169
impl<E: ExtensionField> Debug for dyn MultilinearExtension<E, Output = DenseMultilinearExtension<E>> {
@@ -826,10 +824,10 @@ impl<E: ExtensionField> MultilinearExtension<E> for DenseMultilinearExtension<E>
826824
}
827825
}
828826

829-
fn dyn_try_unwrap(
830-
self: Arc<Self>,
831-
) -> Option<Box<dyn MultilinearExtension<E, Output = Self::Output> + Send + Sync>> {
832-
Arc::try_unwrap(self).ok().map(|it| Box::new(it) as _)
827+
fn arc_try_unwrap(self: Arc<Self>) -> Option<FieldType<E>> {
828+
Arc::try_unwrap(self)
829+
.ok()
830+
.map(|it| it.evaluations_to_owned())
833831
}
834832
}
835833

@@ -1003,9 +1001,7 @@ impl<'a, E: ExtensionField> MultilinearExtension<E> for RangedMultilinearExtensi
10031001
unimplemented!()
10041002
}
10051003

1006-
fn dyn_try_unwrap(
1007-
self: Arc<Self>,
1008-
) -> Option<Box<dyn MultilinearExtension<E, Output = Self::Output> + Send + Sync>> {
1004+
fn arc_try_unwrap(self: Arc<Self>) -> Option<FieldType<E>> {
10091005
unimplemented!()
10101006
}
10111007
}

0 commit comments

Comments
 (0)