Skip to content

Commit

Permalink
ci: run benchmarks in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladislav Grubov committed Aug 7, 2024
1 parent b0a6768 commit 4776929
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BENCHER_PROJECT=xqueue
BENCHER_ADAPTER=json
BENCHER_TESTBED=localhost
LUABENCH_USE_BMF=true
25 changes: 25 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Benchmarking code

on:
- push

jobs:
run-unit-benchmarks:
runs-on: ubuntu-latest
strategy:
matrix:
version: ["1.10.15", "2.10.6", "2.11.0", "2.11.2"]
steps:
- uses: actions/checkout@v4
- uses: tarantool/setup-tarantool@v3
with:
tarantool-version: '${{matrix.version}}'
- name: install luabench
run: tarantoolctl rocks --server https://moonlibs.org install luabench 0.3.0
- name: run benchmarks
env:
LUABENCH_USE_BMF: false
LUABENCH_TIMEOUT: 60
LUABENCH_DURATION: '10s'
run: |
.rocks/bin/luabench
2 changes: 2 additions & 0 deletions .luabench
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
jit = 'on'
duration = '10s'
2 changes: 1 addition & 1 deletion benchmarks/001_put_take_bench.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ xqueue.upgrade(box.space.queue, {

local queue = box.space.queue --[[@as xqueue.space]]
lb.before_all(function() queue:truncate() end)
lb.after_all(function() queue:truncate() box.snapshot() end)
lb.after_all(function() box.space.queue:truncate() box.snapshot() end)

local M = {}

Expand Down
14 changes: 7 additions & 7 deletions benchmarks/002_initial_stat_bench.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ local STATUS = { 'R', 'T', 'W', 'B', 'Z', 'D' }
lb.before_all(function()
box.cfg{ memtx_memory = 2^30 }

box.schema.space.create('queue', {
box.schema.space.create('q1', {
if_not_exists = true,
format = {
{ name = 'id', type = 'unsigned' },
{ name = 'status', type = 'string' },
},
})

box.space.queue:create_index('primary', { parts = {'id'}, if_not_exists = true })
box.space.queue:create_index('xq', { parts = {'status', 'id'}, if_not_exists = true })
box.space.q1:create_index('primary', { parts = {'id'}, if_not_exists = true })
box.space.q1:create_index('xq', { parts = {'status', 'id'}, if_not_exists = true })

if fiber.extend_slice then
fiber.extend_slice({ err = 3600, warn = 3600 })
Expand All @@ -28,21 +28,21 @@ lb.before_all(function()
local tab = {}
for no = 1, 4e6 do
tab[1], tab[2] = no, STATUS[math.random(#STATUS)]
box.space.queue:replace(tab)
box.space.q1:replace(tab)
end
box.commit()
end)

lb.after_all(function()
box.space.queue:drop()
box.space.q1:drop()
box.snapshot()
end)

function M.bench_iterate_all(b)
local limit = b.N
local scanned = 0
local stats = {}
for _, t in box.space.queue:pairs({}, { iterator = "ALL" }) do
for _, t in box.space.q1:pairs({}, { iterator = "ALL" }) do
stats[t.status] = (stats[t.status] or 0ULL) + 1
scanned = scanned + 1
if limit == scanned then break end
Expand All @@ -53,7 +53,7 @@ end
function M.bench_count(b)
local total = 0
for _, s in pairs(STATUS) do
total = total + box.space.queue.index.xq:count(s)
total = total + box.space.q1.index.xq:count(s)
if b.N < total then break end
end
b.N = total
Expand Down

0 comments on commit 4776929

Please sign in to comment.