Skip to content

Commit 2f6d2e9

Browse files
committed
Merge branch 'main' of https://github.com/elastic/elasticsearch into inlinestats_with_union_types
2 parents 12b7b19 + 0b70308 commit 2f6d2e9

File tree

720 files changed

+27204
-6954
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

720 files changed

+27204
-6954
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
steps:
2+
- label: ":pipeline: Generate steps"
3+
command: bash .buildkite/scripts/generate-pr-performance-benchmark.sh | buildkite-agent pipeline upload

.buildkite/pipelines/pull-request/performance-benchmark.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

.buildkite/pull-requests.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"set_commit_status": false,
2828
"build_on_commit": false,
2929
"build_on_comment": true,
30-
"trigger_comment_regex": "^(buildkite|@elastic(search)?machine) benchmark this with (?<benchmark>\\w+)( please)?$"
30+
"target_branch": "main",
31+
"trigger_comment_regex": "^(buildkite|@elastic(search)?machine) benchmark this with (?<benchmark>\\S+)( please)?$"
3132
}
3233
]
3334
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
env_id_baseline=$(python3 -c 'import uuid; print(uuid.uuid4())')
6+
env_id_contender=$(python3 -c 'import uuid; print(uuid.uuid4())')
7+
merge_base=$(git merge-base "${GITHUB_PR_TARGET_BRANCH}" HEAD)
8+
9+
buildkite-agent meta-data set pr_comment:custom-body:body \
10+
"This build attempted two ${GITHUB_PR_COMMENT_VAR_BENCHMARK} benchmarks to evaluate performance impact of this PR."
11+
buildkite-agent meta-data set pr_comment:custom-baseline:head \
12+
"* Baseline: ${merge_base} (env ID ${env_id_baseline})"
13+
buildkite-agent meta-data set pr_comment:custom-contender:head \
14+
"* Contender: ${GITHUB_PR_TRIGGERED_SHA} (env ID ${env_id_contender})"
15+
16+
cat << _EOF_
17+
steps:
18+
- label: Trigger baseline benchmark
19+
trigger: elasticsearch-performance-esbench-pr
20+
build:
21+
message: Baseline benchmark for PR${GITHUB_PR_NUMBER}
22+
branch: master
23+
env:
24+
CONFIGURATION_NAME: ${GITHUB_PR_COMMENT_VAR_BENCHMARK}
25+
ENV_ID: ${env_id_baseline}
26+
REVISION: ${merge_base}
27+
- label: Trigger contender benchmark
28+
trigger: elasticsearch-performance-esbench-pr
29+
build:
30+
message: Contender benchmark for PR${GITHUB_PR_NUMBER}
31+
branch: master
32+
env:
33+
CONFIGURATION_NAME: ${GITHUB_PR_COMMENT_VAR_BENCHMARK}
34+
ENV_ID: ${env_id_contender}
35+
ES_REPO_URL: https://github.com/${GITHUB_PR_OWNER}/${GITHUB_PR_REPO}.git
36+
REVISION: ${GITHUB_PR_TRIGGERED_SHA}
37+
- wait: ~
38+
- label: Modify PR comment
39+
command: buildkite-agent meta-data set pr_comment:custom-comparison:head "* [Benchmark results](<https://esbench-metrics.kb.us-east-2.aws.elastic-cloud.com:9243/app/dashboards#/view/d9079962-5866-49ef-b9f5-145f2141cd31?_a=(query:(language:kuery,query:'user-tags.env-id:${env_id_baseline} or user-tags.env-id:${env_id_contender}'))>)"
40+
_EOF_

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11

2+
# claude
3+
.claude
4+
25
# intellij files
36
.idea/
47
*.iml

