Repository navigation
perf: reuse indexed tar members for file reads - #2520
Open
apex-mochen wants to merge 1 commit into
Open
apex-mochen wants to merge 1 commit into
apex-mochen wants to merge 1 commit into
Conversation
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.
TarFileSystemfinds members in its index, then passes the original name totarfile.extractfile(). The standard library resolves that name by scanning the member list backwards. On a scan of many small shards, this repeats work for every file and can make the name lookup quadratic.Keep the already parsed
TarInfoin the index in place of the unused data offset. Pass it toextractfile()when its name matches the previous lookup key. This still usestarfilefor extraction and link resolution. For unusual regular members with a trailing slash, preserve the previous string lookup, which strips that slash before resolving the name. Exact and normalized duplicate names retain last-entry behavior.End-to-end measurement
Each timed run opens a local archive, discovers JSONL shards with
fs.glob(), reads every matched shard throughfs.cat_file(), and closes the archive. The fixtures store one synthetic record of roughly 450 bytes per member. Archive creation and output hashing are outside the timer. Windows, i9-14900HX, Python 3.12.14, basebaeaac93e2688cd7bb67b35b75df6d335a42a62b, warmed OS cache, median of five measured runs after warm-up, alternating order.The 8,192-member full scans improved by about 81% in both formats. Paths, order and payload bytes matched across all runs. The single-partition case includes reading the entire catalog on each open. These are ordered local reads of small members. Large payloads and random seeks in compressed archives can spend a larger share of time in I/O and decompression.
Validation
TAR and shared archive suites reported 215 passed and 28 skipped. Coverage includes direct and cached reads, compression, links, path normalization, duplicate members, missing members, and negative offsets. Added cases for repeated raw names and the trailing-slash fallback. Ruff check, Ruff formatting and
git diff --checkpassed.Reproduce the end-to-end measurements
Run from the candidate checkout with fsspec importable.