Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
331 commits
Select commit Hold shift + click to select a range
5e4655c
More threads
Tim-Brooks Jul 26, 2025
46e42ce
Change
Tim-Brooks Jul 26, 2025
2b18de7
Change
Tim-Brooks Jul 26, 2025
9523da9
WIP
Tim-Brooks Jul 26, 2025
beaae12
Always structure source
Tim-Brooks Jul 27, 2025
80473e3
Changes
Tim-Brooks Jul 27, 2025
d341c21
Merge remote-tracking branch 'origin/main' into structured_source
Tim-Brooks Jul 27, 2025
549da44
Fix
Tim-Brooks Jul 28, 2025
16d139f
WIP
Tim-Brooks Jul 28, 2025
5e65b3d
Fix
Tim-Brooks Jul 28, 2025
91d246c
Change
Tim-Brooks Jul 28, 2025
e4422ed
Change
Tim-Brooks Jul 28, 2025
cfa2008
Fix
Tim-Brooks Jul 28, 2025
38c2840
fix
Tim-Brooks Jul 28, 2025
38ceb29
Merge remote-tracking branch 'origin/main' into structured_source
Tim-Brooks Jul 28, 2025
ab9e7ba
Change
Tim-Brooks Jul 28, 2025
fc5cdb8
Change
Tim-Brooks Jul 29, 2025
759c632
Change
Tim-Brooks Jul 29, 2025
685f8e7
Merge branch 'structured_source' into structured_source_benchmark
Tim-Brooks Jul 29, 2025
bb057f6
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Jul 29, 2025
eb95625
Changes
Tim-Brooks Jul 29, 2025
110843f
Changes
Tim-Brooks Jul 29, 2025
0a415fb
Close builder
Tim-Brooks Jul 29, 2025
4f2a83a
fix
Tim-Brooks Jul 29, 2025
934593c
Merge branch 'structured_source' into structured_source_benchmark
Tim-Brooks Jul 29, 2025
5893b8a
Fix'
Tim-Brooks Jul 29, 2025
915afab
Merge branch 'structured_source' into structured_source_benchmark
Tim-Brooks Jul 29, 2025
b21c4af
Merge remote-tracking branch 'upstream/main' into structured_source_b…
Tim-Brooks Jul 29, 2025
f22bee4
WIP
Tim-Brooks Jul 30, 2025
ee797b3
Merge remote-tracking branch 'upstream/main' into structured_source_b…
Tim-Brooks Jul 30, 2025
de3160d
Merge remote-tracking branch 'upstream/main' into structured_source_b…
Tim-Brooks Jul 30, 2025
ec75689
WIP
Tim-Brooks Jul 30, 2025
514ae5d
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Jul 30, 2025
2a8dd7c
Change
Tim-Brooks Jul 30, 2025
3cafd1a
NO string interning
Tim-Brooks Jul 31, 2025
25c4d6e
Change
Tim-Brooks Aug 6, 2025
adeee35
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 6, 2025
2db41bb
Changes
Tim-Brooks Aug 7, 2025
2ae8af5
Test
Tim-Brooks Aug 7, 2025
d73705d
Merge branch 'structured_source' into structured_source_benchmark
Tim-Brooks Aug 7, 2025
d44ba76
intern back on
Tim-Brooks Aug 7, 2025
7780bd9
Coment
Tim-Brooks Aug 7, 2025
92a0ed3
Change
Tim-Brooks Aug 7, 2025
d2c857c
Merge branch 'structured_source' into structured_source_benchmark
Tim-Brooks Aug 7, 2025
607c451
Change
Tim-Brooks Aug 7, 2025
9969f8e
Changes
Tim-Brooks Aug 7, 2025
89ac8a2
Changes
Tim-Brooks Aug 7, 2025
c018a7f
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 7, 2025
4077e5a
Fix
Tim-Brooks Aug 8, 2025
c94a52e
bytes
Tim-Brooks Aug 8, 2025
c8826d0
codepoints
Tim-Brooks Aug 8, 2025
2086790
Token array
Tim-Brooks Aug 8, 2025
44e06f6
Merge remote-tracking branch 'upstream/main' into structured_source_b…
Tim-Brooks Aug 8, 2025
f1dd847
Structured source immediately
Tim-Brooks Aug 8, 2025
d0610ab
Merge branch 'structured_source' into structured_source_benchmark
Tim-Brooks Aug 8, 2025
68c8083
Change
Tim-Brooks Aug 8, 2025
0c08e92
Try 2x
Tim-Brooks Aug 8, 2025
b092f7a
Revert "Try 2x"
Tim-Brooks Aug 8, 2025
10343c2
Revert "Change"
Tim-Brooks Aug 8, 2025
850db86
Revert "Token array"
Tim-Brooks Aug 8, 2025
9bb6ef2
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 8, 2025
47f25e5
Merge branch 'structured_source' into structured_source_benchmark
Tim-Brooks Aug 8, 2025
8dbcfa3
Remove transport thrad
Tim-Brooks Aug 9, 2025
c8d8eae
WIP
Tim-Brooks Aug 9, 2025
98b14d5
WIP
Tim-Brooks Aug 9, 2025
42389f5
Change
Tim-Brooks Aug 10, 2025
0a2cf01
Change
Tim-Brooks Aug 10, 2025
5f9a6fe
Rework
Tim-Brooks Aug 10, 2025
0c3f6f1
Change
Tim-Brooks Aug 10, 2025
fe88f68
Change
Tim-Brooks Aug 10, 2025
f5f6b52
Fix
Tim-Brooks Aug 10, 2025
0c2a00d
Improvements
Tim-Brooks Aug 11, 2025
bd830bd
Fix
Tim-Brooks Aug 11, 2025
18ac0b8
More
Tim-Brooks Aug 11, 2025
05b30ff
Changes
Tim-Brooks Aug 11, 2025
1f303cf
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 11, 2025
adfd67e
more
Tim-Brooks Aug 11, 2025
5043373
Change
Tim-Brooks Aug 11, 2025
f980cfc
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 11, 2025
f9ae107
Change
Tim-Brooks Aug 11, 2025
74dcdac
Fix
Tim-Brooks Aug 11, 2025
fe9de75
Change
Tim-Brooks Aug 11, 2025
82f6c7d
Changes
Tim-Brooks Aug 12, 2025
128a12f
Fix more
Tim-Brooks Aug 12, 2025
4201bc9
Fixes
Tim-Brooks Aug 12, 2025
201b9a4
Fix
Tim-Brooks Aug 12, 2025
4926e58
Change
Tim-Brooks Aug 12, 2025
5fab684
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 12, 2025
3b35079
Change
Tim-Brooks Aug 12, 2025
c433086
Change
Tim-Brooks Aug 12, 2025
4b2476a
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 12, 2025
a5d3f75
FIxes
Tim-Brooks Aug 12, 2025
5741663
Change
Tim-Brooks Aug 12, 2025
3358fff
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 12, 2025
4ac2af0
Change
Tim-Brooks Aug 12, 2025
47c4d4a
Fixes
Tim-Brooks Aug 13, 2025
b7bd3c7
Change
Tim-Brooks Aug 13, 2025
848807f
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 13, 2025
5689d8a
Fix
Tim-Brooks Aug 13, 2025
e411e03
Merge remote-tracking branch 'upstream/main' into structured_source_b…
Tim-Brooks Aug 13, 2025
32847df
Fix
Tim-Brooks Aug 13, 2025
7b3b090
Fix
Tim-Brooks Aug 13, 2025
7962b43
Change
Tim-Brooks Aug 13, 2025
30fc90a
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 13, 2025
94dea1e
[CI] Auto commit changes from spotless
Aug 13, 2025
caf1be8
Change
Tim-Brooks Aug 13, 2025
82e7640
Merge remote-tracking branch 'origin/structured_source' into structur…
Tim-Brooks Aug 13, 2025
ced9501
Changes
Tim-Brooks Aug 13, 2025
feb815c
Change
Tim-Brooks Aug 13, 2025
f7b771c
Change
Tim-Brooks Aug 13, 2025
8433712
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 13, 2025
fe746a8
Fix
Tim-Brooks Aug 13, 2025
4f18865
Merge branch 'structured_source' into structured_source_benchmark
Tim-Brooks Aug 13, 2025
befffa9
delay
Tim-Brooks Aug 13, 2025
2d28a6d
Changes
Tim-Brooks Aug 13, 2025
b114cd4
Changes
Tim-Brooks Aug 13, 2025
b0d8ac5
Add
Tim-Brooks Aug 13, 2025
54733a7
more
Tim-Brooks Aug 13, 2025
68f5ab3
Change
Tim-Brooks Aug 13, 2025
68ad391
Fix
Tim-Brooks Aug 14, 2025
f4ab624
Change
Tim-Brooks Aug 14, 2025
2ec0d9d
Change
Tim-Brooks Aug 14, 2025
5f7d960
Change
Tim-Brooks Aug 14, 2025
a00fb8c
Fix
Tim-Brooks Aug 14, 2025
4b2cb7f
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 14, 2025
c6c3c71
Fix
Tim-Brooks Aug 14, 2025
ef1c9db
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 14, 2025
865bba3
bwc
Tim-Brooks Aug 14, 2025
85ab650
Change
Tim-Brooks Aug 14, 2025
5bb9016
More
Tim-Brooks Aug 14, 2025
b13384e
Change
Tim-Brooks Aug 14, 2025
dc14c22
Change
Tim-Brooks Aug 14, 2025
ab88a41
Cahnges
Tim-Brooks Aug 14, 2025
de45afc
Change
Tim-Brooks Aug 14, 2025
452b843
Change
Tim-Brooks Aug 14, 2025
4dfb845
Work
Tim-Brooks Aug 14, 2025
4015fbb
Change
Tim-Brooks Aug 14, 2025
75d4c46
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 14, 2025
6b7ccf2
Changes
Tim-Brooks Aug 15, 2025
8d48ad6
Change
Tim-Brooks Aug 15, 2025
bb153a9
WIP
Tim-Brooks Aug 15, 2025
6085d0f
Change
Tim-Brooks Aug 15, 2025
af757a0
Merge remote-tracking branch 'upstream/main' into structured_source_b…
Tim-Brooks Aug 15, 2025
02ec323
Smaller estimate
Tim-Brooks Aug 15, 2025
afd766d
Change
Tim-Brooks Aug 15, 2025
632831b
Change
Tim-Brooks Aug 15, 2025
661537e
change
Tim-Brooks Aug 15, 2025
363f092
Change
Tim-Brooks Aug 15, 2025
5c2cd99
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 15, 2025
4fc1df0
Fix
Tim-Brooks Aug 15, 2025
df353fc
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 15, 2025
5a3f194
Change
Tim-Brooks Aug 16, 2025
4849e1a
Change
Tim-Brooks Aug 16, 2025
8f6bc10
Change
Tim-Brooks Aug 16, 2025
16eb77c
More
Tim-Brooks Aug 16, 2025
77a75be
Change
Tim-Brooks Aug 16, 2025
db2e9e1
Always start with a page
Tim-Brooks Aug 16, 2025
360e368
Change
Tim-Brooks Aug 16, 2025
7c2925a
Routing
Tim-Brooks Aug 16, 2025
5fe0923
Change
Tim-Brooks Aug 16, 2025
dec8b68
Change
Tim-Brooks Aug 17, 2025
e366c11
Change
Tim-Brooks Aug 17, 2025
0ca1f56
Change
Tim-Brooks Aug 17, 2025
a8b232e
Change
Tim-Brooks Aug 17, 2025
e32dcf2
Try stuff
Tim-Brooks Aug 17, 2025
9374251
Change
Tim-Brooks Aug 17, 2025
6612c32
Fix
Tim-Brooks Aug 17, 2025
02dfa8c
WIP
Tim-Brooks Aug 17, 2025
6652462
Change
Tim-Brooks Aug 17, 2025
f4733f4
Try more
Tim-Brooks Aug 17, 2025
11d900e
More
Tim-Brooks Aug 18, 2025
6fb1afa
More
Tim-Brooks Aug 18, 2025
eb73ecd
More
Tim-Brooks Aug 18, 2025
9d5d04f
Fix
Tim-Brooks Aug 18, 2025
6c13710
Fix
Tim-Brooks Aug 18, 2025
9149e7a
Cleanup
Tim-Brooks Aug 18, 2025
feca844
Merge branch 'structured_source_benchmark' into structured_source
Tim-Brooks Aug 19, 2025
4cda678
Fix
Tim-Brooks Aug 19, 2025
98fb570
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 19, 2025
ee9eb51
Fix
Tim-Brooks Aug 19, 2025
608f302
Fix
Tim-Brooks Aug 19, 2025
4675357
Fix
Tim-Brooks Aug 20, 2025
3c68e47
Fix
Tim-Brooks Aug 20, 2025
99a417b
Release early
Tim-Brooks Aug 20, 2025
0852481
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 20, 2025
2e6b214
Merge branch 'structured_source_benchmark' into structured_source
Tim-Brooks Aug 20, 2025
4ac139a
Change
Tim-Brooks Aug 21, 2025
cb83ac0
Fix
Tim-Brooks Aug 21, 2025
cf55976
Fix
Tim-Brooks Aug 21, 2025
6616aab
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 21, 2025
c7ab93c
Merge remote-tracking branch 'upstream/main' into structured_source_b…
Tim-Brooks Aug 21, 2025
00cdd07
Merge remote-tracking branch 'upstream/main' into structured_source_b…
Tim-Brooks Aug 22, 2025
129229a
Merge remote-tracking branch 'upstream/main' into structured_source_b…
Tim-Brooks Aug 22, 2025
c1f9f5a
Changes
Tim-Brooks Aug 23, 2025
8bdd706
Merge branch 'structured_source_benchmark' into structured_source
Tim-Brooks Aug 23, 2025
ed7df33
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 23, 2025
c8062a7
Change
Tim-Brooks Aug 23, 2025
a93d99c
Fix
Tim-Brooks Aug 23, 2025
0dc0516
Simpler check
Tim-Brooks Aug 23, 2025
01342a5
Fix
Tim-Brooks Aug 23, 2025
4fbb7e9
Changes
Tim-Brooks Aug 23, 2025
7cc4ed8
Change
Tim-Brooks Aug 23, 2025
11c2e16
Change
Tim-Brooks Aug 23, 2025
fadf629
Change
Tim-Brooks Aug 24, 2025
ac75df7
recycler
Tim-Brooks Aug 24, 2025
0909261
Change
Tim-Brooks Aug 24, 2025
4699089
Change
Tim-Brooks Aug 25, 2025
b2253f5
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 25, 2025
606698c
Fix
Tim-Brooks Aug 25, 2025
9c19383
Change
Tim-Brooks Aug 25, 2025
84285a6
Change
Tim-Brooks Aug 25, 2025
b6b28a4
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 25, 2025
3f620e0
[CI] Auto commit changes from spotless
Aug 25, 2025
11541a8
Fix
Tim-Brooks Aug 25, 2025
f031742
Merge remote-tracking branch 'origin/structured_source' into structur…
Tim-Brooks Aug 25, 2025
4f0f3b7
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 26, 2025
23d4fdd
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 26, 2025
83e9ea8
Change
Tim-Brooks Aug 28, 2025
1ac8c88
Merge remote-tracking branch 'upstream/main' into structure_source_de…
Tim-Brooks Aug 28, 2025
fdeb877
Change
Tim-Brooks Aug 28, 2025
11110cc
Fix
Tim-Brooks Aug 28, 2025
7d347a5
Change
Tim-Brooks Aug 28, 2025
602c99b
Fix
Tim-Brooks Aug 29, 2025
479df6e
Merge remote-tracking branch 'upstream/main' into structured_source_b…
Tim-Brooks Aug 29, 2025
c3e3565
Merge remote-tracking branch 'upstream/main' into structured_source_b…
Tim-Brooks Aug 29, 2025
d46e372
Merge branch 'structured_source' into structured_source_benchmark
Tim-Brooks Aug 29, 2025
52fdea8
Change
Tim-Brooks Aug 29, 2025
96c6878
Fix
Tim-Brooks Aug 29, 2025
40d1c45
both
Tim-Brooks Aug 29, 2025
58d4328
More
Tim-Brooks Aug 29, 2025
a95291d
Fixes
Tim-Brooks Aug 29, 2025
b35f9e3
change
Tim-Brooks Aug 29, 2025
b0e8060
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Aug 29, 2025
c8258f0
Merge branch 'structured_source' into structured_source_benchmark
Tim-Brooks Aug 29, 2025
8c64ab7
More
Tim-Brooks Aug 29, 2025
df020e8
Merge remote-tracking branch 'upstream/main' into structured_source_b…
Tim-Brooks Sep 6, 2025
4bd89ea
Cache current
Tim-Brooks Sep 6, 2025
69f7390
Cache
Tim-Brooks Sep 6, 2025
a77189b
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Sep 8, 2025
7673169
Merge branch 'structured_source_benchmark' into structured_source
Tim-Brooks Sep 8, 2025
8249726
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Sep 8, 2025
85b6004
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Sep 30, 2025
2efe549
Merge remote-tracking branch 'upstream/main' into structured_source
Tim-Brooks Sep 30, 2025
00cbb4f
Change
Tim-Brooks Sep 30, 2025
8dd104a
Change
Tim-Brooks Oct 1, 2025
c996e31
Fix
Tim-Brooks Oct 1, 2025
cbe9630
Change
Tim-Brooks Oct 1, 2025
446def4
Change
Tim-Brooks Oct 1, 2025
17e0fe2
Fix
Tim-Brooks Oct 1, 2025
74ac13e
change
Tim-Brooks Oct 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.benchmark.eson;

