Closed cosmicexplorer closed 5 months ago
To compare, applying this commit (https://github.com/cosmicexplorer/zip/commit/d6d90f2a0129bc7306063a3290743afdef81dff2) to this PR avoids adding the new cde_start
field to Shared
, but it slightly reduces performance as per the benchmark:
> cargo bench merge_archive
# ...
running 4 tests
test merge_archive_compressed ... bench: 21,840 ns/iter (+/- 554) = 5169 MB/s
test merge_archive_raw_copy_file_compressed ... bench: 70,272 ns/iter (+/- 6,201) = 1606 MB/s
test merge_archive_raw_copy_file_stored ... bench: 67,223 ns/iter (+/- 3,922) = 1672 MB/s
test merge_archive_stored ... bench: 22,350 ns/iter (+/- 1,287) = 5029 MB/s
Replaced with https://github.com/zip-rs/zip2/pull/61.
In my project
medusa-zip
, I extend this library to support aZipWriter::merge_archive()
operation, which essentially performs the equivalent of.raw_copy_file()
from every entry in a sourceZipArchive
, but much more efficiently; in the new benchmark, it's around 3x as fast:This seems like a reasonable extension of the existing
raw_copy_file()
API. WithZipWriter::finish_into_readable()
from #400, this change enables use cases likemedusa-zip
, which creates zip files very efficiently by splitting their contents, creating intermediate zips, then merging them all into one. See e.g. https://github.com/cosmicexplorer/medusa-zip/blob/3197d740b3cd1a49aeced0d7cbfea57e5ca2f32e/lib/src/zip.rs#L736-L744: