-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a benchmark/profiler to count cycles in demo-prover (#577)
* extract data_gen into its own function * temp push * add prover cycles * include multiple transactions * reduce txns * temp switch * cycle tracker macro * another temp commit * merge main and nightly * use run_without_prover for bench/profile * working metrics * add zk-cycle-utils. missed it * temporary commit * pass features to risc0 vm * feature gate all the bench things * cleanup and testing * check in readme * checking some cargo locks in prep for merge * some fixes * revert rollup config toml * working merge * cleanup and documentation * simplify the macro for generating the wrapped function * format fixes * README changes * simplify code as per lint * lint fix * add profiler to analyze trace * fix cargo lock * really fix Cargo.lock * trace options * cargo fmt * fix log error * fix prover bench * add docs and address comments * prover bench readme * add a skip proving option to demo-prover * add tests for macros * demo prover format * remove commented code * formatting --------- Co-authored-by: dubbelosix <dub@006.com>
- Loading branch information
1 parent
1e43aca
commit 6371c32
Showing
44 changed files
with
2,746 additions
and
147 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::collections::HashMap; | ||
|
||
use once_cell::sync::Lazy; | ||
use parking_lot::Mutex; | ||
|
||
pub static GLOBAL_HASHMAP: Lazy<Mutex<HashMap<String, (u64, u64)>>> = | ||
Lazy::new(|| Mutex::new(HashMap::new())); | ||
|
||
pub fn add_value(metric: String, value: u64) { | ||
let mut hashmap = GLOBAL_HASHMAP.lock(); | ||
hashmap | ||
.entry(metric) | ||
.and_modify(|(sum, count)| { | ||
*sum += value; | ||
*count += 1; | ||
}) | ||
.or_insert((value, 1)); | ||
} | ||
|
||
pub fn deserialize_custom(serialized: &[u8]) -> (String, u64) { | ||
let null_pos = serialized.iter().position(|&b| b == 0).unwrap(); | ||
let (string_bytes, size_bytes_with_null) = serialized.split_at(null_pos); | ||
let size_bytes = &size_bytes_with_null[1..]; // Skip the null terminator | ||
let string = String::from_utf8(string_bytes.to_vec()).unwrap(); | ||
let size = u64::from_ne_bytes(size_bytes.try_into().unwrap()); // Convert bytes back into usize | ||
(string, size) | ||
} | ||
|
||
pub fn metrics_callback(input: &[u8]) -> Vec<u8> { | ||
let met_tuple = deserialize_custom(input); | ||
add_value(met_tuple.0, met_tuple.1); | ||
vec![] | ||
} |
Oops, something went wrong.