Skip to content

Commit 072ba91

Browse files
authored
Merge branch 'main' into 2025/04/07/remove-TransportResponse-Empty
2 parents 993826b + 894d92a commit 072ba91

File tree

98 files changed

+1545
-203
lines changed

Some content is hidden

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

98 files changed

+1545
-203
lines changed

benchmarks/README.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,21 @@ To get realistic results, you should exercise care when running benchmarks. Here
8282
NOTE: Linux only. Sorry Mac and Windows.
8383

8484
Disassembling is fun! Maybe not always useful, but always fun! Generally, you'll want to install `perf` and the JDK's `hsdis`.
85-
`perf` is generally available via `apg-get install perf` or `pacman -S perf`. `hsdis` you'll want to compile from source. is a little more involved. This worked
85+
`perf` is generally available via `apg-get install perf` or `pacman -S perf linux-tools`. `hsdis` you'll want to compile from source. is a little more involved. This worked
8686
on 2020-08-01:
8787

8888
```
8989
git clone [email protected]:openjdk/jdk.git
9090
cd jdk
91-
git checkout jdk-17-ga
92-
cd src/utils/hsdis
91+
git checkout jdk-24-ga
9392
# Get a known good binutils
9493
wget https://ftp.gnu.org/gnu/binutils/binutils-2.35.tar.gz
9594
tar xf binutils-2.35.tar.gz
96-
make BINUTILS=binutils-2.35 ARCH=amd64
97-
sudo cp build/linux-amd64/hsdis-amd64.so /usr/lib/jvm/java-17-openjdk/lib/server/
95+
bash configure --with-hsdis=binutils --with-binutils-src=binutils-2.35 \
96+
--with-boot-jdk=~/.gradle/jdks/oracle_corporation-24-amd64-linux.2
97+
make build-hsdis
98+
cp ./build/linux-x86_64-server-release/jdk/lib/hsdis-amd64.so \
99+
~/.gradle/jdks/oracle_corporation-24-amd64-linux.2/lib/hsdis.so
98100
```
99101

100102
If you want to disassemble a single method do something like this:
@@ -105,6 +107,30 @@ gradlew -p benchmarks run --args ' MemoryStatsBenchmark -jvmArgs "-XX:+UnlockDia
105107

106108
If you want `perf` to find the hot methods for you, then do add `-prof perfasm`.
107109

