Skip to content

Commit 5b6dad2

Browse files
authored
Merge branch 'main' into jackson221
2 parents 77bfba2 + 8202f18 commit 5b6dad2

File tree

210 files changed

+10862
-7185
lines changed

Some content is hidden

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

210 files changed

+10862
-7185
lines changed

.buildkite/pull-requests.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"set_commit_status": false,
4848
"build_on_commit": false,
4949
"build_on_comment": true,
50-
"target_branch": "main",
5150
"trigger_comment_regex": "^(buildkite|@elastic(search)?machine) benchmark this with (?<benchmark>\\S+)( please)?$"
5251
}
5352
]

.buildkite/scripts/generate-pr-performance-benchmark.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set -euo pipefail
1515

1616
env_id_baseline=$(python3 -c 'import uuid; print(uuid.uuid4())')
1717
env_id_contender=$(python3 -c 'import uuid; print(uuid.uuid4())')
18-
merge_base=$(git merge-base "${GITHUB_PR_TARGET_BRANCH}" HEAD)
18+
merge_base=$(git merge-base "origin/${GITHUB_PR_TARGET_BRANCH}" HEAD)
1919

2020
# PR comment
2121
buildkite-agent meta-data set pr_comment:early_comment_job_id "$BUILDKITE_JOB_ID"