import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.recycler.Recycler;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.ingest.ESONIndexed;
import org.elasticsearch.ingest.ESONSource;
import org.elasticsearch.ingest.ESONXContentSerializer;
import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentFactory;
import org.elasticsearch.xcontent.XContentParser;
import org.elasticsearch.xcontent.XContentParserConfiguration;
import org.elasticsearch.xcontent.XContentType;
import org.elasticsearch.xcontent.cbor.CborXContent;
import org.elasticsearch.xcontent.json.JsonXContent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;
import org.openjdk.jmh.infra.Blackhole;

import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;

@Warmup(iterations = 2)
@Measurement(iterations = 3)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread)
@Fork(value = 1)
public class ESONDeserializationBenchmark {

private static final BytesRef BYTES_REF = new BytesRef(new byte[16384]);

private BytesReference source;
private BytesReference cborSource;
private Map<String, Object> map;
private ESONIndexed.ESONObject esonObject;

private final Recycler<BytesRef> refRecycler = new Recycler<>() {
@Override
public V<BytesRef> obtain() {
return new V<>() {
@Override
public BytesRef v() {
return BYTES_REF;
}

@Override
public boolean isRecycled() {
return true;
}

@Override
public void close() {}
};
}

@Override
public int pageSize() {
return BYTES_REF.length;
}
};

@Setup
public void initResults() throws IOException {
source = new BytesArray(
"{\"@timestamp\":\"2021-04-28T19:45:28.222Z\",\"kubernetes\":{\"namespace\":\"namespace0\",\"node\":{\"name\":\"gke-apps-node-name-0\"},\"pod\":{\"name\":\"pod-name-pod-name-0\"},\"volume\":{\"name\":\"volume-0\",\"fs\":{\"capacity\":{\"bytes\":7883960320},\"used\":{\"bytes\":12288},\"inodes\":{\"used\":9,\"free\":1924786,\"count\":1924795},\"available\":{\"bytes\":7883948032}}}},\"metricset\":{\"name\":\"volume\",\"period\":10000},\"fields\":{\"cluster\":\"elastic-apps\"},\"host\":{\"name\":\"gke-apps-host-name0\"},\"agent\":{\"id\":\"96db921d-d0a0-4d00-93b7-2b6cfc591bc3\",\"version\":\"7.6.2\",\"type\":\"metricbeat\",\"ephemeral_id\":\"c0aee896-0c67-45e4-ba76-68fcd6ec4cde\",\"hostname\":\"gke-apps-host-name-0\"},\"ecs\":{\"version\":\"1.4.0\"},\"service\":{\"address\":\"service-address-0\",\"type\":\"kubernetes\"},\"event\":{\"dataset\":\"kubernetes.volume\",\"module\":\"kubernetes\",\"duration\":132588484}}"
);
XContentBuilder builder = XContentFactory.contentBuilder(CborXContent.cborXContent.type());
map = XContentHelper.convertToMap(source, false, XContentType.JSON).v2();
builder.map(map, true);
BytesRef bytesRef = BytesReference.bytes(builder).toBytesRef();
cborSource = new BytesArray(bytesRef.bytes, bytesRef.offset, bytesRef.length);

try (
XContentParser parser = JsonXContent.jsonXContent.createParser(
XContentParserConfiguration.EMPTY,
source.array(),
source.arrayOffset(),
source.length()
)
) {
esonObject = new ESONSource.Builder().parse(parser);
}
}

@Benchmark
public void readCborMap(Blackhole bh) throws IOException {
Tuple<XContentType, Map<String, Object>> tuple = XContentHelper.convertToMap(cborSource, false, XContentType.CBOR);
Map<String, Object> obj = tuple.v2();
bh.consume(obj);
}

@Benchmark
public void writeJSONFromMap(Blackhole bh) throws IOException {
XContentBuilder builder = XContentFactory.contentBuilder(JsonXContent.jsonXContent.type());
builder.map(map, true);
BytesReference bytes = BytesReference.bytes(builder);
bh.consume(bytes);
}

@Benchmark
public void writeJSONFromESON(Blackhole bh) throws IOException {
XContentBuilder builder = XContentFactory.contentBuilder(JsonXContent.jsonXContent.type());
esonObject.toXContent(builder, ToXContent.EMPTY_PARAMS);
BytesReference bytes = BytesReference.bytes(builder);
bh.consume(bytes);
}

@Benchmark
public void writeJSONFromESONFlatten(Blackhole bh) throws IOException {
XContentBuilder builder = XContentFactory.contentBuilder(JsonXContent.jsonXContent.type());
ESONXContentSerializer.flattenToXContent(esonObject.esonFlat(), builder, ToXContent.EMPTY_PARAMS);
BytesReference bytes = BytesReference.bytes(builder);
bh.consume(bytes);
}

@Benchmark
public void readMap(Blackhole bh) throws IOException {
Tuple<XContentType, Map<String, Object>> tuple = XContentHelper.convertToMap(source, false, XContentType.JSON);
Map<String, Object> obj = tuple.v2();
bh.consume(obj);
}

@Benchmark
public void readESON(Blackhole bh) throws IOException {
try (
XContentParser parser = JsonXContent.jsonXContent.createParser(
XContentParserConfiguration.EMPTY,
source.array(),
source.arrayOffset(),
source.length()
)
) {
ESONIndexed.ESONObject eson = new ESONSource.Builder().parse(parser);
bh.consume(eson);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

package org.elasticsearch.benchmark;

import org.elasticsearch.common.bytes.BytesArray;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.ingest.ESONIndexed;
import org.elasticsearch.ingest.ESONSource;
import org.elasticsearch.plugins.internal.XContentParserDecorator;
import org.elasticsearch.test.ESTestCase;
import org.elasticsearch.xcontent.ToXContent;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentFactory;
import org.elasticsearch.xcontent.XContentParser;
import org.elasticsearch.xcontent.XContentParserConfiguration;
import org.elasticsearch.xcontent.XContentType;
import org.elasticsearch.xcontent.json.JsonXContent;

import java.io.IOException;
import java.util.Map;

public class ESONSourceBenchmarkTests extends ESTestCase {

private final BytesArray source = new BytesArray(
"{\"@timestamp\":\"2021-04-28T19:45:28.222Z\",\"kubernetes\":{\"namespace\":\"namespace0\",\"node\":{\"name\":\"gke-apps-node-name-0\"},\"pod\":{\"name\":\"pod-name-pod-name-0\"},\"volume\":{\"name\":\"volume-0\",\"fs\":{\"capacity\":{\"bytes\":7883960320},\"used\":{\"bytes\":12288},\"inodes\":{\"used\":9,\"free\":1924786,\"count\":1924795},\"available\":{\"bytes\":7883948032}}}},\"metricset\":{\"name\":\"volume\",\"period\":10000},\"fields\":{\"cluster\":\"elastic-apps\"},\"host\":{\"name\":\"gke-apps-host-name0\"},\"agent\":{\"id\":\"96db921d-d0a0-4d00-93b7-2b6cfc591bc3\",\"version\":\"7.6.2\",\"type\":\"metricbeat\",\"ephemeral_id\":\"c0aee896-0c67-45e4-ba76-68fcd6ec4cde\",\"hostname\":\"gke-apps-host-name-0\"},\"ecs\":{\"version\":\"1.4.0\"},\"service\":{\"address\":\"service-address-0\",\"type\":\"kubernetes\"},\"event\":{\"dataset\":\"kubernetes.volume\",\"module\":\"kubernetes\",\"duration\":132588484}}"
);

public void testMap() {
System.err.println(source.length());
Map<String, Object> stringObjectMap = XContentHelper.convertToMap(source, false, XContentType.JSON, XContentParserDecorator.NOOP)
.v2();
System.err.println(stringObjectMap);
}

public void testESON() throws IOException {
try (
XContentParser parser = JsonXContent.jsonXContent.createParser(
XContentParserConfiguration.EMPTY,
source.array(),
source.arrayOffset(),
source.length()
)
) {
ESONIndexed.ESONObject root = new ESONSource.Builder().parse(parser);
System.err.println(root);
XContentBuilder builder = XContentFactory.contentBuilder(JsonXContent.jsonXContent.type());
root.toXContent(builder, ToXContent.EMPTY_PARAMS);
BytesReference bytes = BytesReference.bytes(builder);
System.err.println(bytes.utf8ToString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,23 @@

package org.elasticsearch.xcontent.provider;

import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.exc.StreamConstraintsException;
import com.fasterxml.jackson.core.sym.ByteQuadsCanonicalizer;

import org.elasticsearch.xcontent.XContent;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentParserConfiguration;
import org.elasticsearch.xcontent.json.JsonStringEncoder;
import org.elasticsearch.xcontent.provider.cbor.CborXContentImpl;
import org.elasticsearch.xcontent.provider.json.ESJsonFactoryBuilder;
import org.elasticsearch.xcontent.provider.json.JsonStringEncoderImpl;
import org.elasticsearch.xcontent.provider.json.JsonXContentImpl;
import org.elasticsearch.xcontent.provider.smile.SmileXContentImpl;
import org.elasticsearch.xcontent.provider.yaml.YamlXContentImpl;
import org.elasticsearch.xcontent.spi.SymbolTable;
import org.elasticsearch.xcontent.spi.XContentProvider;

import java.io.IOException;
Expand Down Expand Up @@ -95,4 +103,51 @@ public XContentParserConfiguration empty() {
public JsonStringEncoder getJsonStringEncoder() {
return JsonStringEncoderImpl.getInstance();
}

private static final int features;

static {
final JsonFactory jsonFactory;
jsonFactory = XContentImplUtils.configure(new ESJsonFactoryBuilder());
jsonFactory.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true);
jsonFactory.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
jsonFactory.configure(JsonFactory.Feature.FAIL_ON_SYMBOL_HASH_OVERFLOW, false); // this trips on many mappings now...
// Do not automatically close unclosed objects/arrays in com.fasterxml.jackson.core.json.UTF8JsonGenerator#close() method
jsonFactory.configure(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT, false);
jsonFactory.configure(JsonParser.Feature.STRICT_DUPLICATE_DETECTION, true);
jsonFactory.configure(JsonParser.Feature.USE_FAST_DOUBLE_PARSER, true);
// keeping existing behavior of including source, for now
jsonFactory.configure(JsonParser.Feature.INCLUDE_SOURCE_IN_LOCATION, true);
features = jsonFactory.getFactoryFeatures();
}

private final transient ByteQuadsCanonicalizer canonicalizer = ByteQuadsCanonicalizer.createRoot();

private record ByteQuadsSymbolTable(ByteQuadsCanonicalizer child) implements SymbolTable {

@Override
public String findName(int[] quads, int qlen) {
return child.findName(quads, qlen);
}

@Override
public String addName(String newString, int[] quads, int qlen) {
try {
return child.addName(newString, quads, qlen);
} catch (StreamConstraintsException e) {
throw new RuntimeException(e);
}
}

@Override
public void close() {
child.release();
}
}

@Override
public SymbolTable newSymbolTable() {
ByteQuadsCanonicalizer child = canonicalizer.makeChild(features);
return new ByteQuadsSymbolTable(child);
}
}
Loading