benchmarks/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ dependencies {
4747
api(project(':x-pack:plugin:core'))
4848
api(project(':x-pack:plugin:esql'))
4949
api(project(':x-pack:plugin:esql:compute'))
50+
api(project(':x-pack:plugin:mapper-exponential-histogram'))
5051
implementation project(path: ':libs:native')
5152
implementation project(path: ':libs:simdvec')
5253
implementation project(path: ':libs:exponential-histogram')

benchmarks/src/main/java/org/elasticsearch/benchmark/_nightly/esql/ValuesSourceReaderBenchmark.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,26 @@ static void selfTest() {
142142
private static List<ValuesSourceReaderOperator.FieldInfo> fields(String name) {
143143
return switch (name) {
144144
case "3_stored_keywords" -> List.of(
145-
new ValuesSourceReaderOperator.FieldInfo("keyword_1", ElementType.BYTES_REF, shardIdx -> blockLoader("stored_keyword_1")),
146-
new ValuesSourceReaderOperator.FieldInfo("keyword_2", ElementType.BYTES_REF, shardIdx -> blockLoader("stored_keyword_2")),
147-
new ValuesSourceReaderOperator.FieldInfo("keyword_3", ElementType.BYTES_REF, shardIdx -> blockLoader("stored_keyword_3"))
145+
new ValuesSourceReaderOperator.FieldInfo(
146+
"keyword_1",
147+
ElementType.BYTES_REF,
148+
false,
149+
shardIdx -> blockLoader("stored_keyword_1")
150+
),
151+
new ValuesSourceReaderOperator.FieldInfo(
152+
"keyword_2",
153+
ElementType.BYTES_REF,
154+
false,
155+
shardIdx -> blockLoader("stored_keyword_2")
156+
),
157+
new ValuesSourceReaderOperator.FieldInfo(
158+
"keyword_3",
159+
ElementType.BYTES_REF,
160+
false,
161+
shardIdx -> blockLoader("stored_keyword_3")
162+
)
148163
);
149-
default -> List.of(new ValuesSourceReaderOperator.FieldInfo(name, elementType(name), shardIdx -> blockLoader(name)));
164+
default -> List.of(new ValuesSourceReaderOperator.FieldInfo(name, elementType(name), false, shardIdx -> blockLoader(name)));
150165
};
151166
}
152167

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.benchmark.common.network;
11+
12+
import org.elasticsearch.common.network.InetAddresses;
13+
import org.elasticsearch.xcontent.Text;
14+
import org.elasticsearch.xcontent.XContentString;
15+
import org.openjdk.jmh.annotations.Benchmark;
16+
import org.openjdk.jmh.annotations.BenchmarkMode;
17+
import org.openjdk.jmh.annotations.Fork;
18+
import org.openjdk.jmh.annotations.Measurement;
19+
import org.openjdk.jmh.annotations.Mode;
20+
import org.openjdk.jmh.annotations.OutputTimeUnit;
21+
import org.openjdk.jmh.annotations.Param;
22+
import org.openjdk.jmh.annotations.Scope;
23+
import org.openjdk.jmh.annotations.Setup;
24+
import org.openjdk.jmh.annotations.State;
25+
import org.openjdk.jmh.annotations.Warmup;
26+
import org.openjdk.jmh.infra.Blackhole;
27+
28+
import java.net.InetAddress;
29+
import java.net.UnknownHostException;
30+
import java.util.Random;
31+
import java.util.concurrent.TimeUnit;
32+
33+
@Warmup(iterations = 2)
34+
@Measurement(iterations = 3)
35+
@BenchmarkMode(Mode.Throughput)
36+
@OutputTimeUnit(TimeUnit.SECONDS)
37+
@State(Scope.Benchmark)
38+
@Fork(1)
39+
public class IpAddressesBenchmarks {
40+
41+
@Param("1000")
42+
private int size;
43+
private String[] ipV6Addresses;
44+
private String[] ipV4Addresses;
45+
private XContentString[] ipV6AddressesBytes;
46+
private XContentString[] ipV4AddressesBytes;
47+
48+
@Setup
49+
public void setup() throws UnknownHostException {
50+
Random random = new Random();
51+
ipV6Addresses = new String[size];
52+
ipV4Addresses = new String[size];
53+
ipV6AddressesBytes = new XContentString[size];
54+
ipV4AddressesBytes = new XContentString[size];
55+
byte[] ipv6Bytes = new byte[16];
56+
byte[] ipv4Bytes = new byte[4];
57+
for (int i = 0; i < size; i++) {
58+
random.nextBytes(ipv6Bytes);
59+
random.nextBytes(ipv4Bytes);
60+
String ipv6String = InetAddresses.toAddrString(InetAddress.getByAddress(ipv6Bytes));
61+
String ipv4String = InetAddresses.toAddrString(InetAddress.getByAddress(ipv4Bytes));
62+
ipV6Addresses[i] = ipv6String;
63+
ipV4Addresses[i] = ipv4String;
64+
ipV6AddressesBytes[i] = new Text(ipv6String);
65+
ipV4AddressesBytes[i] = new Text(ipv4String);
66+
}
67+
}
68+
69+
@Benchmark
70+
public boolean isInetAddressIpv6() {
71+
boolean b = true;
72+
for (int i = 0; i < size; i++) {
73+
b ^= InetAddresses.isInetAddress(ipV6Addresses[i]);
74+
}
75+
return b;
76+
}
77+
78+
@Benchmark
79+
public boolean isInetAddressIpv4() {
80+
boolean b = true;
81+
for (int i = 0; i < size; i++) {
82+
b ^= InetAddresses.isInetAddress(ipV4Addresses[i]);
83+
}
84+
return b;
85+
}
86+
87+
@Benchmark
88+
public void getIpOrHostIpv6(Blackhole blackhole) {
89+
for (int i = 0; i < size; i++) {
90+
blackhole.consume(InetAddresses.getIpOrHost(ipV6Addresses[i]));
91+
}
92+
}
93+
94+
@Benchmark
95+
public void getIpOrHostIpv4(Blackhole blackhole) {
96+
for (int i = 0; i < size; i++) {
97+
blackhole.consume(InetAddresses.forString(ipV4Addresses[i]));
98+
}
99+
}
100+
101+
@Benchmark
102+
public void forStringIpv6String(Blackhole blackhole) {
103+
for (int i = 0; i < size; i++) {
104+
blackhole.consume(InetAddresses.forString(ipV6Addresses[i]));
105+
}
106+
}
107+
108+
@Benchmark
109+
public void forStringIpv4String(Blackhole blackhole) {
110+
for (int i = 0; i < size; i++) {
111+
blackhole.consume(InetAddresses.forString(ipV4Addresses[i]));
112+
}
113+
}
114+
115+
@Benchmark
116+
public void forStringIpv6Bytes(Blackhole blackhole) {
117+
for (int i = 0; i < size; i++) {
118+
blackhole.consume(InetAddresses.forString(ipV6AddressesBytes[i].bytes()));
119+
}
120+
}
121+
122+
@Benchmark
123+
public void forStringIpv4Bytes(Blackhole blackhole) {
124+
for (int i = 0; i < size; i++) {
125+
blackhole.consume(InetAddresses.forString(ipV4AddressesBytes[i].bytes()));
126+
}
127+
}
128+
129+
@Benchmark
130+
public void encodeAsIpv6WithIpv6(Blackhole blackhole) {
131+
for (int i = 0; i < size; i++) {
132+
blackhole.consume(InetAddresses.encodeAsIpv6(ipV6AddressesBytes[i]));
133+
}
134+
}
135+
136+
@Benchmark
137+
public void encodeAsIpv6WithIpv4(Blackhole blackhole) {
138+
for (int i = 0; i < size; i++) {
139+
blackhole.consume(InetAddresses.encodeAsIpv6(ipV4AddressesBytes[i]));
140+
}
141+
}
142+
}

benchmarks/src/main/java/org/elasticsearch/benchmark/exponentialhistogram/ExponentialHistogramMergeBench.java

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,15 @@
99

1010
package org.elasticsearch.benchmark.exponentialhistogram;
1111

12+
import org.apache.lucene.util.BytesRef;
13+
import org.elasticsearch.common.io.stream.BytesStreamOutput;
1214
import org.elasticsearch.exponentialhistogram.BucketIterator;
1315
import org.elasticsearch.exponentialhistogram.ExponentialHistogram;
1416
import org.elasticsearch.exponentialhistogram.ExponentialHistogramCircuitBreaker;
1517
import org.elasticsearch.exponentialhistogram.ExponentialHistogramGenerator;
1618
import org.elasticsearch.exponentialhistogram.ExponentialHistogramMerger;
19+
import org.elasticsearch.xpack.exponentialhistogram.CompressedExponentialHistogram;
20+
import org.elasticsearch.xpack.exponentialhistogram.IndexWithCount;
1721
import org.openjdk.jmh.annotations.Benchmark;
1822
import org.openjdk.jmh.annotations.BenchmarkMode;
1923
import org.openjdk.jmh.annotations.Fork;
@@ -27,6 +31,8 @@
2731
import org.openjdk.jmh.annotations.Threads;
2832
import org.openjdk.jmh.annotations.Warmup;
2933

34+
import java.io.IOException;
35+
import java.util.ArrayList;
3036
import java.util.List;
3137
import java.util.Random;
3238
import java.util.concurrent.ThreadLocalRandom;
@@ -47,6 +53,9 @@ public class ExponentialHistogramMergeBench {
4753
@Param({ "0.01", "0.1", "0.25", "0.5", "1.0", "2.0" })
4854
double mergedHistoSizeFactor;
4955

56+
@Param({ "array-backed", "compressed" })
57+
String histoImplementation;
58+
5059
Random random;
5160
ExponentialHistogramMerger histoMerger;
5261

@@ -81,16 +90,54 @@ public void setUp() {
8190
bucketIndex += 1 + random.nextInt(bucketCount) % (Math.max(1, bucketCount / dataPointSize));
8291
generator.add(Math.pow(1.001, bucketIndex));
8392
}
84-
toMerge[i] = generator.getAndClear();
85-
cnt = getBucketCount(toMerge[i]);
93+
ExponentialHistogram histogram = generator.getAndClear();
94+
cnt = getBucketCount(histogram);
8695
if (cnt < dataPointSize) {
87-
throw new IllegalArgumentException("Expected bucket count to be " + dataPointSize + ", but was " + cnt);
96+
throw new IllegalStateException("Expected bucket count to be " + dataPointSize + ", but was " + cnt);
97+
}
98+
99+
if ("array-backed".equals(histoImplementation)) {
100+
toMerge[i] = histogram;
101+
} else if ("compressed".equals(histoImplementation)) {
102+
toMerge[i] = asCompressedHistogram(histogram);
103+
} else {
104+
throw new IllegalArgumentException("Unknown implementation: " + histoImplementation);
88105
}
89106
}
90107

91108
index = 0;
92109
}
93110

111+
private ExponentialHistogram asCompressedHistogram(ExponentialHistogram histogram) {
112+
List<IndexWithCount> negativeBuckets = new ArrayList<>();
113+
List<IndexWithCount> positiveBuckets = new ArrayList<>();
114+
115+
BucketIterator it = histogram.negativeBuckets().iterator();
116+
while (it.hasNext()) {
117+
negativeBuckets.add(new IndexWithCount(it.peekIndex(), it.peekCount()));
118+
it.advance();
119+
}
120+
it = histogram.positiveBuckets().iterator();
121+
while (it.hasNext()) {
122+
positiveBuckets.add(new IndexWithCount(it.peekIndex(), it.peekCount()));
123+
it.advance();
124+
}
125+
126+
long totalCount = histogram.zeroBucket().count() + histogram.negativeBuckets().valueCount() + histogram.positiveBuckets()
127+
.valueCount();
128+
BytesStreamOutput histoBytes = new BytesStreamOutput();
129+
try {
130+
CompressedExponentialHistogram.writeHistogramBytes(histoBytes, histogram.scale(), negativeBuckets, positiveBuckets);
131+
CompressedExponentialHistogram result = new CompressedExponentialHistogram();
132+
BytesRef data = histoBytes.bytes().toBytesRef();
133+
result.reset(histogram.zeroBucket().zeroThreshold(), totalCount, data);
134+
return result;
135+
} catch (IOException e) {
136+
throw new RuntimeException(e);
137+
}
138+
139+
}
140+
94141
private static int getBucketCount(ExponentialHistogram histo) {
95142
int cnt = 0;
96143
for (BucketIterator it : List.of(histo.negativeBuckets().iterator(), histo.positiveBuckets().iterator())) {

benchmarks/src/main/java/org/elasticsearch/benchmark/index/codec/tsdb/TSDBDocValuesMergeBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ private static IndexWriterConfig createIndexWriterConfig(boolean optimizedMergeE
258258
);
259259
config.setLeafSorter(DataStream.TIMESERIES_LEAF_READERS_SORTER);
260260
config.setMergePolicy(new LogByteSizeMergePolicy());
261-
var docValuesFormat = new ES819TSDBDocValuesFormat(4096, optimizedMergeEnabled);
261+
var docValuesFormat = new ES819TSDBDocValuesFormat(4096, 512, optimizedMergeEnabled);
262262
config.setCodec(new Elasticsearch900Lucene101Codec() {
263263

264264
@Override

0 commit comments

Comments
 (0)