You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have just updated to echo 4.2.0 and have seen a relatively high performance regression with that release. With bisecting
it seems like commit 2d79ff3 has introduced a perfomance penalty of about 30-40%.
Just ran the benchmarks of tags v4.1.17 and v4.2.0 against each other and the impace is different here.
Seems like this is the reason why it was not detected (not sure if we had already setup benchstat at the time of merging though).
Result of runnung 10 times and compare using benchstat bench-v4.1.17.txt bench-v4.2.0.txt
AFAIK the benchmark tests in the echo repo only test the performance of the router itself by directly calling the find method on it, whereas the web-framework-benchmark benchmarks the whole echo stack.
Seems like the regression has been introduced between the other parts and the find call on the router and not in the router itself.
PR #1628 introduced r.URL.EscapedPath() which sanitizes the request URL on every request. The focus here was correctness for proxying.
So this PR needs to be revisited if this is required for every request or could be limited to proxying.
We can probably find a way to only escape if required (although internally EscapedPath() does that by scanning through the url and deciding if escaping is needed).
@lammel Isn't PR #1628 even a breaking change for route finding?
Assuming a user has registered the following route:
e.Any("/test whitespace/", myHandler)
If the user enters the URL localhost:1323/test%20whitespace/ in his browser, with echo 4.1.17 this route is found because .Path == "/test whitespace/". Whereas after having upgraded to 4.2.0 the route will be searched with /test%20whitespace/and the route is not found anymore.
You are probably right, es the paths added to the router would also need to use EscapedPath() when adding the path if we keep doing it that way. (adding routes is not relevant for performance)
I still think we should limit the implications of path escaping to appropriate places (e.g. proxy as the other PR originally stated).
Like restoring the previously used GetPath() helper function and identify the spots to use EscapedPath for proxying.
All headers where URLs are added (like Location for redirect) may also be affected.
Activity
lammel commentedon Feb 12, 2021
Just ran the benchmarks of tags v4.1.17 and v4.2.0 against each other and the impace is different here.
Seems like this is the reason why it was not detected (not sure if we had already setup benchstat at the time of merging though).
Result of runnung 10 times and compare using
benchstat bench-v4.1.17.txt bench-v4.2.0.txtWhen I do the same using web-framework-benchmark I get similar results as you showed before.
lammel commentedon Feb 12, 2021
Seems like I was the one doing a perf review of PR #1628 and also wrote that I did not see a performance regression..
stffabi commentedon Feb 15, 2021
AFAIK the benchmark tests in the echo repo only test the performance of the router itself by directly calling the find method on it, whereas the web-framework-benchmark benchmarks the whole echo stack.
Seems like the regression has been introduced between the other parts and the find call on the router and not in the router itself.
lammel commentedon Feb 15, 2021
PR #1628 introduced
r.URL.EscapedPath()which sanitizes the request URL on every request. The focus here was correctness for proxying.So this PR needs to be revisited if this is required for every request or could be limited to proxying.
We can probably find a way to only escape if required (although internally
EscapedPath()does that by scanning through the url and deciding if escaping is needed).stffabi commentedon Feb 15, 2021
@lammel Isn't PR #1628 even a breaking change for route finding?
Assuming a user has registered the following route:
If the user enters the URL
localhost:1323/test%20whitespace/in his browser, with echo4.1.17this route is found because.Path == "/test whitespace/". Whereas after having upgraded to4.2.0the route will be searched with/test%20whitespace/and the route is not found anymore.lammel commentedon Feb 15, 2021
You are probably right, es the paths added to the router would also need to use
EscapedPath()when adding the path if we keep doing it that way. (adding routes is not relevant for performance)I still think we should limit the implications of path escaping to appropriate places (e.g. proxy as the other PR originally stated).
Like restoring the previously used
GetPath()helper function and identify the spots to use EscapedPath for proxying.All headers where URLs are added (like Location for redirect) may also be affected.
Fix performance regression caused by path escaping (#1777, #1798, #1799)