Skip to content

v1.1.0

Choose a tag to compare

@dunglas dunglas released this 30 Nov 13:29
· 1 commit to main since this release
v1.1.0
e8c381f

This release adds Options.RejectRegexpGroups to reject patterns with regexp groups at parse time for specs like RFC 9842 and Service Worker static routing, and makes Test, Exec, and New faster with fewer allocations.

✨ New Features

  • Add Options.RejectRegexpGroups and ErrRegexpGroup to refuse patterns with regexp groups at parse time without compiling them (while still accepting (.*) and segment wildcard groups), as required by RFC 9842 and Service Worker static routing, by @dunglas in #22 (merged in #21)

⚡ Performance Improvements

  • Skip capture tracking and result building in Test and TestInit, stop at the first non-matching component, and bypass regexp execution for full-wildcard components by @dunglas in #21
  • Stop Exec at the first non-matching component, defer building group maps until all components match, and pre-size input slices by @dunglas in #21
  • Reduce New allocations by 13% to 20% by returning pointers into the parser token list, reusing shared regexps for literal special schemes, and copying group names so compiled patterns do not retain the full input string by @dunglas in #21

Compared with v1.0.0, Test runs 4 to 5x faster with 87% fewer allocations, and New runs 2x faster with half the allocations. Combined with batched writes, Mercure 1.1.7 uses 2.5x less CPU than 1.1.6 to serve 200 URL Patterns.

v1.0.0, v1.0.1 and v1.1.0 compared on an Apple M5 Pro, medians of 10 runs:

Benchmark v1.0.0 v1.0.1 v1.1.0
New, simple pattern 12.6 µs, 539 allocs 10 µs, 460 allocs 6.7 µs, 262 allocs
Test, named groups 1.8 µs, 63 allocs 0.80 µs, 21 allocs 0.45 µs, 8 allocs
Test, regexp group 1.6 µs, 52 allocs 0.70 µs, 19 allocs 0.39 µs, 7 allocs
Test, no match 1.1 µs, 38 allocs 0.46 µs, 13 allocs 0.22 µs, 5 allocs
Exec, named groups 1.8 µs, 63 allocs 0.77 µs, 21 allocs 0.71 µs, 21 allocs

🙏 Sponsor the Maintainers

Keeping go-urlpattern fast, spec-compliant, and up to date with integrating web standards takes ongoing work. Thanks to the existing sponsors for making it possible. If you or your company rely on go-urlpattern, please consider sponsoring its maintainers:

Full Changelog: v1.0.1...v1.1.0