-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Optimise path decoding in RoutingUtils #47395
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
Conversation
ia3andy
commented
Apr 16, 2025
•
edited by geoand
Loading
edited by geoand
- Closes: Performance regression while resolving path #47384
@franz1981 I'll try to submit a follow up PR fixing it even when there is % in the path.. |
extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/RoutingUtils.java
Show resolved
Hide resolved
In theory URLDecoder can do the same here (slow path) - but what looks like a waste to me is that Vertx already spent cycles doing something here which can be replaced by a single method that does it at once. |
@franz1981 all the vertx tooling for this is not exposed as public API |
Julien is on PTO, let's wait him to come back |
I think it's a bit more complicated than checking for '%' as we also need the remove dots '../' and replace '' with '/'. Let's hold a bit |
This is what's in the internal API that we would need: |
Same here, I would expect Vert.x to do this for us, I'm surprised we have to handle this manually. |
I don't think we can avoid the dots removal :-/ @franz1981 when this PR is green could you run the perf check again? It will probably be less effective than before the breaking commit but still better than using URI all the time.. |
In any case I am on PTO, right now, so cannot perform tests. My suggestion is to use the JMH module we have in quarkus and write a bench..and I can help review it 🙏 |
13b267f
to
b211f3d
Compare
Ok, we are good! There is no need to remove the dots are it's already done by vertx in the Now in This should fix the issue. |
This comment has been minimized.
This comment has been minimized.
@vietj @tsegismont https://github.com/vert-x3/vertx-web/blob/master/vertx-web/src/main/java/io/vertx/ext/web/handler/impl/StaticHandlerImpl.java#L174 It seems doing the remove dots there is not needed here as it's already done as explained in my previous comment. |
Status for workflow
|
Status | Name | Step | Failures | Logs | Raw logs | Build scan |
---|---|---|---|---|---|---|
✔️ | JVM Integration Tests - JDK 17 | Logs | Raw logs | 🔍 | ||
✔️ | JVM Integration Tests - JDK 17 Windows | Logs | Raw logs | 🔍 | ||
✖ | JVM Integration Tests - JDK 21 | Build |
Failures | Logs | Raw logs | 🔍 |
Full information is available in the Build summary check run.
You can consult the Develocity build scans.
Failures
⚙️ JVM Integration Tests - JDK 21 #
- Failing: integration-tests/observability-lgtm
📦 integration-tests/observability-lgtm
✖ io.quarkus.observability.test.LgtmReloadTest.testReload
- History - More details - Source on GitHub
java.lang.IllegalStateException:
Bad response: 404 >> 404 page not found
at io.quarkus.observability.test.utils.GrafanaClient.handle(GrafanaClient.java:51)
at io.quarkus.observability.test.utils.GrafanaClient.user(GrafanaClient.java:81)
at org.awaitility.core.AbstractHamcrestCondition.lambda$new$0(AbstractHamcrestCondition.java:48)
at org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:248)
at org.awaitility.core.ConditionAwaiter$ConditionPoller.call(ConditionAwaiter.java:235)
Flaky tests - Develocity
⚙️ JVM Tests - JDK 21
📦 extensions/smallrye-reactive-messaging/deployment
✖ io.quarkus.smallrye.reactivemessaging.hotreload.ConnectorChangeTest.testUpdatingConnector
- History
Expecting actual: ["-4","-5","-6","-7","-8","-9","-10","-11"] to start with: ["-3", "-4", "-5", "-6"]
-java.lang.AssertionError
java.lang.AssertionError:
Expecting actual:
["-4","-5","-6","-7","-8","-9","-10","-11"]
to start with:
["-3", "-4", "-5", "-6"]
at io.quarkus.smallrye.reactivemessaging.hotreload.ConnectorChangeTest.testUpdatingConnector(ConnectorChangeTest.java:36)
@franz1981 this should be safe to merge, can you approve? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not saying we shouldn't merge this as a quick fix but I'm still wondering why we have to handle things ourselves.
My understanding is that the issue is only with GeneratedStaticResourceBuildItem
so I'm wondering if we should somehow alter the registered endpoint for these and escape it when we register it, rather than doing things at runtime when the request arrives.
My understanding is that we should be able to deal with this once and for all when we register the resource and then have a standard handling as if the files were on disk.
I suppose I might be missing something so happy to have an explanation :).
FWIW, I have been looking at both 7899c9d and the original issue and I'm not clear on what the original patch was exactly supposed to fix. Sorry for asking dumb questions but I would appreciate if we could take a step back and clarify things for posterity. |
@gsmet the test in the original fix should explain the purpose. |
Here was the original issue: #45775 |
Also the issue is not for GeneratedStaticResourceBuildItem but for all static resources. |
This is how the vertx static handler works. @cescoffier or @tsegismont might have answer to this question. |
Here is where we need this: https://github.com/quarkusio/quarkus/blob/main/extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/StaticResourcesRecorder.java#L98-L107 Also we are using this method from RoutingUtils from other extensions which rely on path to get resources (Qute Web for example) |
I got the feeling that similarly to how we scan the endpoints to decide how to configure the right handlers for the types required (see Line 144 in 0061772
we should be able there to check if the endpoint path matches the one which should contains static resources and save any check to happen since they won't deliver anything, but I don't remember by heart |
While I agree we could investigate ways to have vertx deal with this logic in the first place, until then we should apply this fix and backport it as it solves a perf issue which affect all requests (including rest). The fix is pretty safe: |
Thanks @ia3andy for the heads-up |
The dot segments are already taken care of by the call to context.normalizedPath(). See quarkusio/quarkus#47395 (comment) Signed-off-by: Thomas Segismont <[email protected]>
The dot segments are already taken care of by the call to context.normalizedPath(). See quarkusio/quarkus#47395 (comment) Signed-off-by: Thomas Segismont <[email protected]>
@ia3andy in fact, it is required because |
Having to remove dots twice feels quite wrong. Maybe we should consider adding an exception to the RFC decode step to also handle |
Or maybe we should remove support for windows path, because URI paths |
I believe it happens in two steps because a route handler (other than a static file server) can be interested in having a normalized path without fully decoding uri. |