Skip to content

Commit b2819b6

Browse files
committed
Merge branch 'main' into retry_shard_movements_during_query
# Conflicts: # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeComputeHandler.java # x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSender.java # x-pack/plugin/esql/src/test/java/org/elasticsearch/xpack/esql/plugin/DataNodeRequestSenderTests.java
2 parents 0908649 + 128144d commit b2819b6

File tree

69 files changed

+1770
-442
lines changed

Some content is hidden

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

69 files changed

+1770
-442
lines changed

docs/changelog/125631.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 125631
2+
summary: Add `documents_found` and `values_loaded`
3+
area: ES|QL
4+
type: enhancement
5+
issues: []

docs/changelog/126911.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 126911
2+
summary: Fix `vec_caps` to test for OS support too (on x64)
3+
area: Vector Search
4+
type: bug
5+
issues:
6+
- 126809

libs/native/libraries/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ configurations {
1919
}
2020

2121
var zstdVersion = "1.5.5"
22-
var vecVersion = "1.0.10"
22+
var vecVersion = "1.0.11"
2323

2424
repositories {
2525
exclusiveContent {

libs/native/src/main/java/org/elasticsearch/nativeaccess/jdk/JdkVectorLibrary.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public final class JdkVectorLibrary implements VectorLibrary {
4141
try {
4242
int caps = (int) vecCaps$mh.invokeExact();
4343
logger.info("vec_caps=" + caps);
44-
if (caps != 0) {
44+
if (caps > 0) {
4545
if (caps == 2) {
4646
dot7u$mh = downcallHandle(
4747
"dot7u_2",
@@ -67,6 +67,11 @@ public final class JdkVectorLibrary implements VectorLibrary {
6767
}
6868
INSTANCE = new JdkVectorSimilarityFunctions();
6969
} else {
70+
if (caps < 0) {
71+
logger.warn("""
72+
Your CPU supports vector capabilities, but they are disabled at OS level. For optimal performance, \
73+
enable them in your OS/Hypervisor/VM/container""");
74+
}
7075
dot7u$mh = null;
7176
sqr7u$mh = null;
7277
INSTANCE = null;

libs/simdvec/native/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ apply plugin: 'cpp'
1111

1212
var os = org.gradle.internal.os.OperatingSystem.current()
1313

14-
// To update this library run publish_vec_binaries.sh ( or ./gradlew vecSharedLibrary )
14+
// To update this library run publish_vec_binaries.sh ( or ./gradlew buildSharedLibrary )
1515
// Or
1616
// For local development, build the docker image with:
1717
// docker build --platform linux/arm64 --progress=plain --file=Dockerfile.aarch64 . (for aarch64)

libs/simdvec/native/publish_vec_binaries.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ if [ -z "$ARTIFACTORY_API_KEY" ]; then
2020
exit 1;
2121
fi
2222

23-
VERSION="1.0.10"
23+
VERSION="1.0.11"
2424
ARTIFACTORY_REPOSITORY="${ARTIFACTORY_REPOSITORY:-https://artifactory.elastic.dev/artifactory/elasticsearch-native/}"
2525
TEMP=$(mktemp -d)
2626

libs/simdvec/native/src/vec/c/amd64/vec.c

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ static inline void cpuid(int output[4], int functionNumber) {
4646
#endif
4747
}
4848

49+
// Multi-platform XGETBV "intrinsic"
50+
static inline int64_t xgetbv(int ctr) {
51+
#if defined(__GNUC__) || defined(__clang__)
52+
// use inline assembly, Gnu/AT&T syntax
53+
uint32_t a, d;
54+
__asm("xgetbv" : "=a"(a),"=d"(d) : "c"(ctr) : );
55+
return a | (((uint64_t) d) << 32);
56+
57+
#elif (defined (_MSC_FULL_VER) && _MSC_FULL_VER >= 160040000) || (defined (__INTEL_COMPILER) && __INTEL_COMPILER >= 1200)
58+
// Microsoft or Intel compiler supporting _xgetbv intrinsic
59+
return _xgetbv(ctr);
60+
61+
#else
62+
#error Unsupported compiler
63+
#endif
64+
}
65+
4966
// Utility function to horizontally add 8 32-bit integers
5067
static inline int hsum_i32_8(const __m256i a) {
5168
const __m128i sum128 = _mm_add_epi32(_mm256_castsi256_si128(a), _mm256_extractf128_si256(a, 1));
@@ -57,11 +74,20 @@ static inline int hsum_i32_8(const __m256i a) {
5774

5875
EXPORT int vec_caps() {
5976
int cpuInfo[4] = {-1};
60-
// Calling __cpuid with 0x0 as the function_id argument
77+
// Calling CPUID function 0x0 as the function_id argument
6178
// gets the number of the highest valid function ID.
6279
cpuid(cpuInfo, 0);
6380
int functionIds = cpuInfo[0];
81+
if (functionIds == 0) {
82+
// No CPUID functions
83+
return 0;
84+
}
85+
// call CPUID function 0x1 for feature flags
86+
cpuid(cpuInfo, 1);
87+
int hasOsXsave = (cpuInfo[2] & (1 << 27)) != 0;
88+
int avxEnabledInOS = hasOsXsave && ((xgetbv(0) & 6) == 6);
6489
if (functionIds >= 7) {
90+
// call CPUID function 0x7 for AVX2/512 flags
6591
cpuid(cpuInfo, 7);
6692
int ebx = cpuInfo[1];
6793
int ecx = cpuInfo[2];
@@ -72,10 +98,18 @@ EXPORT int vec_caps() {
7298
// int avx512_vnni = (ecx & 0x00000800) != 0;
7399
// if (avx512 && avx512_vnni) {
74100
if (avx512) {
75-
return 2;
101+
if (avxEnabledInOS) {
102+
return 2;
103+
} else {
104+
return -2;
105+
}
76106
}
77107
if (avx2) {
78-
return 1;
108+
if (avxEnabledInOS) {
109+
return 1;
110+
} else {
111+
return -1;
112+
}
79113
}
80114
}
81115
return 0;

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ static TransportVersion def(int id) {
222222
public static final TransportVersion AMAZON_BEDROCK_TASK_SETTINGS = def(9_049_0_00);
223223
public static final TransportVersion ESQL_REPORT_SHARD_PARTITIONING = def(9_050_0_00);
224224
public static final TransportVersion ESQL_QUERY_PLANNING_DURATION = def(9_051_0_00);
225+
public static final TransportVersion ESQL_DOCUMENTS_FOUND_AND_VALUES_LOADED = def(9_052_0_00);
225226

226227
/*
227228
* STOP! READ THIS FIRST! No, really,

server/src/main/java/org/elasticsearch/common/Strings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ public static String toString(ChunkedToXContent chunkedToXContent, boolean prett
822822
* Allows to configure the params.
823823
* Allows to control whether the outputted json needs to be pretty printed and human readable.
824824
*/
825-
private static String toString(ToXContent toXContent, ToXContent.Params params, boolean pretty, boolean human) {
825+
public static String toString(ToXContent toXContent, ToXContent.Params params, boolean pretty, boolean human) {
826826
try {
827827
XContentBuilder builder = createBuilder(pretty, human);
828828
if (toXContent.isFragment()) {

test/framework/src/main/java/org/elasticsearch/node/MockNode.java

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

1010
package org.elasticsearch.node;
1111

12+
import org.elasticsearch.action.search.OnlinePrewarmingService;
13+
import org.elasticsearch.action.search.OnlinePrewarmingServiceProvider;
1214
import org.elasticsearch.client.internal.node.NodeClient;
1315
import org.elasticsearch.cluster.ClusterInfoService;
1416
import org.elasticsearch.cluster.MockInternalClusterInfoService;
@@ -117,6 +119,10 @@ SearchService newSearchService(
117119
tracer
118120
);
119121
}
122+
OnlinePrewarmingService onlinePrewarmingService = pluginsService.loadSingletonServiceProvider(
123+
OnlinePrewarmingServiceProvider.class,
124+
() -> OnlinePrewarmingServiceProvider.DEFAULT
125+
).create(clusterService.getSettings(), threadPool, clusterService);
120126
return new MockSearchService(
121127
clusterService,
122128
indicesService,
@@ -126,7 +132,8 @@ SearchService newSearchService(
126132
fetchPhase,
127133
circuitBreakerService,
128134
executorSelector,
129-
tracer
135+
tracer,
136+
onlinePrewarmingService
130137
);
131138
}
132139

0 commit comments

Comments
 (0)