benchmarks/src/main/java/org/elasticsearch/benchmark/vector/scorer/ScalarOperations.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@
1717
*/
1818
class ScalarOperations {
1919

20+
static float cosine(byte[] a, byte[] b) {
21+
int sum = 0;
22+
int norm1 = 0;
23+
int norm2 = 0;
24+
25+
for (int i = 0; i < a.length; i++) {
26+
byte elem1 = a[i];
27+
byte elem2 = b[i];
28+
sum += elem1 * elem2;
29+
norm1 += elem1 * elem1;
30+
norm2 += elem2 * elem2;
31+
}
32+
return (float) (sum / Math.sqrt((double) norm1 * (double) norm2));
33+
}
34+
2035
static float dotProduct(float[] a, float[] b) {
2136
float res = 0;
2237
for (int i = 0; i < a.length; i++) {

benchmarks/src/main/java/org/elasticsearch/benchmark/vector/scorer/VectorScorerInt8OperationBenchmark.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class VectorScorerInt8OperationBenchmark {
6262
@Param({ "1", "128", "207", "256", "300", "512", "702", "1024", "1536", "2048" })
6363
public int size;
6464

65-
@Param({ "DOT_PRODUCT", "EUCLIDEAN" })
65+
@Param({ "COSINE", "DOT_PRODUCT", "EUCLIDEAN" })
6666
public VectorSimilarityType function;
6767

6868
@FunctionalInterface
@@ -92,11 +92,13 @@ public void init() {
9292
MemorySegment.copy(MemorySegment.ofArray(bytesB), JAVA_BYTE, 0L, nativeSegB, JAVA_BYTE, 0L, bytesB.length);
9393

9494
luceneImpl = switch (function) {
95+
case COSINE -> VectorUtil::cosine;
9596
case DOT_PRODUCT -> VectorUtil::dotProduct;
9697
case EUCLIDEAN -> VectorUtil::squareDistance;
9798
default -> throw new UnsupportedOperationException("Not used");
9899
};
99100
nativeImpl = vectorSimilarityFunctions.getHandle(switch (function) {
101+
case COSINE -> VectorSimilarityFunctions.Function.COSINE;
100102
case DOT_PRODUCT -> VectorSimilarityFunctions.Function.DOT_PRODUCT;
101103
case EUCLIDEAN -> VectorSimilarityFunctions.Function.SQUARE_DISTANCE;
102104
default -> throw new IllegalArgumentException(function.toString());
@@ -121,18 +123,18 @@ public float luceneWithCopy() {
121123
}
122124

123125
@Benchmark
124-
public int nativeWithNativeSeg() {
126+
public float nativeWithNativeSeg() {
125127
try {
126-
return (int) nativeImpl.invokeExact(nativeSegA, nativeSegB, size);
128+
return (float) nativeImpl.invokeExact(nativeSegA, nativeSegB, size);
127129
} catch (Throwable t) {
128130
throw rethrow(t);
129131
}
130132
}
131133

132134
@Benchmark
133-
public int nativeWithHeapSeg() {
135+
public float nativeWithHeapSeg() {
134136
try {
135-
return (int) nativeImpl.invokeExact(heapSegA, heapSegB, size);
137+
return (float) nativeImpl.invokeExact(heapSegA, heapSegB, size);
136138
} catch (Throwable t) {
137139
throw rethrow(t);
138140
}

benchmarks/src/test/java/org/elasticsearch/benchmark/vector/scorer/VectorScorerInt8OperationBenchmarkTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public void test() {
4747
bench.init();
4848
try {
4949
float expected = switch (function) {
50+
case COSINE -> ScalarOperations.cosine(bench.bytesA, bench.bytesB);
5051
case DOT_PRODUCT -> ScalarOperations.dotProduct(bench.bytesA, bench.bytesB);
5152
case EUCLIDEAN -> ScalarOperations.squareDistance(bench.bytesA, bench.bytesB);
5253
default -> throw new AssumptionViolatedException("Not tested");

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchTestBasePlugin.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,23 @@ private static void configureEntitlements(Project project) {
357357
"--add-exports=java.base/org.elasticsearch.entitlement.bridge=ALL-UNNAMED,"
358358
+ modulesContainingEntitlementInstrumentation
359359
);
360+
361+
// Export internal JDK packages that are required (temporarily) to declare instrumentation
362+
test.jvmArgs("--add-exports=jdk.jlink/jdk.tools.jlink.internal=ALL-UNNAMED");
363+
test.jvmArgs("--add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED");
364+
test.jvmArgs("--add-exports=java.base/sun.net.www=ALL-UNNAMED");
365+
test.jvmArgs("--add-exports=java.base/sun.net.www.protocol.ftp=ALL-UNNAMED");
366+
test.jvmArgs("--add-exports=java.base/sun.net.www.protocol.file=ALL-UNNAMED");
367+
test.jvmArgs("--add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED");
368+
test.jvmArgs("--add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED");
369+
test.jvmArgs("--add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED");
370+
test.jvmArgs("--add-exports=java.base/sun.net.www.protocol.mailto=ALL-UNNAMED");
371+
test.jvmArgs("--add-exports=java.base/sun.nio.ch=ALL-UNNAMED");
372+
test.jvmArgs("--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED");
373+
test.jvmArgs("--add-exports=java.base/jdk.internal.foreign.abi=ALL-UNNAMED");
374+
test.jvmArgs("--add-exports=java.base/jdk.internal.foreign.layout=ALL-UNNAMED");
375+
test.jvmArgs("--add-exports=java.net.http/jdk.internal.net.http=ALL-UNNAMED");
376+
test.jvmArgs("--add-exports=jdk.jdi/com.sun.tools.jdi=ALL-UNNAMED");
360377
});
361378
}
362379

build-tools-internal/src/main/resources/checkstyle_suppressions.xml

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

4444
<!-- Gradle requires inputs to be seriablizable -->
4545
<suppress files="build-tools-internal[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]gradle[/\\]internal[/\\]precommit[/\\]TestingConventionRule.java" checks="RegexpSinglelineJava" />
46+
47+
<!-- Entitlements rules API requires functional interfaces to be serializable -->
48+
<suppress files="libs[/\\]entitlement[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]entitlement[/\\]rules[/\\]function[/\\]" checks="RegexpSinglelineJava" />
4649
</suppressions>

build-tools/build.gradle

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ java {
3434
sourceCompatibility = versions.get("minimumRuntimeJava")
3535
}
3636

37+
sourceSets {
38+
integTest {
39+
compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]
40+
runtimeClasspath += output + compileClasspath
41+
}
42+
}
43+
44+
tasks.named("pluginUnderTestMetadata").configure {
45+
getPluginClasspath().from(sourceSets.testFixtures.runtimeClasspath)
46+
}
47+
3748
gradlePlugin {
3849
// We already configure publication and we don't need or want the one that comes
3950
// with the java-gradle-plugin
@@ -94,13 +105,6 @@ tasks.named("processResources").configure {
94105
}
95106
}
96107

97-
sourceSets {
98-
integTest {
99-
compileClasspath += sourceSets["main"].output + configurations["testRuntimeClasspath"]
100-
runtimeClasspath += output + compileClasspath
101-
}
102-
}
103-
104108
// we do not publish the test fixtures of build-tools
105109
components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() }
106110
components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() }
@@ -140,6 +144,7 @@ dependencies {
140144
implementation buildLibs.jackson.core
141145
implementation buildLibs.jackson.databind
142146

147+
testFixturesApi buildLibs.commmons.io
143148
testFixturesApi gradleApi()
144149
testFixturesApi gradleTestKit()
145150
testFixturesApi buildLibs.junit
@@ -176,6 +181,7 @@ tasks.withType(JavaCompile).configureEach {
176181
tasks.named('test').configure {
177182
useJUnitPlatform()
178183
}
184+
179185
tasks.register("integTest", Test) {
180186
testClassesDirs = sourceSets.integTest.output.classesDirs
181187
classpath = sourceSets.integTest.runtimeClasspath
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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.gradle
11+
12+
import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest
13+
import spock.lang.IgnoreIf
14+
15+
import static org.elasticsearch.gradle.fixtures.JdkToolchainTestFixture.withMockedJdkDownload
16+
17+
/**
18+
* Integration tests for {@link org.elasticsearch.gradle.fixtures.JdkToolchainTestFixture}.
19+
* Verifies that the fixture runs a Gradle build with a pre-installed fake JDK path and that
20+
* the build succeeds. Full toolchain resolution and ES_JAVA_HOME override are covered by
21+
* {@link TestClustersPluginFuncTest#override jdk usage via ES_JAVA_HOME for known jdk os incompatibilities}.
22+
*/
23+
@IgnoreIf({ os.isWindows() })
24+
class JdkToolchainTestFixtureFuncTest extends AbstractGradleFuncTest {
25+
26+
def "build with mocked JDK path succeeds"() {
27+
when:
28+
def runner = gradleRunner('tasks', '-i', '-Dorg.gradle.java.installations.auto-detect=false')
29+
def result = withMockedJdkDownload(runner, 17, 'eclipse_adoptium')
30+
31+
then:
32+
result.output.contains('BUILD SUCCESSFUL')
33+
}
34+
}

build-tools/src/integTest/groovy/org/elasticsearch/gradle/TestClustersPluginFuncTest.groovy

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import org.elasticsearch.gradle.fixtures.AbstractGradleFuncTest
1717
import org.gradle.testkit.runner.GradleRunner
1818

1919
import static org.elasticsearch.gradle.fixtures.DistributionDownloadFixture.*
20+
import static org.elasticsearch.gradle.fixtures.JdkToolchainTestFixture.withMockedJdkDownload
2021

2122
/**
2223
* We do not have coverage for the test cluster startup on windows yet.
@@ -241,13 +242,6 @@ class TestClustersPluginFuncTest extends AbstractGradleFuncTest {
241242
@RestoreSystemProperties
242243
def "override jdk usage via ES_JAVA_HOME for known jdk os incompatibilities"() {
243244
given:
244-
245-
settingsFile.text = """
246-
plugins {
247-
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
248-
}
249-
""" + settingsFile.text
250-
251245
buildFile << """
252246
testClusters {
253247
myCluster {
@@ -266,16 +260,29 @@ class TestClustersPluginFuncTest extends AbstractGradleFuncTest {
266260
}
267261
"""
268262
when:
269-
def result = withMockedDistributionDownload(
270-
"8.10.4",
271-
ElasticsearchDistribution.Platform.LINUX,
272-
gradleRunner("myTask", '-Dos.name=Linux', '-Dos.version=6.14.0-1015-gcp', '-i')
273-
) {
274-
build()
275-
}
263+
def runner = gradleRunner(
264+
"myTask",
265+
'-Dos.name=Linux',
266+
'-Dos.version=6.14.0-1015-gcp',
267+
'-i',
268+
'-Dorg.gradle.java.installations.auto-detect=false'
269+
)
270+
271+
def result = withMockedJdkDownload(runner, { GradleRunner r ->
272+
withMockedDistributionDownload(
273+
"8.10.4",
274+
ElasticsearchDistribution.Platform.LINUX,
275+
r,
276+
{ it.build() }
277+
)
278+
}, 17, "eclipse_adoptium")
276279

277280
then:
278-
result.output.lines().anyMatch { line -> line.startsWith("Running") && line.split().find { it.startsWith("ES_JAVA_HOME=") }.contains("eclipse_adoptium-17") }
281+
def output = result.output
282+
assert output.contains("Running")
283+
assert output.lines().anyMatch { line ->
284+
line.contains("ES_JAVA_HOME=") && line.contains("eclipse_adoptium-17")
285+
}
279286
}
280287

281288
boolean assertEsOutputContains(String testCluster, String expectedOutput) {

0 commit comments

Comments
 (0)