diff --git a/.env b/.env new file mode 100644 index 0000000..70bfda2 --- /dev/null +++ b/.env @@ -0,0 +1,4 @@ +BENCHER_PROJECT=xqueue +BENCHER_ADAPTER=json +BENCHER_TESTBED=localhost +LUABENCH_USE_BMF=true diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml new file mode 100644 index 0000000..7add8d7 --- /dev/null +++ b/.github/workflows/benchmark.yml @@ -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 diff --git a/.luabench b/.luabench new file mode 100644 index 0000000..f14e78d --- /dev/null +++ b/.luabench @@ -0,0 +1,2 @@ +jit = 'on' +duration = '10s' \ No newline at end of file diff --git a/benchmarks/001_put_take_bench.lua b/benchmarks/001_put_take_bench.lua index 61a3bbc..9951569 100644 --- a/benchmarks/001_put_take_bench.lua +++ b/benchmarks/001_put_take_bench.lua @@ -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 = {} diff --git a/benchmarks/002_initial_stat_bench.lua b/benchmarks/002_initial_stat_bench.lua index 69282a6..39a0d30 100644 --- a/benchmarks/002_initial_stat_bench.lua +++ b/benchmarks/002_initial_stat_bench.lua @@ -9,7 +9,7 @@ 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' }, @@ -17,8 +17,8 @@ lb.before_all(function() }, }) - 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 }) @@ -28,13 +28,13 @@ 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) @@ -42,7 +42,7 @@ 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 @@ -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