Skip to content

Commit 9fca223

Browse files
committed
Merge branch 'master' into razmon-rpDepleter
2 parents 4530ef4 + 741f7cb commit 9fca223

122 files changed

Lines changed: 8131 additions & 1645 deletions

File tree

Some content is hidden

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

.github/workflows/benchmark-trigger.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ jobs:
2323
uses: ./.github/workflows/benchmark-runner.yml
2424
secrets: inherit
2525

26+
rust-micro-benchmarks:
27+
name: Trigger Rust Micro Benchmarks
28+
if: >
29+
(
30+
github.event.action == 'labeled' &&
31+
github.event.label.name == 'action:run-micro-benchmark'
32+
) || (
33+
contains(fromJson('["opened", "reopened", "synchronize"]'), github.event.action) &&
34+
contains(github.event.pull_request.labels.*.name, 'action:run-micro-benchmark')
35+
)
36+
concurrency:
37+
group: ${{ github.workflow }}-${{ github.event.number }}-rust-micro-benchmark
38+
cancel-in-progress: true
39+
uses: ./.github/workflows/flow-rust-micro-benchmarks.yml
40+
secrets: inherit
41+
2642
micro-benchmarks:
2743
name: Trigger Micro Benchmarks
2844
if: >

.github/workflows/event-nightly.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,15 @@ jobs:
4343
san: address
4444
env: ubuntu-latest
4545

46+
micro-benchmarks:
47+
uses: ./.github/workflows/flow-micro-benchmarks.yml
48+
secrets: inherit
49+
with:
50+
setup: '' # default behavior
51+
52+
4653
notify-failure:
47-
needs: [test-linux, test-macos, coverage, sanitize]
54+
needs: [test-linux, test-macos, coverage, sanitize, micro-benchmarks]
4855
if: failure()
4956
runs-on: ${{ vars.RUNS_ON || 'ubuntu-latest' }}
5057
steps:

.github/workflows/event-push-to-integ.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ jobs:
2121
notify_failure: true
2222

2323
micro-benchmarks:
24+
needs: check-what-changed
25+
if: ${{ needs.check-what-changed.outputs.BENCHMARK_CHANGED == 'true' }}
2426
uses: ./.github/workflows/flow-micro-benchmarks.yml
27+
secrets: inherit
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
architecture:
5+
required: true
6+
type: string
7+
instance-type:
8+
required: true
9+
type: string
10+
ami-id:
11+
required: true
12+
type: string
13+
14+
env:
15+
TAGS: | # Make sure there is no trailing comma!
16+
[
17+
{"Key": "Name", "Value": "redisearch-ci-runner"},
18+
{"Key": "Environment", "Value": "CI"},
19+
{"Key": "Run ID", "Value": "${{ github.run_id }}"},
20+
{"Key": "PR", "Value": "${{ github.event.number }}"},
21+
{"Key": "Owner", "Value": "${{ github.actor }}"},
22+
{"Key": "Project", "Value": "${{ github.repository }}"},
23+
{"Key": "Context", "Value": "micro-benchmarks"}
24+
]
25+
26+
jobs:
27+
start-runner:
28+
name: Start self-hosted EC2 runner
29+
runs-on: ubuntu-latest
30+
outputs:
31+
runner_label: ${{ steps.start-ec2-runner.outputs.label }}
32+
ec2_instance_id: ${{ steps.start-ec2-runner.outputs.ec2-instance-id }}
33+
steps:
34+
- name: Configure AWS credentials
35+
uses: aws-actions/configure-aws-credentials@v4
36+
with:
37+
aws-access-key-id: ${{ secrets.PERFORMANCE_EC2_ACCESS_KEY }}
38+
aws-secret-access-key: ${{ secrets.PERFORMANCE_EC2_SECRET_KEY }}
39+
aws-region: ${{ secrets.PERFORMANCE_EC2_AWS_REGION }}
40+
- name: Start EC2 runner
41+
id: start-ec2-runner
42+
uses: machulav/ec2-github-runner@v2
43+
with:
44+
mode: start
45+
github-token: ${{ secrets.CI_GH_P_TOKEN }}
46+
ec2-image-id: ${{ inputs.ami-id }}
47+
ec2-instance-type: ${{ inputs.instance-type }}
48+
subnet-id: ${{ secrets.AWS_EC2_SUBNET_ID_BENCHMARK }}
49+
security-group-id: ${{ secrets.AWS_EC2_SG_ID_BENCHMARK }}
50+
aws-resource-tags: ${{ env.TAGS }}
51+
52+
micro-benchmark:
53+
name: Run micro-benchmarks on runner
54+
needs: start-runner
55+
runs-on: ${{ needs.start-runner.outputs.runner_label }}
56+
steps:
57+
- name: Pre checkout deps
58+
run: sudo apt-get update && sudo apt-get -y install git
59+
- name: Checkout code
60+
uses: actions/checkout@v4
61+
with:
62+
submodules: recursive
63+
- name: Print runner info
64+
run: |
65+
printf "Runner lscpu:\n$(lscpu)\n"
66+
printf "Runner lsmem:\n$(lsmem)\n"
67+
printf "Runner nproc:\n$(nproc)\n"
68+
printf "Runner uname:\n$(uname -a)\n"
69+
printf "Runner arch:\n$(arch)\n"
70+
- name: Install benchmark dependencies
71+
run: |
72+
export HOME=/home/ubuntu
73+
cd .install
74+
./install_script.sh sudo
75+
cd ..
76+
# Then install Python dependencies
77+
sudo apt install python3-pip -y
78+
pip3 install --upgrade pip PyYAML setuptools redisbench-admin>=0.11.37
79+
env:
80+
DEBIAN_FRONTEND: noninteractive
81+
- name: Run Micro Benchmark
82+
env:
83+
ARCH: ${{ inputs.architecture }}
84+
timeout-minutes: 300
85+
run: |
86+
export HOME=/home/ubuntu
87+
export PATH="$HOME/.cargo/bin:$PATH"
88+
./build.sh run_microbenchmarks
89+
- name: Collect results
90+
run: |
91+
# Determine OS name
92+
OS_NAME=$(uname | tr '[:upper:]' '[:lower:]')
93+
if [[ "$OS_NAME" == "darwin" ]]; then
94+
OS_NAME="macos"
95+
fi
96+
97+
# Get architecture using uname -m
98+
ARCH=$(uname -m)
99+
if [[ "$ARCH" == "arm64" ]]; then
100+
ARCH="aarch64"
101+
elif [[ "$ARCH" == "x86_64" ]]; then
102+
ARCH="x64"
103+
fi
104+
105+
# Set flavor (assuming release build for benchmarks)
106+
FLAVOR="release"
107+
108+
# Create full variant string for the build directory
109+
FULL_VARIANT="${OS_NAME}-${ARCH}-${FLAVOR}"
110+
111+
# Set coordinator type (assuming OSS)
112+
COORD="oss"
113+
OUTDIR="search-community"
114+
115+
# Set the final BINDIR
116+
BINDIR="bin/${FULL_VARIANT}/${OUTDIR}"
117+
118+
# Update the binary directory path for ARM architectures
119+
echo "Looking for benchmark results in $BINDIR/micro-benchmarks"
120+
121+
# Find all JSON result files
122+
JSON_FILES=$(find $BINDIR/micro-benchmarks -name "*_results.json")
123+
124+
if [ -z "$JSON_FILES" ]; then
125+
echo "No benchmark result files found in $BINDIR/micro-benchmarks"
126+
exit 1
127+
fi
128+
129+
# Print found files for debugging
130+
echo "Found the following result files:"
131+
echo "$JSON_FILES" | tr ' ' '\n'
132+
133+
# Process each file individually
134+
for file in $JSON_FILES; do
135+
echo "Processing $file..."
136+
redisbench-admin export \
137+
--redistimeseries_host ${{ secrets.PERFORMANCE_RTS_HOST }} \
138+
--redistimeseries_port ${{ secrets.PERFORMANCE_RTS_PORT }} \
139+
--redistimeseries_user default \
140+
--redistimeseries_pass '${{ secrets.PERFORMANCE_RTS_AUTH }}' \
141+
--github_repo ${{ github.event.repository.name }} \
142+
--github_org ${{ github.repository_owner }} \
143+
--github_branch ${{ github.head_ref || github.ref_name }} \
144+
--github_actor ${{ github.triggering_actor }} \
145+
--results-format google.benchmark \
146+
--benchmark-result-file "$file" \
147+
--triggering_env redisearch-micro-benchmarks \
148+
--architecture ${{ inputs.architecture }}
149+
done
150+
151+
stop-runner:
152+
name: Stop self-hosted EC2 runner
153+
needs:
154+
- start-runner # required to get output from the start-runner job
155+
- micro-benchmark # required to wait when the main job is done
156+
runs-on: ubuntu-latest
157+
if: ${{ always() }} # required to stop the runner even if the error happened in the previous jobs
158+
steps:
159+
- name: Configure AWS credentials
160+
uses: aws-actions/configure-aws-credentials@v4
161+
with:
162+
aws-access-key-id: ${{ secrets.PERFORMANCE_EC2_ACCESS_KEY }}
163+
aws-secret-access-key: ${{ secrets.PERFORMANCE_EC2_SECRET_KEY }}
164+
aws-region: ${{ secrets.PERFORMANCE_EC2_AWS_REGION }}
165+
- name: Stop EC2 runner
166+
uses: machulav/ec2-github-runner@v2
167+
with:
168+
mode: stop
169+
github-token: ${{ secrets.CI_GH_P_TOKEN }}
170+
label: ${{ needs.start-runner.outputs.runner_label }}
171+
ec2-instance-id: ${{ needs.start-runner.outputs.ec2_instance_id }}

