feat(http/unstable): add radix tree router; keep linear scan as routeLinear#7075
Open
esroyo wants to merge 1 commit intodenoland:mainfrom
Open
feat(http/unstable): add radix tree router; keep linear scan as routeLinear#7075esroyo wants to merge 1 commit intodenoland:mainfrom
esroyo wants to merge 1 commit intodenoland:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7075 +/- ##
==========================================
- Coverage 94.41% 94.40% -0.01%
==========================================
Files 630 630
Lines 50490 50617 +127
Branches 8949 8988 +39
==========================================
+ Hits 47669 47786 +117
- Misses 2249 2255 +6
- Partials 572 576 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…Linear Add routeRadix(), a radix tree router that provides O(segments) dispatch for static, parametric, and wildcard routes. Routes with complex URLPattern syntax (regex constraints, optional groups, inline wildcards, modifier suffixes) fall back to linear matching while preserving insertion order. - routeRadix: radix tree with fallback to linear for complex patterns - routeLinear: the original linear scan, extracted as its own export - route: re-exported alias for routeRadix (backward compatible) The radix router matches routeLinear semantics exactly — insertion order is always respected, even when static and parametric routes overlap at the same tree depth. Benchmarks show 1.5–9x improvement on static/parametric/wildcard routes, with negligible overhead on complex fallback patterns.
786873d to
d522ffa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add
routeRadix(), a radix tree router that provides O(segments) dispatch for static, parametric, and wildcard routes. Routes with complex URLPattern syntax (regex constraints, optional groups, inline wildcards, modifier suffixes) fall back to linear matching while preserving insertion order.routeRadix: radix tree with fallback to linear for complex patternsrouteLinear: the original linear scan, extracted as its own exportroute: re-exported alias forrouteRadix(backward compatible)The radix router matches routeLinear semantics exactly; insertion order is always respected, even when static and parametric routes overlap at the same tree depth.
Benchmarks show 1.5–9x improvement on static/parametric/wildcard routes, with negligible overhead on complex fallback patterns.
--- config: themeVariables: xyChart: plotColorPalette: "#e05c5c, #4a90d9" --- xychart-beta title "route: 🔴 linear vs 🔵 radix - Avg latency (µs)" x-axis [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] y-axis "Avg latency (µs)" 0 --> 7 line [0.91, 2.04, 6.1, 1.63, 5.54, 1.49, 2.84, 1.08, 3.15, 0.9, 1.45, 1.98] line [1.08, 1.38, 1.39, 0.62, 0.61, 1.55, 1.66, 0.91, 1.73, 1.46, 1.62, 2.1]