-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Native support for http method matching #58
Comments
https://github.com/aquapi/wint Basically Radix3 is slower than Normally what you do to make routing fast is that you separate static routes and route patterns like URL parameters and wildcards. For static path just use an object literal and for the dynamic path you can use My approach is a bit different since I took the tree structure that Radix3 basically slices the URL into parts when matching URLs, and not all of the time all of the parts are needed to be checked because the previous parts do not match. Also my router does support method matching but it is designed a bit different to reduce creating objects as much as possible. But if you want to stick with Radix3 you can make an object literal with key is the method name and the value is the radix tree you want to match the URL. |
Hi, dear @aquapi thanks for sharing your feedback and nice work on wint! As a quick context, honestly I never put extra efforts into fine-tuning radix3 perf to compete with other routes (there were not many by the time too!) it was based on another work and really fast enough ( Saying all this, i am not against pushing performance even more on radix3 too and i guess there are improvements.
Thanks for this insight. I will certainly check in the benchmarks for cost of adding a new tree per method vs method as last segment matcher.
Can you please elaborate more what do you mean by other URL parameters? Also have you made a benchmark suite by any chance? (would be happy to make one in radix3 ++ having you as collaborator here always!) |
@pi0 I will create a benchmark repo soon for |
@pi0 https://github.com/aquapi/routers Seems like Radix3 is faster for path that has a lot of parameters because I can make a compiler for this matching strategy. |
Rebenchmark the whole thing again and Wint was faster in all tests.
|
Native route matching added in #107 |
Context: unjs/h3#461
I had been trying to implement a generic
filter
option for lookup but it adds too much overhead. If tree structure has a build-in method checker support, it could be much faster.Acceptance criteria:
lookup
method to support an additional method optionlookup(path, { method? }?
addRoute
to support an additional options object to set method criteriamethod => Map<string, string>
structure. other ideas welcome but it should beO(n + 1)
maximum where asn
is number of available methods and not affect performance when no method is specifiedThe text was updated successfully, but these errors were encountered: