Skip to content

Commit e092b1f

Browse files
committed
Merge remote-tracking branch 'origin/main' into lucene_snapshot_10_3
2 parents dc1e276 + 7f90465 commit e092b1f

File tree

783 files changed

+22199
-6502
lines changed

Some content is hidden

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

783 files changed

+22199
-6502
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
steps:
2+
- command: .buildkite/scripts/trigger-if-java-ea-new-build.sh
3+
env:
4+
RECENT_TIME_WINDOW: "24" # time window to consider a build as new in hours
5+
agents:
6+
image: "docker.elastic.co/ci-agent-images/eck-region/buildkite-agent:1.5"
7+
memory: "4G"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
steps:
2-
- label: $FWC_VERSION / fwc
3-
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false
2+
- label: "{{matrix.FWC_VERSION}} / fwc"
3+
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false
44
timeout_in_minutes: 300
55
agents:
66
provider: gcp
@@ -11,4 +11,4 @@ steps:
1111
setup:
1212
FWC_VERSION: $FWC_LIST
1313
env:
14-
FWC_VERSION: $FWC_VERSION
14+
FWC_VERSION: "{{matrix.FWC_VERSION}}"
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This file is auto-generated. See .buildkite/pipelines/periodic-fwc.template.yml
22
steps:
3-
- label: $FWC_VERSION / fwc
4-
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false
3+
- label: "{{matrix.FWC_VERSION}} / fwc"
4+
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v$$FWC_VERSION#fwcTest -Dtests.bwc.snapshot=false
55
timeout_in_minutes: 300
66
agents:
77
provider: gcp
@@ -12,4 +12,4 @@ steps:
1212
setup:
1313
FWC_VERSION: []
1414
env:
15-
FWC_VERSION: $FWC_VERSION
15+
FWC_VERSION: "{{matrix.FWC_VERSION}}"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
steps: []

.buildkite/scripts/fwc-branches.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
# Configure FwC test branches
4+
# We do not want 7.x branch and only to run for branches that:
5+
# - have released at least one minor version (not main)
6+
# - have previous minor unreleased (not the oldest development branch)
7+
FWC_BRANCHES=()
8+
for branch in "${BRANCHES[@]}"; do
9+
if [[ ! "$branch" =~ ^7\..* ]]; then
10+
FWC_BRANCHES+=("$branch")
11+
fi
12+
done
13+
# Remove first and last element
14+
FWC_BRANCHES=("${FWC_BRANCHES[@]:1:${#FWC_BRANCHES[@]}-2}")
15+
16+
shouldRunFwcFor() {
17+
local branch=$1
18+
for fwc_branch in "${FWC_BRANCHES[@]}"; do
19+
if [[ "$fwc_branch" == "$branch" ]]; then
20+
return 0
21+
fi
22+
done
23+
return 1
24+
}

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

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,69 @@
22

33
set -euo pipefail
44

5+
# uncomment for tests
6+
#function buildkite-agent {
7+
# local command=$1
8+
# echo "$@"
9+
# if [ "$command" == "annotate" ]; then
10+
# while read -r line; do
11+
# echo " read: $line";
12+
# done
13+
# fi
14+
#}
15+
516
env_id_baseline=$(python3 -c 'import uuid; print(uuid.uuid4())')
617
env_id_contender=$(python3 -c 'import uuid; print(uuid.uuid4())')
718
merge_base=$(git merge-base "${GITHUB_PR_TARGET_BRANCH}" HEAD)
819

