Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Make online and offline memory use vectors of pages instead of hashmaps #1224

Merged
merged 17 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/vm/src/arch/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct MemoryConfig {

impl Default for MemoryConfig {
fn default() -> Self {
Self::new(29, 1, 29, 29, 17, 64, 1 << 24)
Self::new(3, 1, 29, 29, 17, 64, 1 << 24)
}
}

Expand Down
10 changes: 9 additions & 1 deletion crates/vm/src/system/memory/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ impl<F: PrimeField32> MemoryController<F> {
memory_bus,
range_checker.clone(),
mem_config.clk_max_bits,
Golovanov399 marked this conversation as resolved.
Show resolved Hide resolved
mem_config,
))),
access_adapters: AccessAdapterInventory::new(
range_checker.clone(),
Expand Down Expand Up @@ -298,6 +299,7 @@ impl<F: PrimeField32> MemoryController<F> {
memory_bus,
range_checker.clone(),
mem_config.clk_max_bits,
mem_config,
))),
access_adapters: AccessAdapterInventory::new(
range_checker.clone(),
Expand All @@ -312,6 +314,7 @@ impl<F: PrimeField32> MemoryController<F> {
}

pub fn memory_image(&self) -> &MemoryImage<F> {
// TODO: just return in current form rather than converting
Golovanov399 marked this conversation as resolved.
Show resolved Hide resolved
&self.memory.data
}

Expand Down Expand Up @@ -346,7 +349,7 @@ impl<F: PrimeField32> MemoryController<F> {
panic!("Cannot set initial memory after first timestamp");
}
let mut offline_memory = self.offline_memory.lock().unwrap();
offline_memory.set_initial_memory(memory.clone());
offline_memory.set_initial_memory(memory.clone(), self.mem_config);

self.memory = Memory::from_image(memory.clone(), self.mem_config.access_capacity);

Expand Down Expand Up @@ -452,6 +455,7 @@ impl<F: PrimeField32> MemoryController<F> {
}

fn replay_access_log(&mut self) {
let start = std::time::Instant::now();
let log = mem::take(&mut self.memory.log);

let mut offline_memory = self.offline_memory.lock().unwrap();
Expand All @@ -465,6 +469,10 @@ impl<F: PrimeField32> MemoryController<F> {
&mut self.access_adapters,
);
}
eprintln!(
Golovanov399 marked this conversation as resolved.
Show resolved Hide resolved
"- - - - - - - - - - - - - - - replay_access_log time: {:?}",
start.elapsed()
);
}

fn replay_access(
Expand Down
1 change: 1 addition & 0 deletions crates/vm/src/system/memory/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod merkle;
mod offline;
pub mod offline_checker;
pub mod online;
mod paged_vec;
mod persistent;
#[cfg(test)]
mod tests;
Expand Down
Loading
Loading