110+
NOTE: `perfasm` will need more access:
111+
```
112+
sudo bash
113+
echo -1 > /proc/sys/kernel/perf_event_paranoid
114+
exit
115+
```
116+
117+
If you get warnings like:
118+
```
119+
The perf event count is suspiciously low (0).
120+
```
121+
then check if you are bumping into [this](https://man.archlinux.org/man/perf-stat.1.en#INTEL_HYBRID_SUPPORT)
122+
by running:
123+
```
124+
perf stat -B dd if=/dev/zero of=/dev/null count=1000000
125+
```
126+
127+
If you see lines like:
128+
```
129+
765019980 cpu_atom/cycles/ # 1.728 GHz (0.60%)
130+
2258845959 cpu_core/cycles/ # 5.103 GHz (99.18%)
131+
```
132+
then `perf` is just not going to work for you.
133+
108134
## Async Profiler
109135

110136
Note: Linux and Mac only. Sorry Windows.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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.compute.operator;
11+
12+
import org.apache.lucene.document.InetAddressPoint;
13+
import org.apache.lucene.util.BytesRef;
14+
import org.elasticsearch.common.breaker.NoopCircuitBreaker;
15+
import org.elasticsearch.common.network.InetAddresses;
16+
import org.elasticsearch.compute.operator.BreakingBytesRefBuilder;
17+
import org.elasticsearch.xpack.esql.expression.function.scalar.convert.ParseIp;
18+
import org.openjdk.jmh.annotations.Benchmark;
19+
import org.openjdk.jmh.annotations.BenchmarkMode;
20+
import org.openjdk.jmh.annotations.Fork;
21+
import org.openjdk.jmh.annotations.Measurement;
22+
import org.openjdk.jmh.annotations.Mode;
23+
import org.openjdk.jmh.annotations.OutputTimeUnit;
24+
import org.openjdk.jmh.annotations.Scope;
25+
import org.openjdk.jmh.annotations.State;
26+
import org.openjdk.jmh.annotations.Warmup;
27+
28+
import java.net.InetAddress;
29+
import java.util.concurrent.TimeUnit;
30+
31+
@Warmup(iterations = 5)
32+
@Measurement(iterations = 7)
33+
@BenchmarkMode(Mode.AverageTime)
34+
@OutputTimeUnit(TimeUnit.NANOSECONDS)
35+
@State(Scope.Thread)
36+
@Fork(1)
37+
public class ParseIpBenchmark {
38+
private final BytesRef ip = new BytesRef("192.168.0.1");
39+
private final BreakingBytesRefBuilder scratch = ParseIp.buildScratch(new NoopCircuitBreaker("request"));
40+
41+
@Benchmark
42+
public BytesRef leadingZerosRejected() {
43+
return ParseIp.leadingZerosRejected(ip, scratch);
44+
}
45+
46+
@Benchmark
47+
public BytesRef leadingZerosAreDecimal() {
48+
return ParseIp.leadingZerosAreDecimal(ip, scratch);
49+
}
50+
51+
@Benchmark
52+
public BytesRef leadingZerosAreOctal() {
53+
return ParseIp.leadingZerosAreOctal(ip, scratch);
54+
}
55+
56+
@Benchmark
57+
public BytesRef original() {
58+
InetAddress inetAddress = InetAddresses.forString(ip.utf8ToString());
59+
return new BytesRef(InetAddressPoint.encode(inetAddress));
60+
}
61+
}

docs/changelog/126237.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 126237
2+
summary: Use `FallbackSyntheticSourceBlockLoader` for text fields
3+
area: Mapping
4+
type: enhancement
5+
issues: []

docs/changelog/126338.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 126338
2+
summary: Speed up TO_IP
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

server/src/main/java/org/elasticsearch/action/datastreams/autosharding/DataStreamAutoShardingService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public String toString() {
313313
return Strings.format(
314314
"For data stream %s: %s based on [inc/dec cooldowns %s/%s, %d-%d threads, "
315315
+ "write index %s has all-time/recent/peak loads %g/%g/%g, current shards %d, "
316-
+ "using %s value %g for increase gives %d shards%s]",
316+
+ "increase calculation gives %d shards using %s load %g for write index%s]",
317317
inputs.dataStream,
318318
result,
319319
inputs.increaseShardsCooldown,
@@ -325,19 +325,19 @@ public String toString() {
325325
inputs.writeIndexRecentLoad,
326326
inputs.writeIndexPeakLoad,
327327
inputs.currentNumberOfWriteIndexShards,
328+
increaseCalculation.optimalShardCountForIncrease,
328329
inputs.increaseShardsMetric,
329330
increaseCalculation.writeIndexLoadForIncrease,
330-
increaseCalculation.optimalShardCountForIncrease,
331331
decreaseCalculation == null
332332
? ""
333333
: Strings.format(
334-
", and using %s value %g for dec based on %s gives %d shards",
334+
", decrease calculation gives %d shards using %s load %g for %s",
335+
decreaseCalculation.optimalShardCountForDecrease,
335336
inputs.decreaseShardsMetric,
336337
decreaseCalculation.maxLoadWithinCooldown.load,
337338
decreaseCalculation.maxLoadWithinCooldown.previousIndexWithMaxLoad != null
338339
? decreaseCalculation.maxLoadWithinCooldown.previousIndexWithMaxLoad
339-
: "write index",
340-
decreaseCalculation.optimalShardCountForDecrease
340+
: "write index"
341341
)
342342
);
343343
}

server/src/main/java/org/elasticsearch/index/mapper/TextFieldMapper.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
import org.elasticsearch.search.aggregations.support.CoreValuesSourceType;
7575
import org.elasticsearch.xcontent.ToXContent;
7676
import org.elasticsearch.xcontent.XContentBuilder;
77+
import org.elasticsearch.xcontent.XContentParser;
7778

7879
import java.io.IOException;
7980
import java.util.ArrayList;
@@ -1016,10 +1017,53 @@ protected String delegatingTo() {
10161017
if (isStored()) {
10171018
return new BlockStoredFieldsReader.BytesFromStringsBlockLoader(name());
10181019
}
1020+
1021+
// _ignored_source field will only be present if text field is not stored
1022+
// and there is no syntheticSourceDelegate
1023+
if (isSyntheticSource && syntheticSourceDelegate == null) {
1024+
return fallbackSyntheticSourceBlockLoader();
1025+
}
1026+
10191027
SourceValueFetcher fetcher = SourceValueFetcher.toString(blContext.sourcePaths(name()));
10201028
return new BlockSourceReader.BytesRefsBlockLoader(fetcher, blockReaderDisiLookup(blContext));
10211029
}
10221030

1031+
FallbackSyntheticSourceBlockLoader fallbackSyntheticSourceBlockLoader() {
1032+
var reader = new FallbackSyntheticSourceBlockLoader.SingleValueReader<BytesRef>(null) {
1033+
@Override
1034+
public void convertValue(Object value, List<BytesRef> accumulator) {
1035+
if (value != null) {
1036+
accumulator.add(new BytesRef(value.toString()));
1037+
}
1038+
}
1039+
1040+
@Override
1041+
protected void parseNonNullValue(XContentParser parser, List<BytesRef> accumulator) throws IOException {
1042+
var text = parser.textOrNull();
1043+
1044+
if (text != null) {
1045+
accumulator.add(new BytesRef(text));
1046+
}
1047+
}
1048+
1049+
@Override
1050+
public void writeToBlock(List<BytesRef> values, BlockLoader.Builder blockBuilder) {
1051+
var bytesRefBuilder = (BlockLoader.BytesRefBuilder) blockBuilder;
1052+
1053+
for (var value : values) {
1054+
bytesRefBuilder.appendBytesRef(value);
1055+
}
1056+
}
1057+
};
1058+
1059+
return new FallbackSyntheticSourceBlockLoader(reader, name()) {
1060+
@Override
1061+
public Builder builder(BlockFactory factory, int expectedCount) {
1062+
return factory.bytesRefs(expectedCount);
1063+
}
1064+
};
1065+
}
1066+
10231067
/**
10241068
* Build an iterator of documents that have the field. This mirrors parseCreateField,
10251069
* using whatever

0 commit comments

Comments
 (0)