Skip to content

Commit 00af395

Browse files
authored
Backport #7909: Enable Fast Double Parser in Jackson with system property (#8467)
* Enable Fast Double Parser in Jackson Signed-off-by: Mohit Godwani <[email protected]> * Update chaneglog Signed-off-by: Mohit Godwani <[email protected]> * Add fast double writer behind system property Signed-off-by: Mohit Godwani <[email protected]> * Extract system property out to a constant Signed-off-by: Mohit Godwani <[email protected]> --------- Signed-off-by: Mohit Godwani <[email protected]>
1 parent a90ab97 commit 00af395

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

CHANGELOG.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1616
- Make remote cluster connection setup in async ([#8038](https://github.com/opensearch-project/OpenSearch/pull/8038))
1717
- Add API to initialize extensions ([#8029]()https://github.com/opensearch-project/OpenSearch/pull/8029)
1818
- Added GeoBounds aggregation on GeoShape field type.([#4266](https://github.com/opensearch-project/OpenSearch/pull/4266))
19-
- Addition of Doc values on the GeoShape Field
20-
- Addition of GeoShape ValueSource level code interfaces for accessing the DocValues.
21-
- Addition of Missing Value feature in the GeoShape Aggregations.
19+
- Addition of Doc values on the GeoShape Field
20+
- Addition of GeoShape ValueSource level code interfaces for accessing the DocValues.
21+
- Addition of Missing Value feature in the GeoShape Aggregations.
2222
- Enable Point based optimization for custom comparators ([#8168](https://github.com/opensearch-project/OpenSearch/pull/8168))
2323
- Add GeoTile and GeoHash Grid aggregations on GeoShapes. ([#5589](https://github.com/opensearch-project/OpenSearch/pull/5589))
2424
- Add distributed tracing framework ([#7543](https://github.com/opensearch-project/OpenSearch/issues/7543))
@@ -88,6 +88,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8888
- [Refactor] OpenSearchException and ExceptionsHelper foundation to base class ([#7508](https://github.com/opensearch-project/OpenSearch/pull/7508))
8989
- Move ZSTD compression codecs out of the sandbox ([#7908](https://github.com/opensearch-project/OpenSearch/pull/7908))
9090
- Update ZSTD default compression level ([#8471](https://github.com/opensearch-project/OpenSearch/pull/8471))
91+
- Improved performance of parsing floating point numbers ([#8467](https://github.com/opensearch-project/OpenSearch/pull/8467))
9192

9293
### Deprecated
9394

libs/x-content/src/main/java/org/opensearch/common/xcontent/cbor/CborXContent.java

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import com.fasterxml.jackson.core.JsonGenerator;
3737
import com.fasterxml.jackson.core.JsonParser;
3838
import com.fasterxml.jackson.core.StreamReadConstraints;
39+
import com.fasterxml.jackson.core.StreamReadFeature;
40+
import com.fasterxml.jackson.core.StreamWriteFeature;
3941
import com.fasterxml.jackson.dataformat.cbor.CBORFactory;
4042
import org.opensearch.core.xcontent.DeprecationHandler;
4143
import org.opensearch.core.xcontent.MediaType;
@@ -61,6 +63,8 @@ public class CborXContent implements XContent {
6163
System.getProperty("opensearch.xcontent.string.length.max", Integer.toString(Integer.MAX_VALUE) /* no limit */)
6264
);
6365

66+
public static final boolean USE_FAST_DOUBLE_WRITER = Boolean.getBoolean("opensearch.xcontent.use_fast_double_writer");
67+
6468
public static XContentBuilder contentBuilder() throws IOException {
6569
return XContentBuilder.builder(cborXContent);
6670
}
@@ -75,6 +79,8 @@ public static XContentBuilder contentBuilder() throws IOException {
7579
cborFactory.configure(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, false);
7680
cborFactory.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true);
7781
cborFactory.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());
82+
cborFactory.configure(StreamReadFeature.USE_FAST_DOUBLE_PARSER.mappedFeature(), true);
83+
cborFactory.configure(StreamWriteFeature.USE_FAST_DOUBLE_WRITER.mappedFeature(), USE_FAST_DOUBLE_WRITER);
7884
cborXContent = new CborXContent();
7985
}
8086

libs/x-content/src/main/java/org/opensearch/common/xcontent/json/JsonXContent.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
import com.fasterxml.jackson.core.JsonGenerator;
3838
import com.fasterxml.jackson.core.JsonParser;
3939
import com.fasterxml.jackson.core.StreamReadConstraints;
40-
40+
import com.fasterxml.jackson.core.StreamReadFeature;
41+
import com.fasterxml.jackson.core.StreamWriteFeature;
4142
import org.opensearch.core.xcontent.DeprecationHandler;
4243
import org.opensearch.core.xcontent.MediaType;
4344
import org.opensearch.core.xcontent.NamedXContentRegistry;
@@ -61,6 +62,8 @@ public class JsonXContent implements XContent {
6162
System.getProperty("opensearch.xcontent.string.length.max", Integer.toString(Integer.MAX_VALUE) /* no limit */)
6263
);
6364

65+
public static final boolean USE_FAST_DOUBLE_WRITER = Boolean.getBoolean("opensearch.xcontent.use_fast_double_writer");
66+
6467
public static XContentBuilder contentBuilder() throws IOException {
6568
return XContentBuilder.builder(jsonXContent);
6669
}
@@ -78,6 +81,8 @@ public static XContentBuilder contentBuilder() throws IOException {
7881
jsonFactory.configure(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, false);
7982
jsonFactory.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true);
8083
jsonFactory.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());
84+
jsonFactory.configure(StreamReadFeature.USE_FAST_DOUBLE_PARSER.mappedFeature(), true);
85+
jsonFactory.configure(StreamWriteFeature.USE_FAST_DOUBLE_WRITER.mappedFeature(), USE_FAST_DOUBLE_WRITER);
8186
jsonXContent = new JsonXContent();
8287
}
8388

libs/x-content/src/main/java/org/opensearch/common/xcontent/smile/SmileXContent.java

+6
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
import com.fasterxml.jackson.core.JsonGenerator;
3737
import com.fasterxml.jackson.core.JsonParser;
3838
import com.fasterxml.jackson.core.StreamReadConstraints;
39+
import com.fasterxml.jackson.core.StreamReadFeature;
40+
import com.fasterxml.jackson.core.StreamWriteFeature;
3941
import com.fasterxml.jackson.dataformat.smile.SmileFactory;
4042
import com.fasterxml.jackson.dataformat.smile.SmileGenerator;
4143
import org.opensearch.core.xcontent.DeprecationHandler;
@@ -61,6 +63,8 @@ public class SmileXContent implements XContent {
6163
System.getProperty("opensearch.xcontent.string.length.max", Integer.toString(Integer.MAX_VALUE) /* no limit */)
6264
);
6365

66+
public static final boolean USE_FAST_DOUBLE_WRITER = Boolean.getBoolean("opensearch.xcontent.use_fast_double_writer");
67+
6468
public static XContentBuilder contentBuilder() throws IOException {
6569
return XContentBuilder.builder(smileXContent);
6670
}
@@ -77,6 +81,8 @@ public static XContentBuilder contentBuilder() throws IOException {
7781
smileFactory.configure(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, false);
7882
smileFactory.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true);
7983
smileFactory.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());
84+
smileFactory.configure(StreamReadFeature.USE_FAST_DOUBLE_PARSER.mappedFeature(), true);
85+
smileFactory.configure(StreamWriteFeature.USE_FAST_DOUBLE_WRITER.mappedFeature(), USE_FAST_DOUBLE_WRITER);
8086
smileXContent = new SmileXContent();
8187
}
8288

libs/x-content/src/main/java/org/opensearch/common/xcontent/yaml/YamlXContent.java

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import com.fasterxml.jackson.core.JsonEncoding;
3636
import com.fasterxml.jackson.core.JsonParser;
3737
import com.fasterxml.jackson.core.StreamReadConstraints;
38+
import com.fasterxml.jackson.core.StreamReadFeature;
39+
import com.fasterxml.jackson.core.StreamWriteFeature;
3840
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
3941
import org.opensearch.core.xcontent.DeprecationHandler;
4042
import org.opensearch.core.xcontent.NamedXContentRegistry;
@@ -59,6 +61,8 @@ public class YamlXContent implements XContent {
5961
System.getProperty("opensearch.xcontent.string.length.max", Integer.toString(Integer.MAX_VALUE) /* no limit */)
6062
);
6163

64+
public static final boolean USE_FAST_DOUBLE_WRITER = Boolean.getBoolean("opensearch.xcontent.use_fast_double_writer");
65+
6266
public static XContentBuilder contentBuilder() throws IOException {
6367
return XContentBuilder.builder(yamlXContent);
6468
}
@@ -70,6 +74,8 @@ public static XContentBuilder contentBuilder() throws IOException {
7074
yamlFactory = new YAMLFactory();
7175
yamlFactory.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true);
7276
yamlFactory.setStreamReadConstraints(StreamReadConstraints.builder().maxStringLength(DEFAULT_MAX_STRING_LEN).build());
77+
yamlFactory.configure(StreamReadFeature.USE_FAST_DOUBLE_PARSER.mappedFeature(), true);
78+
yamlFactory.configure(StreamWriteFeature.USE_FAST_DOUBLE_WRITER.mappedFeature(), USE_FAST_DOUBLE_WRITER);
7379
yamlXContent = new YamlXContent();
7480
}
7581

0 commit comments

Comments
 (0)