20+
# PR comment
21+
buildkite-agent meta-data set pr_comment:early_comment_job_id "$BUILDKITE_JOB_ID"
922
buildkite-agent meta-data set pr_comment:custom-body:body \
10-
"This build attempted two ${GITHUB_PR_COMMENT_VAR_BENCHMARK} benchmarks to evaluate performance impact of this PR."
23+
"This build attempts two ${GITHUB_PR_COMMENT_VAR_BENCHMARK} benchmarks to evaluate performance impact of this PR. \
24+
To estimate benchmark completion time inspect previous nightly runs [here](https://buildkite.com/elastic/elasticsearch-performance-esbench-nightly/builds?branch=master)."
1125
buildkite-agent meta-data set pr_comment:custom-baseline:head \
1226
"* Baseline: ${merge_base} (env ID ${env_id_baseline})"
1327
buildkite-agent meta-data set pr_comment:custom-contender:head \
1428
"* Contender: ${GITHUB_PR_TRIGGERED_SHA} (env ID ${env_id_contender})"
1529

16-
cat << _EOF_
30+
# Buildkite annotation
31+
cat << _EOF1_ | buildkite-agent annotate --context "pr-benchmark-notification"
32+
This build attempts two ${GITHUB_PR_COMMENT_VAR_BENCHMARK} benchmarks to evaluate performance impact of PR [${GITHUB_PR_NUMBER}](https://github.com/elastic/elasticsearch/pull/${GITHUB_PR_NUMBER}).
33+
To estimate benchmark completion time inspect previous nightly runs [here](https://buildkite.com/elastic/elasticsearch-performance-esbench-nightly/builds?branch=master).
34+
* Baseline: [${merge_base:0:7}](https://github.com/elastic/elasticsearch/commit/${merge_base}) (env ID ${env_id_baseline})
35+
* Contender: [${GITHUB_PR_TRIGGERED_SHA:0:7}](https://github.com/elastic/elasticsearch/commit/${GITHUB_PR_TRIGGERED_SHA}) (env ID ${env_id_contender})
36+
_EOF1_
37+
38+
cat << _EOF2_
1739
steps:
18-
- label: Trigger baseline benchmark
40+
- label: Trigger baseline benchmark with ${merge_base:0:7}
1941
trigger: elasticsearch-performance-esbench-pr
2042
build:
21-
message: Baseline benchmark for PR${GITHUB_PR_NUMBER}
43+
message: Baseline benchmark for PR ${GITHUB_PR_NUMBER} with ${merge_base:0:7}
2244
branch: master
2345
env:
2446
CONFIGURATION_NAME: ${GITHUB_PR_COMMENT_VAR_BENCHMARK}
2547
ENV_ID: ${env_id_baseline}
2648
REVISION: ${merge_base}
27-
- label: Trigger contender benchmark
49+
- label: Trigger contender benchmark with ${GITHUB_PR_TRIGGERED_SHA:0:7}
2850
trigger: elasticsearch-performance-esbench-pr
2951
build:
30-
message: Contender benchmark for PR${GITHUB_PR_NUMBER}
52+
message: Contender benchmark for PR ${GITHUB_PR_NUMBER} with ${GITHUB_PR_TRIGGERED_SHA:0:7}
3153
branch: master
3254
env:
3355
CONFIGURATION_NAME: ${GITHUB_PR_COMMENT_VAR_BENCHMARK}
3456
ENV_ID: ${env_id_contender}
3557
ES_REPO_URL: https://github.com/${GITHUB_PR_OWNER}/${GITHUB_PR_REPO}.git
3658
REVISION: ${GITHUB_PR_TRIGGERED_SHA}
3759
- wait: ~
38-
- label: Modify PR comment
39-
command: buildkite-agent meta-data set pr_comment:custom-comparison:head "* [Benchmark results](<https://esbench-metrics.kb.us-east-2.aws.elastic-cloud.com:9243/app/dashboards#/view/d9079962-5866-49ef-b9f5-145f2141cd31?_a=(query:(language:kuery,query:'user-tags.env-id:${env_id_baseline} or user-tags.env-id:${env_id_contender}'))>)"
40-
_EOF_
60+
- label: Update PR comment and Buildkite annotation
61+
command: |
62+
buildkite-agent meta-data set pr_comment:custom-body:body "This build ran two ${GITHUB_PR_COMMENT_VAR_BENCHMARK} benchmarks to evaluate performance impact of this PR."
63+
buildkite-agent meta-data set pr_comment:custom-comparison:head "* [Benchmark results](<https://esbench-metrics.kb.us-east-2.aws.elastic-cloud.com:9243/app/dashboards#/view/d9079962-5866-49ef-b9f5-145f2141cd31?_a=(query:(language:kuery,query:'user-tags.env-id:${env_id_baseline} or user-tags.env-id:${env_id_contender}'))>)"
64+
cat << _EOF3_ | buildkite-agent annotate --context "pr-benchmark-notification"
65+
This build ran two ${GITHUB_PR_COMMENT_VAR_BENCHMARK} benchmarks to evaluate performance impact of PR [${GITHUB_PR_NUMBER}](https://github.com/elastic/elasticsearch/pull/${GITHUB_PR_NUMBER}).
66+
* Baseline: [${merge_base:0:7}](https://github.com/elastic/elasticsearch/commit/${merge_base}) (env ID ${env_id_baseline})
67+
* Contender: [${GITHUB_PR_TRIGGERED_SHA:0:7}](https://github.com/elastic/elasticsearch/commit/${GITHUB_PR_TRIGGERED_SHA}) (env ID ${env_id_contender})
68+
* [Benchmark results](<https://esbench-metrics.kb.us-east-2.aws.elastic-cloud.com:9243/app/dashboards#/view/d9079962-5866-49ef-b9f5-145f2141cd31?_a=(query:(language:kuery,query:'user-tags.env-id:${env_id_baseline} or user-tags.env-id:${env_id_contender}'))>)
69+
_EOF3_
70+
_EOF2_

.buildkite/scripts/periodic.trigger.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -euo pipefail
55
echo "steps:"
66

77
source .buildkite/scripts/branches.sh
8+
source .buildkite/scripts/fwc-branches.sh
89

910
IS_FIRST=true
1011
SKIP_DELAY="${SKIP_DELAY:-false}"
@@ -46,8 +47,7 @@ EOF
4647
branch: "$BRANCH"
4748
commit: "$LAST_GOOD_COMMIT"
4849
EOF
49-
# Include forward compatibility tests only for the bugfix branch
50-
if [[ "${BRANCH}" == "${BRANCHES[2]}" ]]; then
50+
if shouldRunFwcFor "$BRANCH"; then
5151
cat <<EOF
5252
- trigger: elasticsearch-periodic-fwc
5353
label: Trigger periodic-fwc pipeline for $BRANCH
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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+
#!/bin/bash
11+
12+
# Allow overriding the time window (in hours) to check for new builds, defaults to 24
13+
RECENT_TIME_WINDOW=${RECENT_TIME_WINDOW:-24}
14+
15+
# Extract current JDK major version from bundled_jdk in version.properties
16+
CURRENT_JDK=$(grep "^bundled_jdk =" build-tools-internal/version.properties | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f1)
17+
TARGET_JDK=$((CURRENT_JDK + 1))
18+
19+
echo "Current JDK major version: $CURRENT_JDK"
20+
echo "Target JDK major version: $TARGET_JDK"
21+
22+
# Query Elasticsearch JDK archive for available JDKs
23+
JDK_ARCHIVE_URL="https://builds.es-jdk-archive.com/jdks/openjdk/recent.json"
24+
echo "Querying JDK archive: $JDK_ARCHIVE_URL"
25+
26+
# Fetch JDK info and filter for target major version
27+
JDK_DATA=$(curl -s "$JDK_ARCHIVE_URL")
28+
29+
if [[ -z "$JDK_DATA" ]]; then
30+
echo "Failed to fetch JDK data from archive"
31+
exit 1
32+
fi
33+
34+
# Find the latest build for the target JDK version
35+
LATEST_BUILD=$(echo "$JDK_DATA" | jq -r --arg target "$TARGET_JDK" '
36+
.majors[$target].builds |
37+
sort_by(.archived_at) |
38+
last'
39+
)
40+
41+
if [[ "$LATEST_BUILD" == "null" || -z "$LATEST_BUILD" ]]; then
42+
echo "No builds found for JDK $TARGET_JDK"
43+
exit 1
44+
fi
45+
46+
# Extract timestamp and JDK identifier
47+
TIMESTAMP=$(echo "$LATEST_BUILD" | jq -r '.archived_at')
48+
JDK_IDENTIFIER=$(echo "$LATEST_BUILD" | jq -r '.id')
49+
50+
echo "Latest JDK ${TARGET_JDK} build from ES archive:"
51+
echo " Timestamp: $TIMESTAMP"
52+
echo " JDK Identifier: $JDK_IDENTIFIER"
53+
54+
# Set variables for use in the pipeline trigger
55+
jdkbuild="$JDK_IDENTIFIER"
56+
jdk_timestamp="$TIMESTAMP"
57+
58+
# Check if timestamp is within last 24 hours
59+
CURRENT_TIME=$(date +%s)
60+
BUILD_TIME=$(date -d "$TIMESTAMP" +%s 2>/dev/null || date -j -f "%Y-%m-%dT%H:%M:%S" "${TIMESTAMP%Z}" +%s 2>/dev/null || echo "0")
61+
62+
if [[ "$BUILD_TIME" == "0" ]]; then
63+
echo "Failed to parse timestamp: $TIMESTAMP"
64+
SHOULD_TRIGGER="false"
65+
else
66+
TIME_DIFF=$((CURRENT_TIME - BUILD_TIME))
67+
TIME_WINDOW=$((RECENT_TIME_WINDOW * 60 * 60))
68+
69+
if [[ $TIME_DIFF -lt $TIME_WINDOW ]]; then
70+
echo "Build is recent (less than ${RECENT_TIME_WINDOW}h old)"
71+
SHOULD_TRIGGER="true"
72+
else
73+
echo "Build is older than ${RECENT_TIME_WINDOW} hours"
74+
SHOULD_TRIGGER="false"
75+
fi
76+
fi
77+
78+
echo "SHOULD_TRIGGER: $SHOULD_TRIGGER"
79+
80+
81+
if [[ "$SHOULD_TRIGGER" == "true" ]]; then
82+
EFFECTIVE_START_DATE=$(date -u -d "@$BUILD_TIME" +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || date -u -r "$BUILD_TIME" +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || echo "")
83+
echo "Triggering performance-esbench-jdk for new jdk build $JDK_IDENTIFIER"
84+
cat << EOF | buildkite-agent pipeline upload
85+
steps:
86+
- trigger: elasticsearch-performance-esbench-jdk
87+
label: Triggering performance-esbench-jdk for new jdk build $JDK_IDENTIFIER
88+
async: true
89+
build:
90+
branch: "$BUILDKITE_BRANCH"
91+
env:
92+
EFFECTIVE_START_DATE: "$EFFECTIVE_START_DATE"
93+
EXECUTION_MODE: "start-run"
94+
EOF
95+
fi

TESTING.asciidoc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -681,12 +681,15 @@ There are multiple base classes for tests:
681681
directly by unit tests.
682682
* **`ESSingleNodeTestCase`**: This test case sets up a cluster that has a
683683
single node.
684-
* **`ESIntegTestCase`**: An integration test case that creates a cluster that
685-
might have multiple nodes.
686-
* **`ESRestTestCase`**: An integration tests that interacts with an external
687-
cluster via the REST API. This is used for Java based REST tests.
688-
* **`ESClientYamlSuiteTestCase` **: A subclass of `ESRestTestCase` used to run
689-
YAML based REST tests.
684+
* **`ESIntegTestCase`**: An internal integration test that starts nodes within the same JVM as the test.
685+
These allow you to test functionality that is not exposed via the REST API, or for verifying a certain internal state.
686+
Additionally, you can easily simulate tricky distributed setups that are difficult to do in REST tests.
687+
If you only need to start one node, use `ESSingleNodeTestCase` instead, which is a much lighter test setup.
688+
* **`ESRestTestCase`**: An integration test that interacts with an external
689+
cluster via the REST API. This is used for Java based REST tests. This should
690+
be the first choice for writing integration tests as these tests run in a much more
691+
realistic setup.
692+
* **`ESClientYamlSuiteTestCase` **: A subclass of `ESRestTestCase` used to run YAML based REST tests.
690693

691694
=== Good practices
692695

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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.vector;
11+
12+
import org.elasticsearch.common.logging.LogConfigurator;
13+
import org.elasticsearch.index.codec.vectors.cluster.NeighborHood;
14+
import org.openjdk.jmh.annotations.Benchmark;
15+
import org.openjdk.jmh.annotations.BenchmarkMode;
16+
import org.openjdk.jmh.annotations.Fork;
17+
import org.openjdk.jmh.annotations.Measurement;
18+
import org.openjdk.jmh.annotations.Mode;
19+
import org.openjdk.jmh.annotations.OutputTimeUnit;
20+
import org.openjdk.jmh.annotations.Param;
21+
import org.openjdk.jmh.annotations.Scope;
22+
import org.openjdk.jmh.annotations.Setup;
23+
import org.openjdk.jmh.annotations.State;
24+
import org.openjdk.jmh.annotations.Warmup;
25+
import org.openjdk.jmh.infra.Blackhole;
26+
27+
import java.io.IOException;
28+
import java.util.Random;
29+
import java.util.concurrent.TimeUnit;
30+
31+
@BenchmarkMode(Mode.AverageTime)
32+
@OutputTimeUnit(TimeUnit.SECONDS)
33+
@State(Scope.Benchmark)
34+
// first iteration is complete garbage, so make sure we really warmup
35+
@Warmup(iterations = 1, time = 1)
36+
// real iterations. not useful to spend tons of time here, better to fork more
37+
@Measurement(iterations = 3, time = 1)
38+
// engage some noise reduction
39+
@Fork(value = 1)
40+
public class ComputeNeighboursBenchmark {
41+
42+
static {
43+
LogConfigurator.configureESLogging(); // native access requires logging to be initialized
44+
}
45+
46+
@Param({ "1000", "2000", "3000", "5000", "10000", "20000", "50000" })
47+
int numVectors;
48+
49+
@Param({ "384", "782", "1024" })
50+
int dims;
51+
52+
float[][] vectors;
53+
int clusterPerNeighbour = 128;
54+
55+
@Setup
56+
public void setup() throws IOException {
57+
Random random = new Random(123);
58+
vectors = new float[numVectors][dims];
59+
for (float[] vector : vectors) {
60+
for (int i = 0; i < dims; i++) {
61+
vector[i] = random.nextFloat();
62+
}
63+
}
64+
}
65+
66+
@Benchmark
67+
@Fork(jvmArgsPrepend = { "--add-modules=jdk.incubator.vector" })
68+
public void bruteForce(Blackhole bh) {
69+
bh.consume(NeighborHood.computeNeighborhoodsBruteForce(vectors, clusterPerNeighbour));
70+
}
71+
72+
@Benchmark
73+
@Fork(jvmArgsPrepend = { "--add-modules=jdk.incubator.vector" })
74+
public void graph(Blackhole bh) throws IOException {
75+
bh.consume(NeighborHood.computeNeighborhoodsGraph(vectors, clusterPerNeighbour));
76+
}
77+
}

0 commit comments

Comments
 (0)