-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Improve performance of UnresolvedForwardReference
for forward reference resolution
#3419
Milestone
Comments
+1 for such work: contribution would be very welcome! Yes, I know exception construction is expensive mostly due to stack trace calculations. |
morganga
added a commit
to morganga/jackson-databind
that referenced
this issue
Mar 20, 2022
…eference thrown internally.
morganga
added a commit
to morganga/jackson-databind
that referenced
this issue
Mar 21, 2022
…eference thrown internally.
cowtowncoder
changed the title
UnresolvedForwardReference performance improvement for forward reference resolution
Improve performance of Mar 22, 2022
UnresolvedForwardReference
for forward reference resolution
cowtowncoder
added a commit
that referenced
this issue
Mar 22, 2022
Merged, will be included in 2.14.0. Thank you @morganga! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JsonMappingException is a checked exception used to signal fatal problems with mapping of content.
UnresolvedForwardReference, which extends JsonMappingException is thrown and caught internally for completely VALID json to resolve forward references.
Throwable.fillInStackTrace() is an expensive operation, it's the main cost of throwing most Exceptions, and it's called for all UnresolvedForwardReference thrown and caught internally. The stackTrace is irrelevant for these internal exceptions, it is wasted computation.
The json documents we process are full of object references, so I took the liberty of locally redefining UnresolvedForwardReference to extend RuntimeException, and using the RuntimeException constructor to set writableStackTrace to false, bypassing the Throwable.fillInStackTrace() call.
I noticed speed improvements of 50%, deserialization takes half the time when Throwable.fillInStackTrace() is turned off for our typical json payloads.
DeserializationContext does have a method checkUnresolvedObjectId(), which throws the genuine fatal unresolved forward references.
All I'm asking is that UnresolvedForwardReference thrown and caught internally are created with writableStackTrace = false, whether that's achieved by supplying new parent constructors to pass the flag up the hierarchy, or creating a new exception type that's only used internally to report a forward reference to be resolved later, It need not be a breaking change, only an internal performance improvement.
The text was updated successfully, but these errors were encountered: