-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pipelined extraction #236
Open
cosmicexplorer
wants to merge
10
commits into
zip-rs:master
Choose a base branch
from
cosmicexplorer:pipelined-extract-v2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+2,541
−3
Open
pipelined extraction #236
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2c02588
pipelined extraction
cosmicexplorer a1734b1
bzip2 support needed for benchmark test
cosmicexplorer 3f0a887
more review comments
cosmicexplorer ec63cdd
fix merge errors
cosmicexplorer c311784
correctly handle backslashes in entry names (i.e. don't)
cosmicexplorer 8efb409
make PathSplitError avoid consing a String until necessary
cosmicexplorer 3c19c28
add repro_old423 test for pipelining
cosmicexplorer 6ccecd0
silence dead code warnings for windows
cosmicexplorer 7332eb6
fix ci error
cosmicexplorer c9dd876
avoid erroring for top-level directory entries
cosmicexplorer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,86 @@ | ||
use bencher::{benchmark_group, benchmark_main}; | ||
|
||
use bencher::Bencher; | ||
use tempdir::TempDir; | ||
|
||
use std::fs; | ||
use std::path::Path; | ||
|
||
use zip::result::ZipResult; | ||
use zip::ZipArchive; | ||
|
||
#[cfg(all(feature = "parallelism", feature = "bzip2", unix))] | ||
use zip::read::{split_extract, ExtractionParameters}; | ||
|
||
/* This archive has a set of entries repeated 20x: | ||
* - 200K random data, stored uncompressed (CompressionMethod::Stored) | ||
* - 246K text data (the project gutenberg html version of king lear) | ||
* (CompressionMethod::Bzip2, compression level 1) (project gutenberg ebooks are public domain) | ||
* | ||
* The full archive file is 5.3MB. | ||
*/ | ||
fn get_test_archive() -> ZipResult<ZipArchive<fs::File>> { | ||
let path = | ||
Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/data/stored-and-compressed-text.zip"); | ||
let file = fs::File::open(path)?; | ||
ZipArchive::new(file) | ||
} | ||
|
||
fn extract_basic(bench: &mut Bencher) { | ||
let mut readable_archive = get_test_archive().unwrap(); | ||
let total_size: u64 = readable_archive | ||
.decompressed_size() | ||
.unwrap() | ||
.try_into() | ||
.unwrap(); | ||
|
||
let parent = TempDir::new("zip-extract").unwrap(); | ||
|
||
bench.bytes = total_size; | ||
bench.bench_n(1, |bench| { | ||
bench.iter(move || { | ||
let outdir = TempDir::new_in(parent.path(), "bench-subdir") | ||
.unwrap() | ||
.into_path(); | ||
readable_archive.extract(outdir).unwrap(); | ||
}); | ||
}); | ||
} | ||
|
||
#[cfg(all(feature = "parallelism", feature = "bzip2", unix))] | ||
const DECOMPRESSION_THREADS: usize = 8; | ||
|
||
#[cfg(all(feature = "parallelism", feature = "bzip2", unix))] | ||
fn extract_split(bench: &mut Bencher) { | ||
let readable_archive = get_test_archive().unwrap(); | ||
let total_size: u64 = readable_archive | ||
.decompressed_size() | ||
.unwrap() | ||
.try_into() | ||
.unwrap(); | ||
|
||
let params = ExtractionParameters { | ||
decompression_threads: DECOMPRESSION_THREADS, | ||
..Default::default() | ||
}; | ||
|
||
let parent = TempDir::new("zip-extract").unwrap(); | ||
|
||
bench.bytes = total_size; | ||
bench.bench_n(1, |bench| { | ||
bench.iter(move || { | ||
let outdir = TempDir::new_in(parent.path(), "bench-subdir") | ||
.unwrap() | ||
.into_path(); | ||
split_extract(&readable_archive, &outdir, params.clone()).unwrap(); | ||
}); | ||
}); | ||
} | ||
|
||
#[cfg(not(all(feature = "parallelism", feature = "bzip2", unix)))] | ||
benchmark_group!(benches, extract_basic); | ||
|
||
#[cfg(all(feature = "parallelism", feature = "bzip2", unix))] | ||
benchmark_group!(benches, extract_basic, extract_split); | ||
|
||
benchmark_main!(benches); |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use https://docs.rs/num_cpus/latest/num_cpus/ instead of a hard-coded number. Also make sure the archive used for this benchmark contains at least 768 files (4 per VCPU on the EC2
*.48xlarge
instances) so that scalable parallelism is properly measured.