Skip to content

Commit 57b3ecc

Browse files
committed
fix allocators recycling
1 parent 2a0c0c2 commit 57b3ecc

File tree

4 files changed

+23
-25
lines changed

4 files changed

+23
-25
lines changed

gpu_prover/src/execution/cpu_worker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub trait NonDeterminism: NonDeterminismCSRSource<Ram> + Clone {}
5454

5555
impl<T> NonDeterminism for T where T: NonDeterminismCSRSource<Ram> + Clone {}
5656

57-
const SNAPSHOT_PERIOD: usize = 1 << 20;
57+
const SNAPSHOT_PERIOD: usize = 1 << 22;
5858

5959
pub(crate) fn run_split_simulator(
6060
batch_id: u64,

gpu_prover/src/execution/prover.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl Default for ExecutionProverConfiguration {
8585
prover_context_config: Default::default(),
8686
host_allocator_backing_allocation_size: 1 << 26, // 64 MB
8787
replay_worker_threads_count: 4,
88-
host_allocators_per_worker_count: 16, // 1 GB
88+
host_allocators_per_worker_count: 64, // 4 GB
8989
host_allocators_per_device_count: 64, // 4 GB
9090
}
9191
}
@@ -450,12 +450,12 @@ impl<K: Clone + Debug + Eq + Hash> ExecutionProver<K> {
450450
} = commitment;
451451
trace!("BATCH[{batch_id}] PROVER received memory commitment for circuit {circuit_type:?}[{sequence_id}]");
452452
if let Some(inits_and_teardowns) = inits_and_teardowns {
453-
if let Some(allocator) = inits_and_teardowns.get_allocator() {
453+
for allocator in inits_and_teardowns.into_allocators() {
454454
self.free_allocators_sender.send(allocator).unwrap();
455455
}
456456
}
457457
if let Some(tracing_data) = tracing_data {
458-
if let Some(allocator) = tracing_data.get_allocator() {
458+
for allocator in tracing_data.into_allocators() {
459459
self.free_allocators_sender.send(allocator).unwrap();
460460
}
461461
}
@@ -476,12 +476,12 @@ impl<K: Clone + Debug + Eq + Hash> ExecutionProver<K> {
476476
} = proof;
477477
trace!("BATCH[{batch_id}] PROVER received proof for circuit {circuit_type:?}[{sequence_id}]");
478478
if let Some(inits_and_teardowns) = inits_and_teardowns {
479-
if let Some(allocator) = inits_and_teardowns.get_allocator() {
479+
for allocator in inits_and_teardowns.into_allocators() {
480480
self.free_allocators_sender.send(allocator).unwrap();
481481
}
482482
}
483483
if let Some(tracing_data) = tracing_data {
484-
if let Some(allocator) = tracing_data.get_allocator() {
484+
for allocator in tracing_data.into_allocators() {
485485
self.free_allocators_sender.send(allocator).unwrap();
486486
}
487487
}
@@ -1406,9 +1406,9 @@ mod tests {
14061406
&binary_image,
14071407
&text_section,
14081408
);
1409-
let non_determinism_source = QuasiUARTSource::new_with_reads(vec![1 << 20, 1 << 16]);
1409+
let non_determinism_source = QuasiUARTSource::new_with_reads(vec![1 << 26, 0]);
14101410
let (_, result) =
1411-
prover.get_results(false, 0, &0usize, 1 << 30, non_determinism_source, None);
1411+
prover.get_results(false, 0, &0usize, 1 << 36, non_determinism_source, None);
14121412
// match result {
14131413
// ExecutionProverResult::MemoryCommitment(memory_commitment) => {
14141414
// for (circuit_type, commitment) in memory_commitment

gpu_prover/src/prover/tracing_data.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ pub(crate) enum DelegationTracingDataHost<A: GoodAllocator> {
3939
}
4040

4141
impl<A: GoodAllocator> DelegationTracingDataHost<A> {
42-
pub fn get_allocator(self) -> Option<A> {
42+
pub fn into_allocators(self) -> Vec<A> {
4343
match self {
44-
DelegationTracingDataHost::BigIntWithControl(trace) => trace.get_allocator(),
45-
DelegationTracingDataHost::Blake2WithCompression(trace) => trace.get_allocator(),
46-
DelegationTracingDataHost::KeccakSpecial5(trace) => trace.get_allocator(),
44+
DelegationTracingDataHost::BigIntWithControl(trace) => trace.into_allocators(),
45+
DelegationTracingDataHost::Blake2WithCompression(trace) => trace.into_allocators(),
46+
DelegationTracingDataHost::KeccakSpecial5(trace) => trace.into_allocators(),
4747
}
4848
}
4949
}
@@ -82,11 +82,11 @@ pub(crate) enum UnrolledTracingDataHost<A: GoodAllocator> {
8282
}
8383

8484
impl<A: GoodAllocator> UnrolledTracingDataHost<A> {
85-
pub fn get_allocator(self) -> Option<A> {
85+
pub fn into_allocators(self) -> Vec<A> {
8686
match self {
87-
UnrolledTracingDataHost::Memory(trace) => trace.get_allocator(),
88-
UnrolledTracingDataHost::NonMemory(trace) => trace.get_allocator(),
89-
UnrolledTracingDataHost::Unified(trace) => trace.get_allocator(),
87+
UnrolledTracingDataHost::Memory(trace) => trace.into_allocators(),
88+
UnrolledTracingDataHost::NonMemory(trace) => trace.into_allocators(),
89+
UnrolledTracingDataHost::Unified(trace) => trace.into_allocators(),
9090
}
9191
}
9292
}
@@ -98,10 +98,10 @@ pub(crate) enum TracingDataHost<A: GoodAllocator> {
9898
}
9999

100100
impl<A: GoodAllocator> TracingDataHost<A> {
101-
pub fn get_allocator(self) -> Option<A> {
101+
pub fn into_allocators(self) -> Vec<A> {
102102
match self {
103-
TracingDataHost::Delegation(trace) => trace.get_allocator(),
104-
TracingDataHost::Unrolled(trace) => trace.get_allocator(),
103+
TracingDataHost::Delegation(trace) => trace.into_allocators(),
104+
TracingDataHost::Unrolled(trace) => trace.into_allocators(),
105105
}
106106
}
107107
}

gpu_prover/src/witness/trace.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ impl<T, A: GoodAllocator> ChunkedTraceHolder<T, A> {
3131
panic!("Index out of bounds");
3232
}
3333

34-
pub fn get_allocator(self) -> Option<A> {
35-
let chunks = self
36-
.chunks
34+
pub fn into_allocators(self) -> Vec<A> {
35+
self.chunks
3736
.into_iter()
38-
.map(|c| Arc::into_inner(c).unwrap())
39-
.collect_vec();
40-
chunks.get(0).map(|c| c.allocator().clone())
37+
.map(|c| Arc::into_inner(c).unwrap().allocator().clone())
38+
.collect()
4139
}
4240
}

0 commit comments

Comments
 (0)