Skip to content

Optimize version comparison hot paths - #30

Merged
andrew merged 2 commits into
mainfrom
optimize-hot-paths
Aug 14, 2026
Merged

Optimize version comparison hot paths#30
andrew merged 2 commits into
mainfrom
optimize-hot-paths

Conversation

@andrew

@andrew andrew commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Replace regexp- and split-based SemVer, RubyGems, and NuGet comparison with allocation-free scanners. Avoid redundant interval comparisons and regexp parsing for VERS URIs and constraints.

Add benchmarks for scheme comparison, parsing, validation, and highest-satisfying selection, plus randomized parity coverage for scanner behavior.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Optimizes version parsing and comparison hot paths by replacing regex/split-based logic with allocation-free scanners across SemVer, RubyGems, and NuGet, and adds parity tests/benchmarks to validate the new scanners.

Changes:

  • Replaced SemVer matching/comparison and NuGet prerelease/numeric parsing with scanner-based, low-allocation implementations.
  • Replaced VERS URI and constraint operator regex parsing with prefix/index scans.
  • Added property-based parity tests and additional benchmarks; tightened interval containment edge coverage.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
version.go Switches SemVer detection/parsing in ParseVersion and SemVer fast path in CompareVersions to scanner-based parsing.
schemes.go Implements allocation-free SemVer scanner/prerelease comparison and RubyGems segment scanning (replacing regex/split).
schemes_test.go Adds randomized parity tests ensuring scanner behavior matches the legacy regex/regexp behavior; adds NuGet edge cases.
pypi.go Reuses qualifierPre constant in PEP 440 pre-tag mapping.
parser.go Replaces vers: URI regex parsing with prefix + slash scan and adds newline guard for constraints.
parser_test.go Adds test coverage for missing separator and newline-in-constraints VERS URI cases.
interval.go Removes redundant early returns in containsCmp and relies on bound checks for correctness.
interval_test.go Adds coverage for equal exclusive bounds containment behavior.
ecosystem_extra.go Uses qualifierPre constant for Gentoo suffix rank handling.
constraint.go Replaces operator regex with a small scanner (constraintOperator).
bench_test.go Adds benchmarks for scheme comparison, constraint parsing, cached parsing, validation, and highest-satisfying selection.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread schemes.go
@andrew
andrew merged commit 774995e into main Aug 14, 2026
5 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