Skip to content

perf(registry): early exit matches_partial#1441

Merged
Nytelife26 merged 2 commits intomainfrom
perf/early-exit-partials
Oct 3, 2025
Merged

perf(registry): early exit matches_partial#1441
Nytelife26 merged 2 commits intomainfrom
perf/early-exit-partials

Conversation

@Nytelife26
Copy link
Copy Markdown
Contributor

@Nytelife26 Nytelife26 commented Oct 2, 2025

Relevant issues

Intended to help with #1440.

Brief

Improve performance of check.matches_partial by 85% in the case of a full match using a fast equality, and 66% in all other cases by using startswith.

Acknowledgements

Credit to @drainpixie for noticing the equivalence of these operations.

@Nytelife26 Nytelife26 requested a review from suchow as a code owner October 2, 2025 23:48
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.15%. Comparing base (7bfb8f1) to head (4a06fb5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1441      +/-   ##
==========================================
- Coverage   94.28%   94.15%   -0.14%     
==========================================
  Files          99       99              
  Lines         805      804       -1     
==========================================
- Hits          759      757       -2     
- Misses         46       47       +1     
Flag Coverage Δ
macos-latest 93.40% <100.00%> (-0.14%) ⬇️
py3.10 94.15% <100.00%> (-0.14%) ⬇️
py3.11 94.15% <100.00%> (-0.14%) ⬇️
py3.12 94.15% <100.00%> (-0.14%) ⬇️
py3.13 93.40% <100.00%> (-0.14%) ⬇️
py3.14 93.40% <100.00%> (-0.14%) ⬇️
ubuntu-latest 93.40% <100.00%> (-0.14%) ⬇️
windows-latest 94.15% <100.00%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

As @drainpixie noticed in #1440, checking segment sequences is
equivalent to asking if the raw path starts with the partial key
followed by the delimiter. This greatly improves the performance of
matches_partial in the fallback case (3x on my system).

Co-authored-by: drainpixie <121581793+drainpixie@users.noreply.github.com>
@Nytelife26
Copy link
Copy Markdown
Contributor Author

Nytelife26 commented Oct 3, 2025

This is ready for review @drainpixie (should be the easiest approve in our lifetimes)

@drainpixie
Copy link
Copy Markdown
Collaborator

:D

@Nytelife26 Nytelife26 merged commit 9fa6339 into main Oct 3, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants