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

Large responses written slowly due to allocating too small buffers #1106

Merged
merged 1 commit into from
Nov 16, 2023

Conversation

ppalaga
Copy link
Contributor

@ppalaga ppalaga commented Nov 13, 2023

fix #1066

@ppalaga
Copy link
Contributor Author

ppalaga commented Nov 13, 2023

@franz1981 @geoand I tried to implement your suggestions here: I have taken the latest ResteasyReactiveOutputStream from Quarkus and adapted it to work here as VertxServletOutputStream. I did very similar edits like @dufoli who ported it originally.

Porting the part with LazyResponse was not easy so I have omitted it for now. Is this perhaps what you meant with "jackson approach mentioned earlier"?

I did some benchmarks and the performance on my machine is great:

  • Before 7954 ms
  • After 838 ms

@ppalaga
Copy link
Contributor Author

ppalaga commented Nov 14, 2023

Added comments explaining from where the two new classes originate.

Copy link

@franz1981 franz1981 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, my only suggestion is related the tests; to avoid being captured by another regression, in the future, adding a test which ensure we are same or better than the expected number of packets, for a large write, would be great

@ppalaga
Copy link
Contributor Author

ppalaga commented Nov 16, 2023

9714f01: added the test ensuring that there is an expected number of chunks.

@ppalaga
Copy link
Contributor Author

ppalaga commented Nov 16, 2023

The way how I implemented the counting of chunks in ChunkedTest through overriding HTTP Client classes is all but elegant. Anybody knows of a nicer approach?

@ppalaga
Copy link
Contributor Author

ppalaga commented Nov 16, 2023

6da774a: made the CodeQL happy.

@franz1981
Copy link

franz1981 commented Nov 16, 2023

These tests are never easy to be implemented...
So, you can do in different ways, actually:

  • how you've done
  • using an existing proxy which can count the http chunks coming from the server
  • mocking some class on the server and verify how http data is sent through it
  • using Netty's Embeddable Channel and intercept how vertx send buffers to it

As you can see there are no elegant one, just some could make uses of existing bits to shorten the amount of code and appear better, because the ugliness is well confined elsewhere :P

@ppalaga
Copy link
Contributor Author

ppalaga commented Nov 16, 2023

Thanks for the suggestions, @franz1981! I think it would be better to avoid changing anything on the server so that we do not influence other tests (which are also run in native mode) in this module. I am not finding any usable proxy implementation.

Thus, I am going to merge like this.

@ppalaga ppalaga merged commit 2c0ff7e into quarkiverse:main Nov 16, 2023
17 checks passed
@ppalaga
Copy link
Contributor Author

ppalaga commented Nov 16, 2023

Open Questions:

  1. You mentioned somewhere that it would be good to make the org.jboss.resteasy.reactive.server.vertx.AppendBuffer public, right? However, depending on resteasy-reactive-vertx here in Quarkus CXF would not be great. Can you perhaps see some module, from where we could re-use it both here and in resteasy-reactive-vertx? Somewhere in Vert.x maybe?
  2. What's your opinion on creating a common parent for io.quarkiverse.cxf.transport.VertxServletOutputStream and org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveOutputStream? IMO it would be great to have it so that Quarkus CXF does not miss any future fixes.

@franz1981
Copy link

Let me route these to @geoand which have a much better knowledge of quarkus's module deps, and I can help doing it

@geoand
Copy link

geoand commented Nov 16, 2023

Can you perhaps see some module, from where we could re-use it both here and in resteasy-reactive-vertx ?

Very unlikely

What's your opinion on creating a common parent for io.quarkiverse.cxf.transport.VertxServletOutputStream and org.jboss.resteasy.reactive.server.vertx.ResteasyReactiveOutputStream ?

I really don't want such kind of coupling

@ppalaga
Copy link
Contributor Author

ppalaga commented Nov 17, 2023

Fair enough, thanks for the clear statement, @geoand

@geoand
Copy link

geoand commented Nov 17, 2023

🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Large responses written slowly due to allocating too small buffers
3 participants