-
Notifications
You must be signed in to change notification settings - Fork 895
[RESTEASY-3656] ResteasyJackson2Provider excessive byte[] copies #4701
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
[RESTEASY-3656] ResteasyJackson2Provider excessive byte[] copies #4701
Conversation
|
@jamezp FYI 🙏 |
62a9ebb to
83d79d2
Compare
|
I've run locally the jackson2 provider integration tests (w debugging), to verify the number of copies are reduced; it passes and looks good 👍 @jamezp |
|
The failures are not related. This is something I need to get fixed. |
|
@franz1981 Is this something we should do more generally for the In general looking at that, writing everything to memory before writing it to the async stream like it could be a potential issue for large objects. |
|
In Quarkus I have implemented a thing called AppendBuffer in the vertx output stream, for Restleasy Reactive, which:
In this way you both have batchy flush and some predictable memory usage. This specific Jackson writer here looks to be just in memory, I can tell; which as you said, could be dangerous under heavy load due to memory footprint: I've indeed found this improvement because due to the existing implementation, it was so memory hungry to appear in our profiling data in the performance lab |
83d79d2 to
64809e4
Compare
|
Awesome, thank you. I'd be tempted to put this also in |
|
Good point @jamezp yep, in theory should work similarly -although for a generic use case I would create a stream which append chunks of byte[] instead of reallocating (by copying and enlarging) the same byte[] over and over. |
|
Perfect. I may copy it over and look at the other chunking separately. Also, thank for you this. I really want to learn more about performance testing, but it seems like an art form that there either isn't a lot of information on or I'm not able to find it :) |
|
Reach out to me and my team and I can help with it @jamezp no worries :) |
https://issues.redhat.com/browse/RESTEASY-3656 Signed-off-by: James R. Perkins <jperkins@ibm.com>
b901034 to
65c9ce8
Compare
Jackson usually configure different form of buffer pooling (see https://github.com/FasterXML/jackson-core/blob/e19615bb99f6127230793e2c7766bbb3beaee6fc/src/main/java/com/fasterxml/jackson/core/io/IOContext.java#L63) and perform a single
write(byte[] b, int offset, int lengh)vs the provided output stream during serialization, using its internally pooled buffer.In short, this enable an async write to:
This is just an idea as the subsequent
AsyncOutputStream ::asyncWritecan "backfire" performing an additional copy, see 3408cf1see