perf: eliminate duplicate by_index() call in ZIP extraction#54
Merged
Conversation
Restructure ZipArchive::process_entry() from two by_index() calls per entry to one. The previous approach called by_index() once for metadata and again for extraction due to borrow checker constraints. The new approach uses a single by_index() call with three-way branching on entry type (directory/symlink/file), dropping the ZipFile borrow explicitly before validator calls in directory and symlink branches. Add ZipEntryAdapter::is_symlink_from_mode() to detect symlinks from Unix mode bits without needing a live ZipFile reference. Remove the now unused to_entry_type() and is_symlink() methods. Benchmarks show 3-7% improvement for many-file ZIP workloads: - file_count_scaling/5000: -7.1% (p < 0.05) - many_small_files/1000: -4.6% (p < 0.05) - file_extraction/zip_small: -11.8% (p < 0.05) No regressions in single-file or validation benchmarks. Closes #52
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (65.27%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. @@ Coverage Diff @@
## main #54 +/- ##
========================================
Coverage 90.30% 90.31%
========================================
Files 62 58 -4
Lines 10347 10191 -156
========================================
- Hits 9344 9204 -140
+ Misses 1003 987 -16
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 4 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
ZipArchive::process_entry()from twoby_index()calls per entry to oneby_index()with three-way branching on entry type (directory/symlink/file)ZipEntryAdapter::is_symlink_from_mode()for symlink detection from Unix mode bitsto_entry_type()andis_symlink()methodsBenchmark Results
Test plan
Closes #52