From 0123ffda77493d8b8144e53f2e90b89214ea0a03 Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Tue, 4 Apr 2023 11:04:02 -0400 Subject: [PATCH 1/2] Disable Jackson field name interning Interning introduces excessive contention https://github.com/FasterXML/jackson-core/issues/946 --- .../conjure/java/serialization/ObjectMappers.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/conjure-java-jackson-serialization/src/main/java/com/palantir/conjure/java/serialization/ObjectMappers.java b/conjure-java-jackson-serialization/src/main/java/com/palantir/conjure/java/serialization/ObjectMappers.java index 2b1e9ed0b..d2133684a 100644 --- a/conjure-java-jackson-serialization/src/main/java/com/palantir/conjure/java/serialization/ObjectMappers.java +++ b/conjure-java-jackson-serialization/src/main/java/com/palantir/conjure/java/serialization/ObjectMappers.java @@ -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; @@ -46,7 +47,7 @@ private ObjectMappers() {} * */ public static JsonMapper newClientJsonMapper() { - return withDefaultModules(JsonMapper.builder(new InstrumentedJsonFactory())) + return withDefaultModules(JsonMapper.builder(jsonFactory())) .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) .build(); } @@ -92,7 +93,7 @@ public static SmileMapper newClientSmileMapper() { * */ public static JsonMapper newServerJsonMapper() { - return withDefaultModules(JsonMapper.builder(new InstrumentedJsonFactory())) + return withDefaultModules(JsonMapper.builder(jsonFactory())) .enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) .build(); } @@ -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(); } } From 1c26ef0c033e8a77c8d8e14588ca630612e09e98 Mon Sep 17 00:00:00 2001 From: svc-changelog Date: Tue, 4 Apr 2023 16:17:07 +0000 Subject: [PATCH 2/2] Add generated changelog entries --- changelog/@unreleased/pr-2583.v2.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelog/@unreleased/pr-2583.v2.yml diff --git a/changelog/@unreleased/pr-2583.v2.yml b/changelog/@unreleased/pr-2583.v2.yml new file mode 100644 index 000000000..6cfc19c0e --- /dev/null +++ b/changelog/@unreleased/pr-2583.v2.yml @@ -0,0 +1,5 @@ +type: improvement +improvement: + description: Interning introduces excessive contention + links: + - https://github.com/palantir/conjure-java-runtime/pull/2583