Skip to content

Commit d48d11d

Browse files
Merge branch 'main' into es-gpu
2 parents f926084 + e0c4132 commit d48d11d

File tree

27 files changed

+1282
-119
lines changed

27 files changed

+1282
-119
lines changed

build-tools/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchCluster.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
public class ElasticsearchCluster implements TestClusterConfiguration, Named {
6565

6666
private static final Logger LOGGER = Logging.getLogger(ElasticsearchNode.class);
67-
private static final int CLUSTER_UP_TIMEOUT = 40;
67+
private static final int CLUSTER_UP_TIMEOUT = 120;
6868
private static final TimeUnit CLUSTER_UP_TIMEOUT_UNIT = TimeUnit.SECONDS;
6969

7070
private final AtomicBoolean configurationFrozen = new AtomicBoolean(false);

docs/changelog/135262.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 135262
2+
summary: Add usage stats for `semantic_text` fields
3+
area: "Vector Search"
4+
type: enhancement
5+
issues: []

docs/changelog/135635.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 135635
2+
summary: Add executor name attribute to cache miss metrics
3+
area: Search
4+
type: enhancement
5+
issues: []

muted-tests.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,6 @@ tests:
588588
- class: org.elasticsearch.xpack.esql.qa.single_node.EsqlSpecIT
589589
method: test {csv-spec:spatial_shapes.ConvertCartesianShapeFromStringParseError}
590590
issue: https://github.com/elastic/elasticsearch/issues/135455
591-
- class: org.elasticsearch.xpack.esql.qa.multi_node.GenerativeIT
592-
method: test
593-
issue: https://github.com/elastic/elasticsearch/issues/134407
594591
- class: org.elasticsearch.cluster.routing.allocation.decider.RestoreInProgressAllocationDeciderTests
595592
method: testCanAllocatePrimaryExistingInRestoreInProgress
596593
issue: https://github.com/elastic/elasticsearch/issues/135566
@@ -603,9 +600,6 @@ tests:
603600
- class: org.elasticsearch.xpack.esql.heap_attack.HeapAttackIT
604601
method: testAggTooManyMvLongs
605602
issue: https://github.com/elastic/elasticsearch/issues/135585
606-
- class: org.elasticsearch.xpack.esql.qa.single_node.GenerativeIT
607-
method: test
608-
issue: https://github.com/elastic/elasticsearch/issues/134407
609603

610604
# Examples:
611605
#
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9182000
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
index_reshard_shardcount_small,9181000
1+
inference_telemetry_added_semantic_text_stats,9182000

x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/BlobCacheMetrics.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import org.apache.logging.log4j.LogManager;
1111
import org.apache.logging.log4j.Logger;
12+
import org.elasticsearch.common.util.concurrent.EsExecutors;
1213
import org.elasticsearch.index.store.LuceneFilesExtensions;
1314
import org.elasticsearch.telemetry.TelemetryProvider;
1415
import org.elasticsearch.telemetry.metric.DoubleHistogram;
@@ -29,7 +30,9 @@ public class BlobCacheMetrics {
2930
public static final String CACHE_POPULATION_REASON_ATTRIBUTE_KEY = "reason";
3031
public static final String CACHE_POPULATION_SOURCE_ATTRIBUTE_KEY = "source";
3132
public static final String LUCENE_FILE_EXTENSION_ATTRIBUTE_KEY = "file_extension";
33+
public static final String ES_EXECUTOR_ATTRIBUTE_KEY = "executor";
3234
public static final String NON_LUCENE_EXTENSION_TO_RECORD = "other";
35+
public static final String NON_ES_EXECUTOR_TO_RECORD = "other";
3336
public static final String BLOB_CACHE_COUNT_OF_EVICTED_REGIONS_TOTAL = "es.blob_cache.count_of_evicted_regions.total";
3437
public static final String SEARCH_ORIGIN_REMOTE_STORAGE_DOWNLOAD_TOOK_TIME = "es.blob_cache.search_origin.download_took_time.total";
3538

@@ -198,13 +201,16 @@ public void recordCachePopulationMetrics(
198201
) {
199202
LuceneFilesExtensions luceneFilesExtensions = LuceneFilesExtensions.fromFile(fileName);
200203
String luceneFileExt = luceneFilesExtensions != null ? luceneFilesExtensions.getExtension() : NON_LUCENE_EXTENSION_TO_RECORD;
204+
String executorName = EsExecutors.executorName(Thread.currentThread());
201205
Map<String, Object> metricAttributes = Map.of(
202206
CACHE_POPULATION_REASON_ATTRIBUTE_KEY,
203207
cachePopulationReason.name(),
204208
CACHE_POPULATION_SOURCE_ATTRIBUTE_KEY,
205209
cachePopulationSource.name(),
206210
LUCENE_FILE_EXTENSION_ATTRIBUTE_KEY,
207-
luceneFileExt
211+
luceneFileExt,
212+
ES_EXECUTOR_ATTRIBUTE_KEY,
213+
executorName != null ? executorName : NON_ES_EXECUTOR_TO_RECORD
208214
);
209215
assert bytesCopied > 0 : "We shouldn't be recording zero-sized copies";
210216
cachePopulationBytes.incrementBy(bytesCopied, metricAttributes);

x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/shared/SharedBlobCacheService.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.elasticsearch.common.unit.ByteSizeValue;
3030
import org.elasticsearch.common.unit.RelativeByteSizeValue;
3131
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
32+
import org.elasticsearch.common.util.concurrent.EsExecutors;
3233
import org.elasticsearch.common.util.concurrent.ThrottledTaskRunner;
3334
import org.elasticsearch.core.AbstractRefCounted;
3435
import org.elasticsearch.core.Assertions;
@@ -69,7 +70,9 @@
6970
import java.util.function.Predicate;
7071
import java.util.stream.Collectors;
7172

73+
import static org.elasticsearch.blobcache.BlobCacheMetrics.ES_EXECUTOR_ATTRIBUTE_KEY;
7274
import static org.elasticsearch.blobcache.BlobCacheMetrics.LUCENE_FILE_EXTENSION_ATTRIBUTE_KEY;
75+
import static org.elasticsearch.blobcache.BlobCacheMetrics.NON_ES_EXECUTOR_TO_RECORD;
7376
import static org.elasticsearch.blobcache.BlobCacheMetrics.NON_LUCENE_EXTENSION_TO_RECORD;
7477

7578
/**
@@ -1284,6 +1287,7 @@ public void fillCacheRange(
12841287
ActionListener<Void> completionListener
12851288
) throws IOException {
12861289
String blobFileExtension = getFileExtension(resourceDescription);
1290+
String executorName = EsExecutors.executorName(Thread.currentThread());
12871291
writer.fillCacheRange(
12881292
channel,
12891293
channelPos,
@@ -1295,7 +1299,15 @@ public void fillCacheRange(
12951299
var elapsedTime = TimeUnit.NANOSECONDS.toMillis(relativeTimeInNanosSupplier.getAsLong() - startTime);
12961300
blobCacheMetrics.getCacheMissLoadTimes().record(elapsedTime);
12971301
blobCacheMetrics.getCacheMissCounter()
1298-
.incrementBy(1L, Map.of(LUCENE_FILE_EXTENSION_ATTRIBUTE_KEY, blobFileExtension));
1302+
.incrementBy(
1303+
1L,
1304+
Map.of(
1305+
LUCENE_FILE_EXTENSION_ATTRIBUTE_KEY,
1306+
blobFileExtension,
1307+
ES_EXECUTOR_ATTRIBUTE_KEY,
1308+
executorName != null ? executorName : NON_ES_EXECUTOR_TO_RECORD
1309+
)
1310+
);
12991311
return null;
13001312
})
13011313
);

x-pack/plugin/blob-cache/src/test/java/org/elasticsearch/blobcache/BlobCacheMetricsTests.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.concurrent.TimeUnit;
2020
import java.util.stream.IntStream;
2121

22+
import static org.elasticsearch.blobcache.BlobCacheMetrics.NON_ES_EXECUTOR_TO_RECORD;
2223
import static org.hamcrest.Matchers.is;
2324

2425
public class BlobCacheMetricsTests extends ESTestCase {
@@ -46,27 +47,28 @@ public void testRecordCachePopulationMetricsRecordsThroughput() {
4647
cachePopulationReason,
4748
cachePopulationSource
4849
);
50+
String threadName = NON_ES_EXECUTOR_TO_RECORD;
4951

5052
// throughput histogram
5153
Measurement throughputMeasurement = recordingMeterRegistry.getRecorder()
5254
.getMeasurements(InstrumentType.DOUBLE_HISTOGRAM, "es.blob_cache.population.throughput.histogram")
5355
.get(0);
5456
assertEquals(throughputMeasurement.getDouble(), (double) mebiBytesSent / secondsTaken, 0.0);
55-
assertExpectedAttributesPresent(throughputMeasurement, cachePopulationReason, cachePopulationSource, fileExtension);
57+
assertExpectedAttributesPresent(throughputMeasurement, cachePopulationReason, cachePopulationSource, fileExtension, threadName);
5658

5759
// bytes counter
5860
Measurement totalBytesMeasurement = recordingMeterRegistry.getRecorder()
5961
.getMeasurements(InstrumentType.LONG_COUNTER, "es.blob_cache.population.bytes.total")
6062
.get(0);
6163
assertEquals(totalBytesMeasurement.getLong(), ByteSizeValue.ofMb(mebiBytesSent).getBytes());
62-
assertExpectedAttributesPresent(totalBytesMeasurement, cachePopulationReason, cachePopulationSource, fileExtension);
64+
assertExpectedAttributesPresent(totalBytesMeasurement, cachePopulationReason, cachePopulationSource, fileExtension, threadName);
6365

6466
// time counter
6567
Measurement totalTimeMeasurement = recordingMeterRegistry.getRecorder()
6668
.getMeasurements(InstrumentType.LONG_COUNTER, "es.blob_cache.population.time.total")
6769
.get(0);
6870
assertEquals(totalTimeMeasurement.getLong(), TimeUnit.SECONDS.toMillis(secondsTaken));
69-
assertExpectedAttributesPresent(totalTimeMeasurement, cachePopulationReason, cachePopulationSource, fileExtension);
71+
assertExpectedAttributesPresent(totalTimeMeasurement, cachePopulationReason, cachePopulationSource, fileExtension, threadName);
7072

7173
// let us check for 0, avoid div by 0.
7274
checkReadsAndMisses(0, 0, 1);
@@ -107,10 +109,12 @@ private static void assertExpectedAttributesPresent(
107109
Measurement measurement,
108110
BlobCacheMetrics.CachePopulationReason cachePopulationReason,
109111
CachePopulationSource cachePopulationSource,
110-
String fileExtension
112+
String fileExtension,
113+
String threadName
111114
) {
112115
assertThat(measurement.attributes().get(BlobCacheMetrics.CACHE_POPULATION_REASON_ATTRIBUTE_KEY), is(cachePopulationReason.name()));
113116
assertThat(measurement.attributes().get(BlobCacheMetrics.CACHE_POPULATION_SOURCE_ATTRIBUTE_KEY), is(cachePopulationSource.name()));
114117
assertThat(measurement.attributes().get(BlobCacheMetrics.LUCENE_FILE_EXTENSION_ATTRIBUTE_KEY), is(fileExtension));
118+
assertThat(measurement.attributes().get(BlobCacheMetrics.ES_EXECUTOR_ATTRIBUTE_KEY), is(threadName));
115119
}
116120
}

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/inference/usage/ModelStats.java

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77

88
package org.elasticsearch.xpack.core.inference.usage;
99

10+
import org.elasticsearch.TransportVersion;
1011
import org.elasticsearch.common.io.stream.StreamInput;
1112
import org.elasticsearch.common.io.stream.StreamOutput;
1213
import org.elasticsearch.common.io.stream.Writeable;
14+
import org.elasticsearch.core.Nullable;
15+
import org.elasticsearch.features.NodeFeature;
1316
import org.elasticsearch.inference.TaskType;
1417
import org.elasticsearch.xcontent.ToXContentObject;
1518
import org.elasticsearch.xcontent.XContentBuilder;
@@ -19,28 +22,34 @@
1922

2023
public class ModelStats implements ToXContentObject, Writeable {
2124

25+
public static final NodeFeature SEMANTIC_TEXT_USAGE = new NodeFeature("inference.semantic_text_usage");
26+
27+
static final TransportVersion INFERENCE_TELEMETRY_ADDED_SEMANTIC_TEXT_STATS = TransportVersion.fromName(
28+
"inference_telemetry_added_semantic_text_stats"
29+
);
30+
2231
private final String service;
2332
private final TaskType taskType;
2433
private long count;
34+
@Nullable
35+
private final SemanticTextStats semanticTextStats;
2536

26-
public ModelStats(String service, TaskType taskType) {
27-
this(service, taskType, 0L);
28-
}
29-
30-
public ModelStats(String service, TaskType taskType, long count) {
37+
public ModelStats(String service, TaskType taskType, long count, @Nullable SemanticTextStats semanticTextStats) {
3138
this.service = service;
3239
this.taskType = taskType;
3340
this.count = count;
34-
}
35-
36-
public ModelStats(ModelStats stats) {
37-
this(stats.service, stats.taskType, stats.count);
41+
this.semanticTextStats = semanticTextStats;
3842
}
3943

4044
public ModelStats(StreamInput in) throws IOException {
4145
this.service = in.readString();
4246
this.taskType = in.readEnum(TaskType.class);
4347
this.count = in.readLong();
48+
if (in.getTransportVersion().supports(INFERENCE_TELEMETRY_ADDED_SEMANTIC_TEXT_STATS)) {
49+
this.semanticTextStats = in.readOptional(SemanticTextStats::new);
50+
} else {
51+
this.semanticTextStats = null;
52+
}
4453
}
4554

4655
public void add() {
@@ -59,6 +68,11 @@ public long count() {
5968
return count;
6069
}
6170

71+
@Nullable
72+
public SemanticTextStats semanticTextStats() {
73+
return semanticTextStats;
74+
}
75+
6276
@Override
6377
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
6478
builder.startObject();
@@ -71,25 +85,34 @@ public void addXContentFragment(XContentBuilder builder, Params params) throws I
7185
builder.field("service", service);
7286
builder.field("task_type", taskType.name());
7387
builder.field("count", count);
88+
if (semanticTextStats != null) {
89+
builder.field("semantic_text", semanticTextStats);
90+
}
7491
}
7592

7693
@Override
7794
public void writeTo(StreamOutput out) throws IOException {
7895
out.writeString(service);
7996
out.writeEnum(taskType);
8097
out.writeLong(count);
98+
if (out.getTransportVersion().supports(INFERENCE_TELEMETRY_ADDED_SEMANTIC_TEXT_STATS)) {
99+
out.writeOptionalWriteable(semanticTextStats);
100+
}
81101
}
82102

83103
@Override
84104
public boolean equals(Object o) {
85105
if (this == o) return true;
86106
if (o == null || getClass() != o.getClass()) return false;
87107
ModelStats that = (ModelStats) o;
88-
return count == that.count && Objects.equals(service, that.service) && taskType == that.taskType;
108+
return count == that.count
109+
&& Objects.equals(service, that.service)
110+
&& taskType == that.taskType
111+
&& Objects.equals(semanticTextStats, that.semanticTextStats);
89112
}
90113

91114
@Override
92115
public int hashCode() {
93-
return Objects.hash(service, taskType, count);
116+
return Objects.hash(service, taskType, count, semanticTextStats);
94117
}
95118
}

0 commit comments

Comments
 (0)