Skip to content
Closed
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 }}

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

on:
# TODO: Remove the PR trigger after review.
pull_request:
workflow_dispatch:
schedule:
- cron: '0 1 * * *'

permissions:
contents: read

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

jobs:
check:
if: github.repository == 'tarantool/vshard'
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: baseline
args: --generators 4
- 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: release-master
- name: Run benchmarks
run: |
perf_cpus=$(cat /sys/devices/system/cpu/isolated)
taskset -c "$perf_cpus" chrt 50 \
tarantool perf/run.lua ${{ matrix.args }} \
--output-dir perf/output/ci/${{ matrix.scenario }}
- name: Export results for InfluxDB
run: |
tarantool perf/export.lua \
--input-dir perf/output/ci \
--output perf/output/summary.txt
- name: Send results to InfluxDB
# TODO: Remove after review.
if: github.event_name != 'pull_request'
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
- name: Save results and logs
if: always()
uses: actions/upload-artifact@v4
with:
name: performance-${{ matrix.scenario }}
retention-days: 21
path: 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
57 changes: 57 additions & 0 deletions perf/export.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env tarantool
local fio = require('fio')
local root = fio.abspath(fio.pathjoin(fio.dirname(arg[0]), '..'))
package.path = root .. '/?.lua;' .. root .. '/?/init.lua;' .. package.path

local argparse = require('internal.argparse')
local datetime = require('datetime')
local util = require('perf.lib.util')

local opts = argparse.parse(arg, {
{'input-dir', 'string'},
{'output', 'string'},
})
assert(#opts == 0, 'Unexpected positional arguments')
local input_dir = opts['input-dir']
assert(input_dir and fio.path.is_dir(input_dir), 'Invalid --input-dir')
assert(opts.output, 'Missing --output')

local function escape_tag(value)
return (value:gsub('[ ,=]', '\\%1'))
end

local function quote_field(value)
return '"' .. value:gsub('[\\"]', '\\%1') .. '"'
end

local fmt = 'vshard,operation=%s,%s items_per_second=%.17g,%s %.0f\n'
local lines = {}
local scenarios = assert(fio.listdir(input_dir))
table.sort(scenarios)
for _, scenario in ipairs(scenarios) do
local path = fio.pathjoin(input_dir, scenario, 'results.json')
if not fio.path.is_file(path) then
goto continue
end
local report = util.read_json(path)
if report.status ~= 'complete' then
goto continue
end
local context = report.context
local date = datetime.parse(context.date)
local tags = ('configuration=%s,branch=%s'):format(
escape_tag(scenario), escape_tag(context.vshard_branch))
local fields = ('commit=%s,tarantool_version=%s'):format(
quote_field(context.vshard_commit),
quote_field(context.tarantool_version))
for _, bench in ipairs(report.benchmarks) do
local line = fmt:format(escape_tag(bench.name), tags,
bench.items_per_second, fields, date.epoch)
table.insert(lines, line)
end
::continue::
end

local output = assert(io.open(opts.output, 'wb'))
assert(output:write(table.concat(lines)))
assert(output:close())
105 changes: 105 additions & 0 deletions perf/instance.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
local root = arg[3]
package.path = root .. '/?.lua;' .. root .. '/?/init.lua;' .. package.path

local fio = require('fio')
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')

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 noop()
return true
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.noop = noop
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

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

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

api.ready = ready
Loading
Loading