Repository navigation
perf: add configurable benchmarks #681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,172 @@ | ||||||||||||||||||||
| name: performance | ||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
If we're going to use the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||||||||||||||
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| *.log | ||
| *.vylog | ||
| test/var/ | ||
| perf/output/ | ||
| VERSION | ||
|
|
||
| CMakeCache.txt | ||
|
|
||
| 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 |
There was a problem hiding this comment.
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-hostedfromself-hostedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done