-
-
Notifications
You must be signed in to change notification settings - Fork 809
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
Change default for TokenStreamFactory.Feature.INTERN_FIELD_NAMES
to false
#378
Comments
I have worked on a performance optimization for field name handling, to try to avoid dual-lookup (first to map from byte sequence to String, then from String to property object), and an interesting side benefit here is that this should remove benefit of Assuming this development (addition of new variant of So in the end I think there is a solution that works nicely for all use cases. |
JsonFactory.Feature.INTERN_FIELD_NAMES
for different usageJsonFactory.Feature.INTERN_FIELD_NAMES
to false
for Jackson 3.x
You can write own string pool to implement what |
@IRus Jackson has (and has had) its canonicalizer(s) since first versions. This mostly helps in avoiding allocation overhead, but can not quite be used for identity checks for couple of reasons (separate one for byte- and char-backed sources, out of necessity; databind has no access; these are per |
…ata-binding, more details are here FasterXML/jackson-core#378
JsonFactory.Feature.INTERN_FIELD_NAMES
to false
for Jackson 3.xTokenStreamFactory.Feature.INTERN_FIELD_NAMES
to false
After updating all codecs to implement And with other changes databind is typically 10-20% faster, despite not being able to use identity checks. So this ended up being win/win situation after all. Thank you everyone who helped convince me this was worth the effort. :) |
(note: 3.0 will split
JsonFactory
intoTokenStreamFactory
base for all codecs, andJsonFactory
just or json -- features to be part of former)Since there are many users concerned about downsides of interning JSON property field names (and similarly for other dataformats, as per #332, it may make sense to consider changing default setting for
INTERN_FIELD_NAMES
feature for Jackson 3.x.As a background, the main measurable benefit of using
String.intern()
on field names (and ONLY once usually, first time a new symbol is encountered -- it is not an on-going cost) is that matching of JSON property name to Java logical property can usually be done with simple identity check.This speeds up data-binding by ~10% for many cases (see
jackson-benchmarks
).But doing this will not usually have benefits if:
To me it seems reasonable that for use case of
ObjectMapper
implicitly creating aJsonFactory
(or similar factory for other formats) default should remain the same. But I have no objection to using different default to "direct" usage.There are multiple ways to achieve this: one possibility would just be to make
ObjectMapper
explicitly set the default if it directly creates the factory; but not change setting if it is passed one.And then
JsonFactory
base class can just default to intern()ing being disabled by default.Other than this I am also open to possibility of changing defaults for databinding use case, if all major framework developers choose explicitly disabled settings as their baseline.
(authors/contributors of major frameworks like Spring Boot, Dropwizard, Restlet etc etc please send your notes to mailing list, or directly to developers -- I am not looking forward to "voting" here; but I will add condensed notes here for any input we receive).
The text was updated successfully, but these errors were encountered: