Repository navigation
Conversation
Add tests that pin the JSON written by the common structured logging formats for the rename, add, include, exclude, context and customizer properties, including empty names and charsets, and the message of the empty name assertion in JsonWriter, before changing how names are processed. Signed-off-by: Diego Magalhães <dgomesbr@gmail.com>
Check whether any rename is configured before building the member path in StructuredLoggingJsonPropertiesJsonMembersCustomizer, and only build the message of the empty-name assertion in JsonValueWriter when the assertion fails. Both ran for every member and pair of every log event whenever a logging.structured.json property was set. Names, filtering and failures are unchanged. Signed-off-by: Diego Magalhães <dgomesbr@gmail.com>
dgomesbr
force-pushed
the
perf/json-rename-fast-path
branch
from
November 3, 2026 17:44
a06bab5 to
0290d50
Compare
Member
|
See #52574 (comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As soon as any
logging.structured.json.*property is bound - include, exclude, rename, add, context, stack trace, a customizer, any of them - Boot registersStructuredLoggingJsonPropertiesJsonMembersCustomizer, and its name processor runs on every member of every event, whether or not that member's name actually changes. Two things happen on every single call.renameJsonMembersbuildspath.toUnescapedString()before it even checks whether a rename is configured, and that string gets thrown away unless the user renamed something.JsonValueWriter.processNamebuilds its assertion message eagerly -"NameProcessor " + nameProcessor + " returned an empty result"- even though the message is only used when the result actually is empty. For Spring Boot's own processor, a method reference, building that message means rendering a hidden class name and an identity hash into roughly 160 characters, for every name, every time.renameJsonMembersnow returns the existing name before building the path when no rename is configured, andprocessNamepasses its assertion message as aSupplier, matching how the other assertions in the same file already work. The processor stays registered exactly as before; only the per-name cost on the success path disappears.Names, filtering, ordering, and failures don't change - an empty name still fails with the same
IllegalStateExceptionand the same message text. The one observable difference: aNameProcessor'stoString()is now called only when it actually returns an empty result, so a custom processor whosetoString()throws will fail only on that path instead of on every write. Dropping thetoUnescapedString()call also drops its recursion, so this can only reduce stack depth at the margin instead of inflating/growing on top of it. A differential run over 10,000 generated events across 11 property combinations found no output difference on JDK 17.0.20.1 or 25.0.5, with or without #52362 applied on top - that PR is open against the same customizer but a different method, so the two don't conflict.Most of what this removes is that assertion-message string, built and thrown away on every successful write.
json.addset (micro)json.addset (micro)json.addsetjson.addset