-
Notifications
You must be signed in to change notification settings - Fork 1
Perf/deep merkle executor misc #672
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,10 +105,15 @@ impl Executor { | |
|
|
||
| /// Run to completion and return all logs (consumes executor) | ||
| pub fn run(mut self) -> Result<ExecutionResult, ExecutorError> { | ||
| let mut logs = Vec::with_capacity(CHUNK_SIZE); | ||
|
|
||
| while let Some(chunk) = self.resume()? { | ||
| logs.extend_from_slice(chunk); | ||
| let mut logs = Vec::new(); | ||
|
|
||
| // `resume()` fills `self.logs` (a reused chunk buffer) and returns a | ||
| // borrow of it. Drop that borrow immediately (`.is_some()`), then *move* | ||
| // the chunk out with `append` instead of cloning it via | ||
| // `extend_from_slice`: this avoids holding a second copy of every chunk | ||
| // and the per-log clone, lowering peak log memory during proving. | ||
| while self.resume()?.is_some() { | ||
| logs.append(&mut self.logs); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This directly reads The old |
||
| } | ||
|
|
||
| Ok(ExecutionResult { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment claims this avoids "the per-log clone, lowering peak log memory during proving", but
Logcontains onlyu64fields — cloning is a bitwise copy that compiles to the same code as a move. The memory argument doesn't hold. The real (minor) benefit is avoiding theClonetrait dispatch, which LLVM inlines anyway.Also worth restoring the pre-allocation: without it, the first
appendtriggers an immediate realloc from 0.