Skip to content

Commit

Permalink
Flamegraph script
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Oct 4, 2023
1 parent b864e4f commit 1b19b2c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pr-run-mode = "plan"
[profile.release]
lto = "thin"

[profile.perf]
[profile.profiling]
inherits = "release"
debug = 1

Expand Down
5 changes: 3 additions & 2 deletions crates/install-wheel-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ walkdir = { workspace = true }
zip = { version = "0.6.6", default-features = false, features = ["deflate"] } # no default features for zstd

[features]
default = ["cli"]
default = ["cli", "parallel"]
python_bindings = ["pyo3", "tracing-subscriber"]
cli = ["clap", "rayon"]
cli = ["clap"]
parallel = ["rayon"]

[dev-dependencies]
indoc = { workspace = true }
Expand Down
17 changes: 15 additions & 2 deletions crates/install-wheel-rs/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use clap::Parser;
use fs_err::File;
use install_wheel_rs::{install_wheel, CompatibleTags, Error, InstallLocation, WheelFilename};
#[cfg(feature = "rayon")]
use rayon::iter::{IntoParallelIterator, ParallelIterator};
use std::path::PathBuf;
use std::str::FromStr;
Expand All @@ -18,6 +19,9 @@ struct Args {
/// The minor version of the current python interpreter
#[clap(long)]
minor: u8,
/// Compile .py files to .pyc (errors are ignored)
#[clap(long)]
compile: bool,
}

fn main() -> Result<(), Error> {
Expand All @@ -44,14 +48,23 @@ fn main() -> Result<(), Error> {
})
.collect::<Result<_, Error>>()?;

let wheels = {
#[cfg(feature = "rayon")]
{
wheels.into_par_iter()
}
#[cfg(not(feature = "rayon"))]
{
wheels.into_iter()
}
};
wheels
.into_par_iter()
.map(|(wheel, filename)| {
install_wheel(
&locked_dir,
File::open(wheel)?,
filename,
false,
args.compile,
&[],
// Only relevant for monotrail style installation
"",
Expand Down
8 changes: 5 additions & 3 deletions flamegraph.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env bash

cargo build -p install-wheel-rs --bin install-wheel-rs --profile profiling --no-default-features --features cli
rm -rf test-venvs/benchmark
virtualenv test-venvs/benchmark
VIRTUAL_ENV=test-venvs/benchmark flamegraph -o flamegraph_plotly.svg -- target/release/monotrail wheel-install --no-compile test-data/popular-wheels/plotly-5.5.0-py2.py3-none-any.whl
VIRTUAL_ENV=test-venvs/benchmark flamegraph -o flamegraph_popular.svg -- target/release/monotrail wheel-install --no-compile test-data/popular-wheels/*
virtualenv -p 3.8 test-venvs/benchmark

VIRTUAL_ENV=test-venvs/benchmark flamegraph -o flamegraph_plotly.svg -- target/profiling/install-wheel-rs --major 3 --minor 8 test-data/popular-wheels/plotly-5.5.0-py2.py3-none-any.whl
VIRTUAL_ENV=test-venvs/benchmark flamegraph -o flamegraph_popular.svg -- target/profiling/install-wheel-rs --major 3 --minor 8 test-data/popular-wheels/*

0 comments on commit 1b19b2c

Please sign in to comment.