perf(index): filter find-links entries before url conversion - #14123
Open
KRRT7 wants to merge 1 commit into
Open
perf(index): filter find-links entries before url conversion#14123KRRT7 wants to merge 1 commit into
KRRT7 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.
Summary
--find-linksdirectory entries by filename before converting them to file URLsPerformance Model
mimetypes.guess_type()on unrelated filesProfile before the change confirmed the cost: in 20 scans of a directory with 5,000 unrelated files, 50 wheels, and 10 HTML pages,
_scan_directory()spent about 1.98s inpath_to_url()and about 1.01s in HTML MIME checks.Benchmark
Apple M3, 24 GiB RAM, CPython 3.14.5
Target workload:
_FlatDirectoryToUrls.project_name_to_urlsscanning a local--find-linksdirectory with:.txtfiles with spaces/symbols in their namesdemo_pkgwheel filenamesExpected output is unchanged: 50 URLs under
demo-pkgand 10 page candidate URLs.6b0011b49(base)9f8243c09(head)Reproduce the benchmark locally
Changelog
Added
news/d54d50c4-da3a-402b-886d-e6cecc11237a.bugfix.rst.Stack
perf/find-links-scan-filtermainExisting open performance PRs were checked and are independent of this change: #14122, #14108, #14106, #14088, #14103, #14045, #14026, and #13860.
Test plan
cProfileuv run ruff check src/pip/_internal/index/sources.py tests/unit/test_collector.pyuv run pytest tests/unit/test_collector.py -q