Skip to content
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

Speed up the slow matching of static routes #11

Open
nestarz opened this issue Nov 14, 2023 · 0 comments
Open

Speed up the slow matching of static routes #11

nestarz opened this issue Nov 14, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@nestarz
Copy link

nestarz commented Nov 14, 2023

I came across this PR from Deno's fresh framework that might be beneficial to Rutt.

The PR is a fix to speed up the slow matching of static routes where previously, each static file route had its own URLPattern instance. This approach was slow and did not allow for an exact match.

What the PR proposes is to extend the route pattern to either be URLPattern or string. If the route pattern is a string, they treat it as an exact match, the URL is parsed, and a regex match is avoided. This is only applicable for internally created patterns; user-supplied patterns will still be parsed into URLPattern like before.

The author has reported significant improvements with this fix, reducing route-matching time from 62ms down to 0.7ms in real-world testing.

I think it could be an interesting enhancement for the routing in Rutt as well. It may be worth considering whether similar improvements can be implemented.

@nestarz nestarz changed the title Consider Incorporating PR to Speed Up Matching Static Routes Speed up the slow matching of static routes Nov 14, 2023
@eliassjogreen eliassjogreen added the enhancement New feature or request label Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants