Repository navigation
Conversation
Each pax global header merged its records into the accumulated map with array_merge($this->paxGlobal, $records), rebuilding the whole map every time. For an archive with many global headers this is quadratic in their number, so a small compressed tar can cost minutes of CPU while listing or extracting it. An empty global header triggers the full copy as well. Assign the records in place instead, which is linear in the number of records a header carries. Likewise, when applying the global defaults to an entry, look up only the few keywords that are actually used instead of merging the whole global map into every entry. The behaviour is unchanged: global records still apply to the entries that follow, entry specific records still win, and empty records still suppress a global value. A regression test builds an archive with many global headers and asserts it is processed well within a linear time budget. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This branch has not been deployed
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.
parseHeader()merged each pax global header into the accumulated map witharray_merge($this->paxGlobal, $records), rebuilding the whole map per header — quadratic in the number of global headers, so a ~680 KB gzipped tar costs ~12 s of CPU when listed or extracted (and grows with the square of the count). An empty global header triggers the full copy as well.This assigns the records in place instead, and when applying the global defaults to an entry looks up only the keywords
applyPaxRecords()uses rather than merging the whole global map into every entry. Behaviour is unchanged: global records still apply to following entries, entry-specific records still win, and empty records still suppress a global value (verified with a byte-for-byte output diff over global-apply / entry-override / empty-delete / multi-global fixtures). On the payload above this drops from ~12 s to ~0.6 s and scales linearly.Adds
testPaxGlobalHeaderIsLinear(), which builds an archive with many global headers and asserts it is processed within a linear time budget.Fixes #42
🤖 Generated with Claude Code