-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use a set for TargetPython.get_tags for performance #12204
Merged
Merged
Commits on Aug 4, 2023
-
Use a set for TargetPython.get_tags
This speeds up a representative pip-compile by about 40% ``` λ hyperfine -w 1 -M 3 -p 'rm req.txt || true' 'python -m piptools compile req.in --output-file req.txt --strip-extras --resolver=backtracking' Benchmark 1: python -m piptools compile req.in --output-file req.txt --strip-extras --resolver=backtracking Time (mean ± σ): 28.552 s ± 2.552 s [User: 20.477 s, System: 1.547 s] Range (min … max): 26.446 s … 31.390 s 3 runs λ hyperfine -w 1 -M 3 -p 'rm req.txt || true' 'python -m piptools compile req.in --output-file req.txt --strip-extras --resolver=backtracking' Benchmark 1: python -m piptools compile req.in --output-file req.txt --strip-extras --resolver=backtracking Time (mean ± σ): 17.570 s ± 0.450 s [User: 11.537 s, System: 1.345 s] Range (min … max): 17.095 s … 17.989 s 3 runs ``` This makes the set.isdisjoint operation done over here much cheaper: https://github.com/pypa/pip/blob/593b85f4a/src/pip/_internal/models/wheel.py#L92 The reason for this is because a Python usually has a lot of supported tags. The Python I used above has 2000 supported tags! Whereas a wheel usually only has one or two file tags. The CPython code will unfortunately iterate over all 2000 tags to check if there's a match. Only if the other collection is a set will CPython think to swap the operands to iterate over the shorter collection: https://github.com/python/cpython/blob/35963da40f/Objects/setobject.c#L1352
Configuration menu - View commit details
-
Copy full SHA for 91c4fc4 - Browse repository at this point
Copy the full SHA 91c4fc4View commit details -
Configuration menu - View commit details
-
Copy full SHA for bcde032 - Browse repository at this point
Copy the full SHA bcde032View commit details -
Configuration menu - View commit details
-
Copy full SHA for 47f21a7 - Browse repository at this point
Copy the full SHA 47f21a7View commit details -
Configuration menu - View commit details
-
Copy full SHA for c17ff03 - Browse repository at this point
Copy the full SHA c17ff03View commit details -
Configuration menu - View commit details
-
Copy full SHA for 53f9ce7 - Browse repository at this point
Copy the full SHA 53f9ce7View commit details -
Configuration menu - View commit details
-
Copy full SHA for a0c804f - Browse repository at this point
Copy the full SHA a0c804fView commit details -
Configuration menu - View commit details
-
Copy full SHA for ba7863d - Browse repository at this point
Copy the full SHA ba7863dView commit details -
Configuration menu - View commit details
-
Copy full SHA for f8fbbb1 - Browse repository at this point
Copy the full SHA f8fbbb1View commit details -
Configuration menu - View commit details
-
Copy full SHA for 18926cb - Browse repository at this point
Copy the full SHA 18926cbView commit details -
Configuration menu - View commit details
-
Copy full SHA for dfdf4ec - Browse repository at this point
Copy the full SHA dfdf4ecView commit details
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.