-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Poor URLPattern performance #19861
Comments
Thanks for flagging it Kit, we actually discussed it last week. We'll look into optimizing it. |
Quick profile from V8 shows that
|
Yeah, I noticed both |
Was looking at a couple of server boot Fresh traces and |
@littledivy is actively looking into improving performance of |
For completeness: The pattern to regex parser I used can be found here https://github.com/denoland/fresh/compare/url-matcher#diff-7d5020e43e696993c4dee3edff778d85149f8165379a8a480824b53dfff7bbdeR1133-R1210 . Mostly used it as a starting point to see how much of a difference there is between a regex and |
On top of raw performance timing, after profiling some isolates in production we suspect that this is also causing a lot of memory pressure.
|
Still an issue. While
|
I'm using URL Pattern here and great performance would be much appreciated. |
@kitsonk For a fairer comparison, we might want to restrict // benchmarks.test.ts
const urlPattern = new URLPattern({ pathname: "/" }); This gave ~1.6x better results, making Does the difference become insignificant for more complex path patterns?// benchmarks.test.ts
const pattern =
"/foo{/:date(\d{4}-\d{2}-\d{2})}?/bar{/:manydates(\d{4}-\d{2}-\d{2})}+";
const urlPattern = new URLPattern({ pathname: pattern });
const pathname = "/foo/2024-08-30/bar/2024-08-30/2024-08-30";
const url = "http://localhost" + pathname; In this scenario To what extent is its speed justified?We can note that
❓ Is Should framework routers actually rely on
|
I was looking at the performance of my oak router versus my acorn router. Oak uses pathToRegex while acorn uses
URLPattern
. The implementation ofURLPattern
in Deno is super non-performant compared to pathToRegex and is making any routers that leverageURLPattern
quite noticeably non-performant against other solutions.By my calculations,
URLPattern
is ~150x slower than pathToRegex when testing/executing.To reproduce:
benchmarks.test.ts
And then:
The text was updated successfully, but these errors were encountered: