-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Dto streaming #3103
Dto streaming #3103
Conversation
Hello @tareqhs thanks for this PR. Do you have any statistic that confirms performance optimization? |
Build # 1052 - FAILED Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/1052/ to view the results. |
7dc41f6
to
d7d5661
Compare
Hi @skabashnyuk , Setup
All times below are in milliseconds. Benchmark 1 Without fix : 6601, 5569, 5931, 5479, 5486, 5838, 5523, 5556, 5521, 5495 Omitting the bootstrap pass, average benchmark time is reduced by 52% Benchmark 2 Without fix : 6758, 6460, 6480, 6492, 6602, 6455, 6431, 6478, 6400, 6617 Omitting the bootstrap pass, average benchmark time is reduced by 63% |
* use Reader/Writer directly in DtoFactory, do not create full JSON texts * read/write DTOs using direct streaming methods instead of building trees * configure Gson type adapters instead of generating tree building code Signed-off-by: Tareq Sharafy <tareq.sha@gmail.com>
d7d5661
to
f89f313
Compare
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/1062/ |
hi @skabashnyuk , any update on this ? |
Build # 1149 - FAILED Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/1149/ to view the results. |
ci-build |
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/1179/ |
@skabashnyuk seems the ci passes now |
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/1394/ |
@@ -176,6 +177,16 @@ protected String getJsonFieldName(Method getterMethod) { | |||
return new ArrayList<>(getters.values()); | |||
} | |||
|
|||
protected Set<String> getSuperGetterNames(Class<?> dto) { |
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.
javadoc
@@ -46,5 +46,18 @@ | |||
void setParentField(String parentField); | |||
|
|||
ChildDto withParentField(String parentField); | |||
|
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.
What is the purpose of changes in DTOHierarchy class?
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.
shadowed fields cause caused initial failure, fixed this and added them to make the behavior is consistent
@skabashnyuk
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.
Can you elaborate a bit more. explanation is not clear for me.
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.
Gson fails if a class has a shadowed field (a field with the same name as another field in a base class). To avoid this shadowed fields are omitted from generated classes and this test verifies the behavior. @skabashnyuk
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/1454/ |
hi @skabashnyuk , any update on this ? |
No updates. I'm looking for some free time-frame to make some integration and performance testing internally. Recently we made some performance testing of ws-agent and one of the slowest part was DTO parsing codenvy/codenvy#1466. Interesting how your PR can affect on this. |
Added Changlog entry. |
down-port eclipse-che/che#3103 Change-Id: I1465e8b1023511e9ce248340c45f3cf9eb957157
down-port eclipse-che/che#3103 Change-Id: Iea2704e625105ad483ee9f1348b217b0bc493d6e Signed-off-by: Tareq Sharafy <tareq.sha@gmail.com>
down-port eclipse-che/che#3103 Change-Id: Iea2704e625105ad483ee9f1348b217b0bc493d6e Signed-off-by: Tareq Sharafy <tareq.sha@gmail.com>
down-port eclipse-che/che#3103 Change-Id: Iea2704e625105ad483ee9f1348b217b0bc493d6e Signed-off-by: Tareq Sharafy <tareq.sha@gmail.com>
down-port eclipse-che/che#3103 Change-Id: Iea2704e625105ad483ee9f1348b217b0bc493d6e Signed-off-by: Tareq Sharafy <tareq.sha@gmail.com>
down-port eclipse-che/che#3103 Change-Id: Iea2704e625105ad483ee9f1348b217b0bc493d6e Signed-off-by: Tareq Sharafy <tareq.sha@gmail.com>
down-port eclipse-che/che#3103 Change-Id: Iea2704e625105ad483ee9f1348b217b0bc493d6e Signed-off-by: Tareq Sharafy <tareq.sha@gmail.com>
* Streaming approach for DTO serialization * use Reader/Writer directly in DtoFactory, do not create full JSON texts * read/write DTOs using direct streaming methods instead of building trees * configure Gson type adapters instead of generating tree building code Signed-off-by: Tareq Sharafy <tareq.sha@gmail.com> * add missing javadoc
What does this PR do?
Eliminates the redundant creation of full in-memory JSON tress and then strings when reading DTOs from requests or writing them to responses. Applies to general consumption of
DtoFactory
as well, not JAX-RS services only.What issues does this PR fix or reference?
Current method always constructs a full replica of the DTO objects as an in-memory
JsonElement
tree, and then asks Gson to dump the tree as a full string. There are two issues here:JsonWriter
which eliminates the need for any intermediate trees. Actually no JSON elements are created at all here.CheJsonProvider
passes streamReader
and responseWriter
that can used directly by Gson, eliminating even the need of an intermediate full JSON texts.A large part of the generated DTO implementation code is there to replicate the DTO data in
JsonElement
trees, bit by bit. The code section in the generator that takes care of generating this java code in the tool is the most complicated area in the already hard to maintain generator. Gson can do this automatically and more efficiently (previous point).Previous behavior
New behavior
Reader
s and responseWriter
s directly inDtoFactory
.Changelog
Removes redundant in-memory JSON trees for faster DTO parsing performance.
Signed-off-by: Tareq Sharafy tareq.sha@gmail.com