Skip to content

Commit 514b536

Browse files
Merge branch 'main' into rest_handlers_services
2 parents 645ec6c + 7a1f15c commit 514b536

File tree

478 files changed

+22029
-6397
lines changed

Some content is hidden

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

478 files changed

+22029
-6397
lines changed

benchmarks/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ tasks.register("copyPainless", Copy) {
9595

9696
tasks.named("run").configure {
9797
executable = "${buildParams.runtimeJavaHome.get()}/bin/java" + (OS.current() == OS.WINDOWS ? '.exe' : '')
98-
args << "-Dplugins.dir=${buildDir}/plugins" << "-Dtests.index=${buildDir}/index"
9998
dependsOn "copyExpression", "copyPainless", configurations.nativeLib
99+
systemProperty 'plugins.dir', "${buildDir}/plugins"
100+
systemProperty 'tests.index', "${buildDir}/index"
100101
systemProperty 'es.nativelibs.path', TestUtil.getTestLibraryPath(file("../libs/native/libraries/build/platform/").toString())
101102
}
102103

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import org.elasticsearch.index.mapper.MappingLookup;
6060
import org.elasticsearch.index.mapper.NumberFieldMapper;
6161
import org.elasticsearch.index.mapper.blockloader.BlockLoaderFunctionConfig;
62+
import org.elasticsearch.index.mapper.blockloader.Warnings;
6263
import org.elasticsearch.search.lookup.SearchLookup;
6364
import org.elasticsearch.xpack.esql.planner.PlannerSettings;
6465
import org.elasticsearch.xpack.esql.plugin.EsqlPlugin;
@@ -161,27 +162,27 @@ private static List<ValuesSourceReaderOperator.FieldInfo> fields(String name) {
161162
"keyword_1",
162163
ElementType.BYTES_REF,
163164
false,
164-
shardIdx -> ValuesSourceReaderOperator.load(blockLoader("stored_keyword_1"))
165+
(ctx, shardIdx) -> ValuesSourceReaderOperator.load(blockLoader("stored_keyword_1"))
165166
),
166167
new ValuesSourceReaderOperator.FieldInfo(
167168
"keyword_2",
168169
ElementType.BYTES_REF,
169170
false,
170-
shardIdx -> ValuesSourceReaderOperator.load(blockLoader("stored_keyword_2"))
171+
(ctx, shardIdx) -> ValuesSourceReaderOperator.load(blockLoader("stored_keyword_2"))
171172
),
172173
new ValuesSourceReaderOperator.FieldInfo(
173174
"keyword_3",
174175
ElementType.BYTES_REF,
175176
false,
176-
shardIdx -> ValuesSourceReaderOperator.load(blockLoader("stored_keyword_3"))
177+
(ctx, shardIdx) -> ValuesSourceReaderOperator.load(blockLoader("stored_keyword_3"))
177178
)
178179
);
179180
default -> List.of(
180181
new ValuesSourceReaderOperator.FieldInfo(
181182
name,
182183
elementType(name),
183184
false,
184-
shardIdx -> ValuesSourceReaderOperator.load(blockLoader(name))
185+
(ctx, shardIdx) -> ValuesSourceReaderOperator.load(blockLoader(name))
185186
)
186187
);
187188
};
@@ -633,6 +634,11 @@ public BlockLoaderFunctionConfig blockLoaderFunctionConfig() {
633634
return null;
634635
}
635636

