Skip to content

Optimize route matching hot path - #57

Merged
josiahking merged 1 commit into
2.xfrom
perf/routing-hot-path
Aug 31, 2026
Merged

Optimize route matching hot path#57
josiahking merged 1 commit into
2.xfrom
perf/routing-hot-path

Conversation

@josiahking

Copy link
Copy Markdown
Owner

Summary

  • use exact path comparison for static route patterns
  • parse parameterized request paths once per matcher operation and reuse the prepared segments
  • preserve route insertion-order precedence and existing method/path semantics
  • move HTTP benchmark fixture construction outside the timed request path
  • add benchmark and routing regression coverage for the optimized behavior

Performance

Same-environment local benchmark measurements with the corrected HTTP timing boundary showed:

  • static request: 21.224 µs → 16.324 µs (23.09% faster)
  • parameterized request: 21.260 µs → 18.290 µs (13.97% faster)
  • middleware-heavy request: 32.816 µs → 27.874 µs (15.06% faster)
  • 404 path: 33.336 µs → 18.860 µs (43.42% faster)
  • 405 path: 35.274 µs → 20.938 µs (40.64% faster)
  • repeated warm static request: 21.226 µs → 16.418 µs (22.65% faster)

These are local development measurements from the same environment and are not intended as cross-environment performance guarantees.

Validation

  • benchmark tests: 17 tests / 77 assertions
  • root test suite: 679 tests / 2456 assertions / 1 skipped
  • architecture and documentation tests: 210 tests / 9583 assertions
  • benchmark syntax and smoke checks passed
  • skeleton create-project validation passed
  • release package validation passed
  • prerelease consumer validation passed
  • supply-chain validation passed
  • deterministic package split validation passed for all seven packages

Routing insertion-order precedence, parameter capture, method matching, path case, trailing-slash behavior, and 404/405 behavior remain unchanged.

@josiahking josiahking self-assigned this Aug 31, 2026
@josiahking
josiahking merged commit 9a0e741 into 2.x Aug 31, 2026
3 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.

1 participant