Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup-tarantool/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ runs:
uses: actions/cache@v3
with:
path: /home/runner/tnt-release
key: cache-tnt-${{ inputs.tarantool_version }}${{ env.VERSION_POSTFIX }}
key: cache-tnt-${{ runner.environment }}-${{ inputs.tarantool_version }}${{ env.VERSION_POSTFIX }}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not related to perf test, let's put it in separate commit: we're trying to distinguish github-hosted from self-hosted

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


- name: Clone tarantool ${{ inputs.tarantool_version }}
if: |
Expand Down
172 changes: 172 additions & 0 deletions .github/workflows/performance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: performance

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow is great, but I don't think it's enough, since we won't be able to see the perf degradation compared to master: it runs after merge or with performance tag in PR, which won't be used that often. So, we'll notice, that perf degraded only after merging to master, not good.

Can we also introduce the workflow, which will run on github runners: take master, run several times, take the mean, take branch, run several times, take the mean, compare them, if master has at least 5% more rps than branch, fail the workflow, again: router overload + storage overload.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


on:
pull_request:
types: [opened, reopened, synchronize, labeled]
workflow_dispatch:
schedule:
- cron: '0 1 * * *' # Every day at 01:00 UTC.

permissions:
contents: read

concurrency:
# Cancel superseded developer runs; preserve master, releases, and tags.
group: ${{ (
github.ref == 'refs/heads/master' ||
startsWith(github.ref, 'refs/heads/release/') ||
startsWith(github.ref, 'refs/tags/') ||
(github.event_name == 'pull_request' &&
github.event.action == 'labeled' &&
github.event.label.name != 'performance')) &&
format('{0}-{1}', github.run_id, github.run_attempt) ||
format('{0}-{1}', github.workflow, github.ref) }}
cancel-in-progress: true

jobs:
check:
if: github.repository == 'tarantool/vshard' &&
(github.event_name != 'pull_request' ||
(contains(github.event.pull_request.labels.*.name, 'performance') &&
(github.event.action != 'labeled' ||
github.event.label.name == 'performance')))
runs-on: ubuntu-22.04
permissions:
actions: read
outputs:
run: ${{ steps.check.outputs.result }}
steps:
- name: Check previous runs
id: check
uses: actions/github-script@v7
with:
result-encoding: string
script: |
if (context.eventName !== 'schedule') {
return true
}
// Run benchmarks if this commit hasn't been tested successfully.
const runs = await github.paginate(
github.rest.actions.listWorkflowRuns, {
...context.repo,
workflow_id: 'performance.yml',
branch: context.ref.replace('refs/heads/', ''),
head_sha: context.sha,
status: 'success',
per_page: 100,
})
return !runs.some(run =>
run.event === 'schedule' ||
run.event === 'workflow_dispatch')

performance:
name: performance (${{ matrix.scenario }})
needs: check
if: needs.check.outputs.run == 'true'
strategy:
fail-fast: false
max-parallel: 1
matrix:
include:
- scenario: router-pressure
args: --replicasets 4 --routers 1 --generators 4
- scenario: storage-pressure
args: --replicasets 1 --routers 4 --generators 16

runs-on: [self-hosted, Linux, x86_64, performance]
timeout-minutes: 60
defaults:
run:
shell: bash
env:
PERF_BRANCH: ${{ github.event.pull_request.head.ref || github.ref_name }}
PERF_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
LC_ALL: C
TZ: UTC

steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.PERF_COMMIT }}
persist-credentials: false
- name: Setup Tarantool
uses: ./.github/actions/setup-tarantool
with:
tarantool_version: '3.9.0'
- name: Checkout Tarantool
uses: actions/checkout@v4
with:
repository: tarantool/tarantool
ref: '3.9.0'
path: tarantool
persist-credentials: false
- name: Prepare environment
run: sudo sh tarantool/perf/tools/setup_env.sh
- name: Run benchmarks
run: |
/usr/bin/tarantool --version
taskset 0x01fffffe chrt 50 \
/usr/bin/tarantool perf/run.lua ${{ matrix.args }} \
--output perf/output/${{ matrix.scenario }}.json
- name: Aggregate benchmark results
run: |
/usr/bin/tarantool tarantool/perf/tools/aggregate.lua \
--input_dir perf/output \
--output perf/output/summary.txt \
--config_path perf/output/config_bench.json
- name: Send results to InfluxDB

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't manage to find the dashboard on grafana, let's add the link to PR description

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if: github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
env:
INFLUXDB_URL: ${{ secrets.INFLUXDB_URL }}
INFLUXDB_TOKEN: ${{ secrets.INFLUXDB_TOKEN }}
INFLUXDB_BUCKET_ID: ${{ secrets.INFLUXDB_BUCKET_ID }}
run: |
test -s perf/output/summary.txt
url="${INFLUXDB_URL%/}/api/v2/write"
url="$url?org=tarantool&bucket=$INFLUXDB_BUCKET_ID&precision=s"
http_code=$(curl --request POST "$url" \
--fail --silent --show-error --output /dev/null \
--write-out '%{http_code}' \
--retry 3 --retry-delay 5 \
--connect-timeout 10 --max-time 30 \
--header "Authorization: Token $INFLUXDB_TOKEN" \
--header 'Content-Type: text/plain; charset=utf-8' \
--data-binary @perf/output/summary.txt)
printf 'InfluxDB: HTTP %s\n' "$http_code"
test "$http_code" = 204
- uses: actions/setup-python@v5
if: github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
with:
python-version: '3.10'
- name: Analyze results with Otava
if: github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository
env:
INFLUXDB_URL: ${{ secrets.INFLUXDB_URL }}
INFLUXDB_TOKEN: ${{ secrets.INFLUXDB_TOKEN }}
run: |
python -m venv "$RUNNER_TEMP/venv_otava"
source "$RUNNER_TEMP/venv_otava/bin/activate"
pip install influxdb-client==1.44.0 PyYAML==6.0.2 apache-otava==0.8.0
mkdir -p perf/output/otava
cd perf/output/otava
python "$GITHUB_WORKSPACE/tarantool/perf/tools/extract_perf_data.py" \
--influx_url "$INFLUXDB_URL" \
--influx_token "$INFLUXDB_TOKEN" \
--influx_bucket vshard-perf \
--branch_name "$PERF_BRANCH" \
--hours 8760 \
--config ../config_bench.json \
--base_path .
export OTAVA_CONFIG="$PWD/otava.yaml"
otava analyze --magnitude 0.2 tarantool 2>&1 | tee report.txt
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: performance-${{ matrix.scenario }}
retention-days: 21
path: perf/output/
if-no-files-found: ignore

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here're the differences with tarantool's CI, which I don't really like:

Host preparation Runs setup_env.sh: checks isolation/SMT and adjusts CPU frequency, turbo, ASLR, and huge-page settings No equivalent preparation step
CPU placement Fixed CPU mask for CPUs 1–24, with chrt 50 Reads isolated CPUs from sysfs, with chrt 50
Concurrency Cancels superseded developer-branch runs; preserves master/release/tag runs Preserves running jobs, groups by workflow/ref, serializes matrix scenarios
Export Uses perf/tools/aggregate.lua; generates InfluxDB data and analysis configuration Uses its own perf/export.lua; generates InfluxDB data
Analysis Downloads historical results and runs Otava No historical comparison or regression analysis

If we're going to use the setup_env.sh and aggregate.lua from Tarantool, maybe it's better to clone the repo in CI and use them explciitly without copy-pasting, they're not needed locally anyway

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

78 changes: 78 additions & 0 deletions .github/workflows/performance_compare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: performance_compare

on:
pull_request:

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
compare:
name: performance_compare (${{ matrix.scenario }})
runs-on: ubuntu-22.04
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- scenario: router-pressure
args: --replicasets 4 --routers 1 --generators 4
- scenario: storage-pressure
args: --replicasets 1 --routers 4 --generators 16
env:
PERF_BRANCH: ${{ github.event.pull_request.head.ref }}
PERF_COMMIT: ${{ github.event.pull_request.head.sha }}
LC_ALL: C
TZ: UTC

steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.PERF_COMMIT }}
persist-credentials: false
- name: Setup Tarantool
uses: ./.github/actions/setup-tarantool
with:
tarantool_version: '3.9.0'
- name: Checkout base
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.sha }}
path: base
persist-credentials: false
- name: Prepare base benchmarks
run: |
rm -rf base/perf
cp -R perf base/perf
- name: Benchmark base
working-directory: base
env:
PERF_BRANCH: ${{ github.event.pull_request.base.ref }}
PERF_COMMIT: ${{ github.event.pull_request.base.sha }}
run: |
/usr/bin/tarantool --version
/usr/bin/tarantool perf/run.lua ${{ matrix.args }} --repetitions 3 \
--output perf/output/${{ matrix.scenario }}.json
- name: Benchmark PR
run: |
/usr/bin/tarantool perf/run.lua ${{ matrix.args }} --repetitions 3 \
--output perf/output/${{ matrix.scenario }}.json
- name: Compare results
run: |
/usr/bin/tarantool perf/tools/compare.lua \
--base base/perf/output/${{ matrix.scenario }}.json \
--head perf/output/${{ matrix.scenario }}.json
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: performance-compare-${{ matrix.scenario }}
retention-days: 21
path: |
perf/output/
base/perf/output/
if-no-files-found: ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*.log
*.vylog
test/var/
perf/output/
VERSION

CMakeCache.txt
Expand Down
2 changes: 2 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ ignore = {
}

include_files = {
'perf/**/*.lua',
'vshard/**/*.lua',
'test/**/*_test.lua',
'test/luatest_helpers/vtest.lua',
'test/instances/*.lua',
}

exclude_files = {
'perf/output/**',
'test/var/*',
}

Expand Down
107 changes: 107 additions & 0 deletions perf/instance.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
local root = arg[3]
package.path = root .. '/?.lua;' .. root .. '/?/init.lua;' .. package.path

local fio = require('fio')
local log = require('log')
local util = require('perf.lib.util')
local spec = util.read_json(arg[1])
local node = assert(spec.nodes[tonumber(arg[2])], 'Unknown node index')
local cfg, directory = spec.config, fio.dirname(arg[1])
local api = {}
_G.perf = api

local sharding = node.role == 'generator' and {} or spec.sharding
sharding.work_dir = fio.pathjoin(directory, node.name)
sharding.listen = node.uri
sharding.log = fio.pathjoin(directory, node.name .. '.log')
log.cfg({log = sharding.log})

if node.role == 'storage' then
local vutil = require('vshard.util')
local master = spec.nodes[(node.rs - 1) * cfg.instances_per_replicaset + 1]
sharding.replication = node.master and {} or {
'storage:storage@' .. master.uri,
}
if vutil.version_is_at_least(3, 0, 0, nil, 0, 0) then
sharding.bootstrap_strategy = 'config'
sharding.bootstrap_leader = master.uuid
else
-- The master is already running; each replica has one upstream.
sharding.bootstrap_strategy = 'legacy'
end
local storage = require('vshard.storage')
_G.vshard = {storage = storage}
storage.cfg(sharding, node.uuid)
if node.master then
box.schema.user.grant('guest', 'super')
local space = box.schema.space.create('perf_data', {
format = {
{'id', 'unsigned'},
{'bucket_id', 'unsigned'},
{'payload', 'string'},
},
})
space:create_index('pk')
space:create_index('bucket_id', {
parts = {'bucket_id'},
unique = false,
})
end

local function preload()
local payload = string.rep('x', cfg.payload_bytes)
local buckets = storage.buckets_discovery()
for _, bid in ipairs(buckets) do
for key = bid, cfg.rows, cfg.bucket_count do
box.space.perf_data:replace{key, bid, payload}
end
end
return {
rows = box.space.perf_data:count(),
buckets = storage.buckets_count(),
}
end

api.preload = preload
elseif node.role == 'router' then
local router = require('vshard.router')
_G.vshard = {router = router}
router.cfg(sharding)
box.schema.user.grant('guest', 'super')
elseif node.role == 'generator' then
box.cfg(sharding)
box.schema.user.grant('guest', 'super')
local net_box = require('net.box')
local workload = require('perf.lib.workload')
local routers = {}
for _, target in ipairs(spec.nodes) do
if target.role == 'router' then
local connection = net_box.connect(target.uri, {
wait_connected = cfg.startup_timeout_seconds,
})
assert(connection:is_connected(),
'Cannot connect to ' .. target.name .. ': ' ..
tostring(connection.error))
table.insert(routers, connection)
end
end

local function run(case, start_at, duration)
return workload.run(routers, cfg, case, node.index, start_at, duration)
end

local function warmup(case)
return workload.warmup(routers, cfg, case)
end

api.run = run
api.warmup = warmup
else
error('Unknown instance role: ' .. tostring(node.role))
end

local function ready()
return {name = node.name}
end

api.ready = ready
Loading
Loading