Skip to content
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

Disable Jackson field name interning #2583

Merged
merged 2 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-2583.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Interning introduces excessive contention
links:
- https://github.com/palantir/conjure-java-runtime/pull/2583
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.palantir.conjure.java.serialization;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -46,7 +47,7 @@ private ObjectMappers() {}
* </ul>
*/
public static JsonMapper newClientJsonMapper() {
return withDefaultModules(JsonMapper.builder(new InstrumentedJsonFactory()))
return withDefaultModules(JsonMapper.builder(jsonFactory()))
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.build();
}
Expand Down Expand Up @@ -92,7 +93,7 @@ public static SmileMapper newClientSmileMapper() {
* </ul>
*/
public static JsonMapper newServerJsonMapper() {
return withDefaultModules(JsonMapper.builder(new InstrumentedJsonFactory()))
return withDefaultModules(JsonMapper.builder(jsonFactory()))
.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.build();
}
Expand Down Expand Up @@ -220,9 +221,18 @@ public static ObjectMapper withDefaultModules(ObjectMapper mapper) {
.disable(DeserializationFeature.ACCEPT_FLOAT_AS_INT);
}

private static JsonFactory jsonFactory() {
JsonFactory jsonFactory = new InstrumentedJsonFactory();
// Interning introduces excessive contention https://github.com/FasterXML/jackson-core/issues/946
jsonFactory.disable(JsonFactory.Feature.INTERN_FIELD_NAMES);
return jsonFactory;
}

private static SmileFactory smileFactory() {
return InstrumentedSmileFactory.builder()
.disable(SmileGenerator.Feature.ENCODE_BINARY_AS_7BIT)
// Interning introduces excessive contention https://github.com/FasterXML/jackson-core/issues/946
.disable(JsonFactory.Feature.INTERN_FIELD_NAMES)
.build();
}
}