-
Notifications
You must be signed in to change notification settings - Fork 117
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
Optimize InstantDeserializer
addInColonToOffsetIfMissing()
#336
Conversation
976935a
to
0415d3f
Compare
0415d3f
to
6cc4f9b
Compare
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.
@schlosna Super interesting findings! 👍🏼👍🏼 Just out of curiosity, may I ask how much performance improvement this change makes in your usecase/production? Here the performance test here you shared (thank you) seems to show like 20% improvement, but just wondering how much or just how it helps in production.
Thank you in advance!
datetime/src/main/java/com/fasterxml/jackson/datatype/jsr310/deser/InstantDeserializer.java
Show resolved
Hide resolved
@Test | ||
public void OffsetDateTime_with_offset_can_be_deserialized() throws Exception { |
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.
Seems like we can merge this and one for zonedDateTime below into a separate test class like Xxx336Test.java
for their purposes and similar style, but idk might be overkill for now.
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.
Sure, I can consolidate these into a separate test 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.
In this case, I think keeping them along with existing test makes sense: this is not new functionality but optimizing (and adding test coverage). So let's not create per-issue test classes.
Also, for a second I thought about maybe change
classes to override for their own good. This one also potential overkill (or at least for at this point) |
Thanks for the quick review. I have seen profiles pointing at the regex matcher allocations and method profiles pointing at |
While more performance results can be useful and interesting, I think I am satisfied with included benchmarks. True, end-to-end effect will be more limited, but this seems like safe change wrt test coverage. So I will go ahead and merge -- 2.19(.0) makes sense since while looks safe enough, changes are not trivial so prefer inclusion in minor version (over patch). |
InstantDeserializer
addInColonToOffsetIfMissing()
Thanks @cowtowncoder |
When using Jackson to deserialize timestamps with formatter of
DateTimeFormatter.ISO_OFFSET_DATE_TIME
orDateTimeFormatter.ISO_ZONED_DATE_TIME
, a lot of time is spent inInstantDeserializer::addInColonToOffsetIfMissing
allocating and performing regex matching on possible timezone offset, even if the input timestamp is already in a valid ISO 8601 format with explicit zone ofZ
or with colon separated offset.Similar to #266
Before (2.18.2)
After (2.19.0-SNAPSHOT)