Skip to content

Commit

Permalink
feat: Track max memory usage for TASO (#120)
Browse files Browse the repository at this point in the history
Adds a `peak_alloc` feature to the binary (enabled by default) to print
the max memory usage at the end of the execution.
  • Loading branch information
aborgna-q authored Sep 20, 2023
1 parent 41eaf72 commit 02d1e38
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
7 changes: 6 additions & 1 deletion taso-optimiser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ serde_json = "1.0"
tket2 = { path = "../", features = ["portmatching"] }
quantinuum-hugr = { workspace = true }
itertools = { workspace = true }
tket-json-rs = { workspace = true }
tket-json-rs = { workspace = true }
peak_alloc = { version = "0.2.0", optional = true }

[features]
default = ["peak_alloc"]
peak_alloc = ["dep:peak_alloc"]
10 changes: 10 additions & 0 deletions taso-optimiser/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ use tket2::{
};
use tket_json_rs::circuit_json::SerialCircuit;

#[cfg(feature = "peak_alloc")]
use peak_alloc::PeakAlloc;

#[cfg(feature = "peak_alloc")]
#[global_allocator]
static PEAK_ALLOC: PeakAlloc = PeakAlloc;

/// Optimise circuits using Quartz-generated ECCs.
///
/// Quartz: <https://github.com/quantum-compiler/quartz>
Expand Down Expand Up @@ -91,5 +98,8 @@ fn main() {
println!("Saving result");
save_tk1_json_file(output_path, &opt_circ).unwrap();

#[cfg(feature = "peak_alloc")]
println!("Peak memory usage: {} GB", PEAK_ALLOC.peak_usage_as_gb());

println!("Done.")
}

0 comments on commit 02d1e38

Please sign in to comment.