From 93bc91ac34a1d4d30f900d6b2d2a6bc4f7dbce69 Mon Sep 17 00:00:00 2001 From: Carter Kozak Date: Fri, 5 May 2023 12:27:42 -0400 Subject: [PATCH] fix #994: Expand ByteSourceJsonBootstrapper canonicalization performance comment --- .../jackson/core/json/ByteSourceJsonBootstrapper.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/com/fasterxml/jackson/core/json/ByteSourceJsonBootstrapper.java b/src/main/java/com/fasterxml/jackson/core/json/ByteSourceJsonBootstrapper.java index b2b9d088bf..d6d0545863 100644 --- a/src/main/java/com/fasterxml/jackson/core/json/ByteSourceJsonBootstrapper.java +++ b/src/main/java/com/fasterxml/jackson/core/json/ByteSourceJsonBootstrapper.java @@ -259,6 +259,11 @@ public JsonParser constructParser(int parserFeatures, ObjectCodec codec, if (enc == JsonEncoding.UTF8) { /* and without canonicalization, byte-based approach is not performant; just use std UTF-8 reader * (which is ok for larger input; not so hot for smaller; but this is not a common case) + * 5-May-2023, ckozak [core#994]: The reader-based implementation under-performs for small inputs + * due to the initialization cost of InputStreamReader which allocates a new 8KiB buffer. Normalizing + * benchmarks for that fixed cost, ReaderBasedJsonParser maintains a performance edge in tested scenarios. + * Notes from this investigation can be found here: + * https://github.com/FasterXML/jackson-core/pull/995#issuecomment-1523912770 */ if (JsonFactory.Feature.CANONICALIZE_FIELD_NAMES.enabledIn(factoryFeatures)) { ByteQuadsCanonicalizer can = rootByteSymbols.makeChild(factoryFeatures);