Skip to content

Commit

Permalink
Skip hashes for perf
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Oct 5, 2023
1 parent e70f3d8 commit 10730ea
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ srcery/poetry.lock
target
target-*
test-data/popular-wheels
test-data/stored
test-venvs
venv
zcc
zcc
1 change: 1 addition & 0 deletions crates/install-wheel-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ pub fn install_wheel_in_venv(
File::open(wheel)?,
filename,
false,
true,
&[],
// Only relevant for monotrail style installation
"",
Expand Down
4 changes: 4 additions & 0 deletions crates/install-wheel-rs/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ struct Args {
/// Compile .py files to .pyc (errors are ignored)
#[clap(long)]
compile: bool,
/// Don't check the hashes in RECORD
#[clap(long)]
skip_hashes: bool,
}

fn main() -> Result<(), Error> {
Expand Down Expand Up @@ -65,6 +68,7 @@ fn main() -> Result<(), Error> {
File::open(wheel)?,
filename,
args.compile,
!args.skip_hashes,
&[],
// Only relevant for monotrail style installation
"",
Expand Down
1 change: 1 addition & 0 deletions crates/install-wheel-rs/src/python_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl LockedVenv {
File::open(wheel)?,
filename,
true,
true,
&[],
// unique_version can be anything since it's only used to monotrail
"",
Expand Down
11 changes: 9 additions & 2 deletions crates/install-wheel-rs/src/wheel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,7 @@ pub fn install_wheel(
reader: impl Read + Seek,
filename: WheelFilename,
compile: bool,
check_hashes: bool,
// initially used to the console scripts, currently unused. Keeping it because we likely need
// it for validation later
_extras: &[String],
Expand Down Expand Up @@ -1101,8 +1102,13 @@ pub fn install_wheel(
// > 1.d Else unpack archive into platlib (site-packages).
// We always install in the same virtualenv site packages
debug!(name = name.as_str(), "Extracting file");
let unpacked_paths =
unpack_wheel_files(&site_packages, &record_path, &mut archive, &record, true)?;
let unpacked_paths = unpack_wheel_files(
&site_packages,
&record_path,
&mut archive,
&record,
check_hashes,
)?;
debug!(
name = name.as_str(),
"Extracted {} files",
Expand Down Expand Up @@ -1350,6 +1356,7 @@ mod test {
File::open(wheel).unwrap(),
WheelFilename::from_str(&filename).unwrap(),
true,
true,
&[],
"0.9.9",
&python,
Expand Down
1 change: 1 addition & 0 deletions crates/monotrail/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ fn download_and_install(
File::open(wheel)?,
filename,
compile,
true,
&spec.extras,
&spec.unique_version,
&sys_executable,
Expand Down
23 changes: 21 additions & 2 deletions flamegraph.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
#!/usr/bin/env bash

set -e

cargo build -p install-wheel-rs --bin install-wheel-rs --profile profiling --no-default-features --features cli
rm -rf test-venvs/benchmark
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/*
compressed=test-data/popular-wheels/plotly-5.5.0-py2.py3-none-any.whl
stored=test-data/stored/plotly-5.5.0-py2.py3-none-any.whl

if [ ! -f "$stored" ]; then
mkdir -p test-data/stored
# https://stackoverflow.com/a/34701207/3549270
tmp_dir=$(mktemp -d)
unzip -qq "$compressed" -d "$tmp_dir"
pwd=$(pwd)
cd "$tmp_dir"
zip -q -0 -r "$pwd/$stored" ./*
cd "$pwd"
rm -r "$tmp_dir"
fi


VIRTUAL_ENV=test-venvs/benchmark flamegraph -o flamegraph_plotly.svg -- target/profiling/install-wheel-rs --skip-hashes --major 3 --minor 8 "$compressed"
VIRTUAL_ENV=test-venvs/benchmark flamegraph -o flamegraph_plotly_stored.svg -- target/profiling/install-wheel-rs --skip-hashes --major 3 --minor 8 "$stored"
VIRTUAL_ENV=test-venvs/benchmark flamegraph -o flamegraph_popular.svg -- target/profiling/install-wheel-rs --skip-hashes --major 3 --minor 8 test-data/popular-wheels/*

0 comments on commit 10730ea

Please sign in to comment.