.github/workflows/flow-micro-benchmarks.yml

Lines changed: 92 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,63 +2,102 @@ name: Run a Micro Benchmark Flow
22

33
on:
44
workflow_call:
5+
inputs:
6+
architecture:
7+
type: string
8+
required: false
9+
default: 'all'
10+
description: 'Run only on specific architecture'
11+
workflow_dispatch:
12+
inputs:
13+
architecture:
14+
type: choice
15+
options:
16+
- all
17+
- aarch64
18+
- x86_64
19+
description: 'Run only on specific architecture'
20+
default: 'all'
521

622
jobs:
7-
benchmarks:
8-
runs-on: ${{ vars.RUNS_ON || 'ubuntu-latest' }}
9-
env:
10-
RUST_BACKTRACE: full
23+
prepare_runner_configurations:
24+
runs-on: ubuntu-latest
25+
outputs:
26+
matrix: ${{ steps.set-matrix.outputs.matrix }}
1127
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v4
14-
with:
15-
submodules: recursive
16-
- name: Setup specific
17-
working-directory: .install
18-
run: ./install_script.sh sudo
19-
- name: Build RediSearch
20-
run: ./build.sh
21-
- name: Download Latest Baseline Artifact from master
22-
id: get-artifact
23-
if: github.event_name == 'pull_request'
24-
uses: dawidd6/action-download-artifact@4c1e823582f43b179e2cbb49c3eade4e41f992e2 # refs @v10
25-
with:
26-
github_token: ${{ secrets.GITHUB_TOKEN }}
27-
branch: master
28-
name: rust-benchmark-results-master
29-
path: ./bin/redisearch_rs/criterion
30-
workflow: event-push-to-integ.yml
31-
continue-on-error: true
32-
- name: Check if Baseline Exists
33-
id: check_baseline
28+
- name: Set matrix
29+
id: set-matrix
3430
run: |
35-
if [ -d bin/redisearch_rs/criterion ]; then
36-
echo "baseline_exists=true" >> $GITHUB_OUTPUT
31+
# Define the full matrix as a JSON string
32+
FULL_MATRIX='
33+
{
34+
"include": [
35+
{
36+
"architecture": "aarch64",
37+
"instance-type": "i8g.xlarge",
38+
"ami-id": "ami-0d6c92b636b74f843"
39+
},
40+
{
41+
"architecture": "x86_64",
42+
"instance-type": "r7i.xlarge",
43+
"ami-id": "ami-09fabd03bb09b3704"
44+
}
45+
]
46+
}
47+
'
48+
49+
# Filter the matrix based on architecture
50+
if [ "${{ inputs.architecture }}" = "all" ]; then
51+
# Use the full matrix
52+
FILTERED_MATRIX="$FULL_MATRIX"
3753
else
38-
echo "baseline_exists=false" >> $GITHUB_OUTPUT
54+
# Filter to only the selected architecture
55+
FILTERED_MATRIX=$(echo "$FULL_MATRIX" | jq -c '{include: [.include[] | select(.architecture | contains("${{ inputs.architecture }}"))]}')
3956
fi
40-
- name: Run benchmark on PR with baseline from master
41-
if: github.event_name == 'pull_request' && steps.check_baseline.outputs.baseline_exists == 'true'
42-
run: cargo bench --workspace -- --baseline master
43-
working-directory: src/redisearch_rs
44-
- name: Run benchmark on PR without baseline
45-
if: github.event_name == 'pull_request' && steps.check_baseline.outputs.baseline_exists == 'false'
46-
run: cargo bench --workspace
47-
working-directory: src/redisearch_rs
48-
- name: Run benchmark on master
49-
if: github.ref == 'refs/heads/master' && github.event_name == 'push' && success()
50-
run: cargo bench --workspace -- --save-baseline master
51-
working-directory: src/redisearch_rs
5257
53-
- name: Upload rust baseline benchmarks for master
54-
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
55-
uses: actions/upload-artifact@v4
56-
with:
57-
name: "rust-benchmark-results-master"
58-
path: bin/redisearch_rs/criterion
59-
- name: Upload benchmarks for PR comparison
60-
if: github.event_name == 'pull_request'
61-
uses: actions/upload-artifact@v4
62-
with:
63-
name: "rust-benchmark-results-pr-${{ github.event.pull_request.number }}"
64-
path: bin/redisearch_rs/criterion
58+
# Use multiline output delimiter syntax for GitHub Actions
59+
echo "matrix<<EOF" >> $GITHUB_OUTPUT
60+
echo "$FILTERED_MATRIX" >> $GITHUB_OUTPUT
61+
echo "EOF" >> $GITHUB_OUTPUT
62+
63+
run_micro_benchmarks:
64+
name: Run ${{ matrix.architecture }} micro-benchmarks
65+
needs: prepare_runner_configurations
66+
uses: ./.github/workflows/flow-micro-benchmarks-runner.yml
67+
secrets: inherit
68+
strategy:
69+
matrix: ${{ fromJson(needs.prepare_runner_configurations.outputs.matrix) }}
70+
with:
71+
architecture: ${{ matrix.architecture }}
72+
instance-type: ${{ matrix.instance-type }}
73+
ami-id: ${{ matrix.ami-id }}
74+
75+
compare_micro_benchmarks:
76+
needs: run_micro_benchmarks
77+
if: github.event.number
78+
runs-on: ubuntu-latest
79+
env:
80+
PERFORMANCE_GH_TOKEN: ${{ secrets.PERFORMANCE_GH_TOKEN }}
81+
PERFORMANCE_WH_TOKEN: ${{ secrets.PERFORMANCE_WH_TOKEN }}
82+
steps:
83+
- name: Install benchmark dependencies
84+
run: |
85+
# Then install Python dependencies
86+
sudo apt install python3-pip -y
87+
pip3 install --upgrade pip PyYAML setuptools redisbench-admin
88+
- name: Compare benchmark results
89+
run: |
90+
redisbench-admin compare \
91+
--comparison-branch ${{ github.event.pull_request.head.ref || github.ref_name }} \
92+
--baseline-branch ${{ github.event.pull_request.base.ref }} \
93+
--auto-approve \
94+
--pull-request ${{ github.event.number }} \
95+
--redistimeseries_host ${{ secrets.PERFORMANCE_RTS_HOST }} \
96+
--redistimeseries_port ${{ secrets.PERFORMANCE_RTS_PORT }} \
97+
--redistimeseries_pass '${{ secrets.PERFORMANCE_RTS_AUTH }}' \
98+
--github_repo ${{ github.event.repository.name }} \
99+
--github_org ${{ github.repository_owner }} \
100+
--triggering_env redisearch-micro-benchmarks \
101+
--metric_name cpu_time \
102+
--metric_mode 'lower-better' \
103+
--grafana_uid 8171e685-e93d-49dd-86a5-859e779d652c

0 commit comments

Comments
 (0)