637+
@Override
638+
public Warnings warnings() {
639+
return null;
640+
}
641+
636642
@Override
637643
public ByteSizeValue ordinalsByteSize() {
638644
return DEFAULT_ORDINALS_BYTE_SIZE;

benchmarks/src/main/java/org/elasticsearch/benchmark/common/lucene/BytesRefCodePointCountBenchmark.java

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

benchmarks/src/main/java/org/elasticsearch/benchmark/compute/operator/ParallelParsingBenchmark.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import java.nio.charset.StandardCharsets;
5050
import java.time.Instant;
5151
import java.util.List;
52+
import java.util.Locale;
5253
import java.util.Map;
5354
import java.util.concurrent.ExecutorService;
5455
import java.util.concurrent.Executors;
@@ -91,7 +92,7 @@ public class ParallelParsingBenchmark {
9192
public void setup() {
9293
StringBuilder sb = new StringBuilder();
9394
for (int i = 0; i < lineCount; i++) {
94-
sb.append("line-").append(String.format("%08d", i)).append(",value-").append(i % 1000).append("\n");
95+
sb.append("line-").append(String.format(Locale.ROOT, "%08d", i)).append(",value-").append(i % 1000).append("\n");
9596
}
9697
fileData = sb.toString().getBytes(StandardCharsets.UTF_8);
9798
executor = Executors.newFixedThreadPool(Math.max(parallelism, 1));

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.apache.lucene.util.BytesRef;
2727
import org.elasticsearch.benchmark.Utils;
2828
import org.elasticsearch.cluster.metadata.DataStream;
29-
import org.elasticsearch.index.codec.Elasticsearch92Lucene103Codec;
29+
import org.elasticsearch.index.codec.Elasticsearch93Lucene104Codec;
3030
import org.elasticsearch.index.codec.tsdb.BinaryDVCompressionMode;
3131
import org.elasticsearch.index.codec.tsdb.es819.ES819Version3TSDBDocValuesFormat;
3232
import org.openjdk.jmh.annotations.Benchmark;
@@ -266,7 +266,7 @@ private static IndexWriterConfig createIndexWriterConfig(boolean optimizedMergeE
266266
true,
267267
NUMERIC_LARGE_BLOCK_SHIFT
268268
);
269-
config.setCodec(new Elasticsearch92Lucene103Codec() {
269+
config.setCodec(new Elasticsearch93Lucene104Codec() {
270270
@Override
271271
public DocValuesFormat getDocValuesFormatForField(String field) {
272272
return docValuesFormat;
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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.script;
11+
12+
import org.elasticsearch.benchmark.Utils;
13+
import org.elasticsearch.common.settings.Settings;
14+
import org.elasticsearch.plugins.ExtensiblePlugin;
15+
import org.elasticsearch.plugins.ScriptPlugin;
16+
import org.elasticsearch.script.IngestConditionalScript;
17+
import org.elasticsearch.script.ScriptEngine;
18+
import org.elasticsearch.script.ScriptModule;
19+
import org.openjdk.jmh.annotations.Benchmark;
20+
import org.openjdk.jmh.annotations.BenchmarkMode;
21+
import org.openjdk.jmh.annotations.Fork;
22+
import org.openjdk.jmh.annotations.Measurement;
23+
import org.openjdk.jmh.annotations.Mode;
24+
import org.openjdk.jmh.annotations.OutputTimeUnit;
25+
import org.openjdk.jmh.annotations.Param;
26+
import org.openjdk.jmh.annotations.Scope;
27+
import org.openjdk.jmh.annotations.Setup;
28+
import org.openjdk.jmh.annotations.State;
29+
import org.openjdk.jmh.annotations.Warmup;
30+
31+
import java.io.IOException;
32+
import java.net.URL;
33+
import java.net.URLClassLoader;
34+
import java.nio.file.Files;
35+
import java.nio.file.Path;
36+
import java.util.HashMap;
37+
import java.util.List;
38+
import java.util.Map;
39+
import java.util.concurrent.TimeUnit;
40+
import java.util.stream.Collectors;
41+
42+
/**
43+
* Benchmarks the common Painless pattern of {@code ['a','b','c'].contains(x)}
44+
* used pervasively in ingest pipeline {@code if:} conditions.
45+
*
46+
* Measures baseline performance across a matrix of list sizes and hit/miss lookups.
47+
*/
48+
@Fork(2)
49+
@Warmup(iterations = 5)
50+
@Measurement(iterations = 5)
51+
@BenchmarkMode(Mode.AverageTime)
52+
@OutputTimeUnit(TimeUnit.NANOSECONDS)
53+
@State(Scope.Benchmark)
54+
public class PainlessListContainsBenchmark {
55+
56+
static {
57+
Utils.configureBenchmarkLogging();
58+
}
59+
60+
private static final List<String> WORDS = List.of(
61+
"alfa",
62+
"bravo",
63+
"charlie",
64+
"delta",
65+
"echo",
66+
"foxtrot",
67+
"golf",
68+
"hotel",
69+
"india",
70+
"juliett",
71+
"kilo",
72+
"lima",
73+
"mike",
74+
"november",
75+
"oscar",
76+
"papa",
77+
"quebec",
78+
"romeo",
79+
"sierra",
80+
"tango",
81+
"uniform",
82+
"victor",
83+
"whiskey",
84+
"xray",
85+
"yankee",
86+
"zulu",
87+
"one",
88+
"two",
89+
"three",
90+
"four",
91+
"five",
92+
"six",
93+
"seven",
94+
"eight",
95+
"nine",
96+
"ten",
97+
"eleven",
98+
"twelve",
99+
"thirteen",
100+
"fourteen"
101+
);
102+
103+
private static final String MISS_WORD = "ZZZNOTFOUND";
104+
105+
@Param({ "5", "15", "40" })
106+
private int listSize;
107+
108+
@Param({ "hit", "miss" })
109+
private String mode;
110+
111+
private IngestConditionalScript script;
112+
113+
@Setup
114+
public void setup() throws Exception {
115+
ScriptEngine engine = loadPainlessEngine();
116+
117+
List<String> words = WORDS.subList(0, listSize);
118+
119+
String listLiteral = words.stream().map(w -> "'" + w + "'").collect(Collectors.joining(", ", "[", "]"));
120+
String source = listLiteral + ".contains(params.target)";
121+
122+
IngestConditionalScript.Factory factory = engine.compile("bench", source, IngestConditionalScript.CONTEXT, Map.of());
123+
124+
String target = "hit".equals(mode) ? words.get(words.size() - 1) : MISS_WORD;
125+
Map<String, Object> params = new HashMap<>();
126+
params.put("target", target);
127+
128+
Map<String, Object> ctxMap = new HashMap<>();
129+
ctxMap.put("message", "test");
130+
131+
script = factory.newInstance(params, ctxMap);
132+
}
133+
134+
@Benchmark
135+
public boolean benchmark() {
136+
return script.execute();
137+
}
138+
139+
private static ScriptEngine loadPainlessEngine() throws Exception {
140+
Path pluginDir = Path.of(System.getProperty("plugins.dir"), "painless");
141+
URL[] jarUrls;
142+
try (var stream = Files.walk(pluginDir)) {
143+
jarUrls = stream.filter(p -> p.toString().endsWith(".jar")).map(p -> {
144+
try {
145+
return p.toUri().toURL();
146+
} catch (IOException e) {
147+
throw new RuntimeException(e);
148+
}
149+
}).toArray(URL[]::new);
150+
}
151+
URLClassLoader loader = URLClassLoader.newInstance(jarUrls, PainlessListContainsBenchmark.class.getClassLoader());
152+
Class<?> pluginClass = loader.loadClass("org.elasticsearch.painless.PainlessPlugin");
153+
Object plugin = pluginClass.getDeclaredConstructor().newInstance();
154+
((ExtensiblePlugin) plugin).loadExtensions(new ExtensiblePlugin.ExtensionLoader() {
155+
@Override
156+
public <T> List<T> loadExtensions(Class<T> extensionPointType) {
157+
return List.of();
158+
}
159+
});
160+
ScriptPlugin scriptPlugin = (ScriptPlugin) plugin;
161+
ScriptModule scriptModule = new ScriptModule(Settings.EMPTY, List.of(scriptPlugin));
162+
return scriptModule.engines.get("painless");
163+
}
164+
}

0 commit comments

Comments
 (0)