Skip to content

Optimize single & batch query response writers to reduce memory allocation overhead #292

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

Merged

Conversation

artem-ag
Copy link
Contributor

Optimize single & batch query response writers to reduce memory allocation overhead caused by the servlet.

When large 10MiB+ responses are serialized, existing implementation performs significant amount of redundant string conversions and string concatenations. In my scenario overhead reached as much as 4GiB in extra RAM allocated.

This change replaces Json serialization into a String with Json serialization into byte array for both single and batch queries. In addition, it removes all string concatenations from batch response writer.

Copy link
Member

@oliemansm oliemansm left a comment

Choose a reason for hiding this comment

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

JDK8 based tests are failing, can you take a look at that? Maybe you're using something not compatible with JDK8?

Can you also try to get >80% test coverage on your changes? I see you have added tests, but can't judge coverage, and unfortunately SonarCloud doesn't support PR analysis on external PRs yet.

@artem-ag
Copy link
Contributor Author

JDK8 based tests are failing, can you take a look at that? Maybe you're using something not compatible with JDK8?

Can you also try to get >80% test coverage on your changes? I see you have added tests, but can't judge coverage, and unfortunately SonarCloud doesn't support PR analysis on external PRs yet.

Didn't realize 8, 11, 15 are jdk version numbers... Updated test to be backward compatible. PTAL.

The new class has close to 100% coverage:
Screen Shot 2020-12-30 at 7 13 59 PM

@oliemansm oliemansm added this to the 11.1.0 milestone Dec 31, 2020
@oliemansm oliemansm merged commit fb69545 into graphql-java-kickstart:master Dec 31, 2020
@oliemansm
Copy link
Member

Thanks a lot!

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

Successfully merging this pull request may close these issues.

2 participants