Skip to content

Commit

Permalink
perf: Use jemallocator by default for taso (#198)
Browse files Browse the repository at this point in the history
Also enables thin LTO on release builds.

Tested on `barenco_tof_10`, 10s timeout, single threaded, on my laptop.

Before / after:

<img
src="https://github.com/CQCL/tket2/assets/121866228/a3bec2d1-c985-4462-8404-d3c6d3baf4ea"
width="49%"/>
<img
src="https://github.com/CQCL/tket2/assets/121866228/c39e2bfc-b1b3-47a3-ae4f-837870a8b2fb"
width="49%"/>

---------

Co-authored-by: doug-q <[email protected]>
  • Loading branch information
aborgna-q and doug-q authored Oct 24, 2023
1 parent fb4c668 commit 038bb70
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ bench = false
name = "tket2"
path = "src/lib.rs"

[profile.release]
lto = "thin"

[dependencies]
lazy_static = "1.4.0"
cgmath = "0.18.0"
Expand Down
5 changes: 4 additions & 1 deletion taso-optimiser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ tracing-subscriber = "0.3.17"
tracing-appender = "0.2.2"
peak_alloc = { version = "0.2.0", optional = true }

[target.'cfg(not(target_env = "msvc"))'.dependencies]
tikv-jemallocator = "0.5"

[features]
default = ["peak_alloc"]
default = []
peak_alloc = ["dep:peak_alloc"]
7 changes: 4 additions & 3 deletions taso-optimiser/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ use tket2::optimiser::taso::log::TasoLogger;
use tket2::optimiser::TasoOptimiser;

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

#[cfg(feature = "peak_alloc")]
#[cfg(all(not(target_env = "msvc"), not(feature = "peak_alloc")))]
#[global_allocator]
static PEAK_ALLOC: PeakAlloc = PeakAlloc;
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;

/// Optimise circuits using Quartz-generated ECCs.
///
Expand Down

0 comments on commit 038bb70

Please sign in to comment.