Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Sergey Kaplun <skaplun@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v1 luajit 38/41] perf: add aggregator helper for bench statistics
Date: Tue, 18 Nov 2025 15:31:02 +0300	[thread overview]
Message-ID: <4187d8d3-4d9d-466c-869c-f3dde532c5e5@tarantool.org> (raw)
In-Reply-To: <edcba097e9269d0814359a276d99f79b4f13ca09.1761301736.git.skaplun@tarantool.org>

[-- Attachment #1: Type: text/plain, Size: 6019 bytes --]

Hi, Sergey,

thanks for the patch! See my comments.

Sergey

On 10/24/25 14:00, Sergey Kaplun wrote:
> This patch adds a helper script to aggregate the benchmark results from
> JSON files to the format parsable by the InfluxDB line protocol [1].

format cannot be parsed by protocol, please rephrase.

Something like "the format compatible with the InfluxDB line protocol"

>
> All JSON files from each suite in the <perf/output> directory are
> considered as the benchmark results and aggregated into the
> <perf/output/summary.txt> file that can be posted to the InfluxDB. The
> results are aggregated via the new target LuaJIT-perf-aggregate.
may be say that cjson is required?
>
> [1]:https://docs.influxdata.com/influxdb/v2/reference/syntax/line-protocol/
> ---
>   perf/CMakeLists.txt        |  13 ++++
>   perf/helpers/aggregate.lua | 124 +++++++++++++++++++++++++++++++++++++
>   2 files changed, 137 insertions(+)
>   create mode 100644 perf/helpers/aggregate.lua
>
> diff --git a/perf/CMakeLists.txt b/perf/CMakeLists.txt
> index cc3c312f..68e561fd 100644
> --- a/perf/CMakeLists.txt
> +++ b/perf/CMakeLists.txt
> @@ -97,3 +97,16 @@ add_custom_target(${PROJECT_NAME}-perf
>   add_custom_target(${PROJECT_NAME}-perf-console
>     DEPENDS LuaJIT-benches-console
>   )
> +
> +set(PERF_SUMMARY ${PERF_OUTPUT_DIR}/summary.txt)
> +add_custom_target(${PROJECT_NAME}-perf-aggregate
> +  BYPRODUCTS ${PERF_SUMMARY}
> +  COMMENT "Aggregate performance test results into ${PERF_SUMMARY}"
> +  COMMAND ${CMAKE_COMMAND} -E env
> +    LUA_CPATH="${LUA_CPATH}"
> +      ${LUAJIT_BINARY} ${CMAKE_CURRENT_SOURCE_DIR}/helpers/aggregate.lua
> +        ${PERF_SUMMARY}
> +        ${PERF_OUTPUT_DIR}
> +  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
> +  DEPENDS luajit-main
> +)
> diff --git a/perf/helpers/aggregate.lua b/perf/helpers/aggregate.lua
> new file mode 100644
> index 00000000..12a8ab89
> --- /dev/null
> +++ b/perf/helpers/aggregate.lua
> @@ -0,0 +1,124 @@
> +local json = require('cjson')
What if cjson is absent? Do we want to handle error?
> +
> +-- File to aggregate the benchmark results from JSON files to the
> +-- format parsable by the InfluxDB line protocol [1]:
> +-- <measurement>,<tag_set> <field_set> <timestamp>
> +--
> +-- <tag_set> and <field_set> have the following format:
> +-- <key1>=<value1>,<key2>=<value2>
> +--
> +-- The reported tag set is a set of values that can be used for
> +-- filtering data (i.e., branch or benchmark name).
> +--
> +-- luacheck: push no max comment line length
> +--
> +-- [1]:https://docs.influxdata.com/influxdb/v2/reference/syntax/line-protocol/
> +--
> +-- luacheck: pop

I propose to document command-line options

(1st arg is output file, 2nd arg is a dir, "current dir by default"),

env variables (PERF_COMMIT, PERF_BRANCH) and requirements

(git is an optional requirement, cjson Lua module is mandatory).

> +
> +local output = assert(arg[1], 'Output file is required as the first argument')
> +local input_dir = arg[2] or '.'
> +
> +local out_fh = assert(io.open(output, 'w+'))
> +
> +local function exec(cmd)
> +  return io.popen(cmd):read('*all'):gsub('%s+$', '')
> +end
> +
> +local commit = os.getenv('PERF_COMMIT') or exec('git rev-parse --short HEAD')
> +assert(commit, 'can not determine the commit')
> +
> +local branch = os.getenv('PERF_BRANCH') or
> +  exec('git rev-parse --abbrev-ref HEAD')
> +assert(branch, 'can not determine the branch')
> +
> +-- Not very robust, but OK for our needs.
> +local function listdir(path)
> +  local handle = io.popen('ls -1 ' .. path)
> +
> +  local files = {}
> +  for file inhandle:lines() do
> +    table.insert(files, file)
> +  end
> +
> +  return files
> +end
> +
> +local tag_set = {branch = branch}
> +
> +local function table_plain_copy(src)
> +  local dst = {}
> +  for k, v in pairs(src) do
> +    dst[k] = v
> +  end
> +  return dst
> +end
> +
> +local function read_all(file)
> +  local fh = assert(io.open(file, 'rb'))
> +  local content =fh:read('*all')
> +fh:close()
> +  return content
> +end
> +
> +local REPORTED_FIELDS = {
> +  'cpu_time',
> +  'items_per_second',
> +  'iterations',
> +  'real_time',
> +}
> +
> +local function influx_kv(tab)
> +  local kv_string = {}
> +  for k, v in pairs(tab) do
> +    table.insert(kv_string, ('%s=%s'):format(k, v))
> +  end
> +  return table.concat(kv_string, ',')
> +end
> +
> +local time = os.time()
> +local function influx_line(measurement, tags, fields)
> +  return ('%s,%s %s %d\n'):format(measurement, influx_kv(tags),
> +          influx_kv(fields), time)
> +end
> +
> +for _, suite_name in pairs(listdir(input_dir)) do
> +  -- May list the report file, but will be ignored by the
> +  -- condition below.
> +  local suite_dir = ('%s/%s'):format(input_dir, suite_name)
> +  for _, file in pairs(listdir(suite_dir)) do
> +    -- Skip files in which we are not interested.
> +    if notfile:match('%.json$') then goto continue end
> +
> +    local data = read_all(('%s/%s'):format(suite_dir, file))
> +    local bench_name =file:match('([^/]+)%.json')
> +    local bench_data = json.decode(data)
> +    local benchmarks = bench_data.benchmarks
> +    local arch = bench_data.context.arch
> +    local gc64 = bench_data.context.gc64
> +    local jit = bench_data.context.jit
> +
> +    for _, bench in ipairs(benchmarks) do
> +      local full_tag_set = table_plain_copy(tag_set)
> +      full_tag_set.name = bench.name
> +      full_tag_set.suite = suite_name
> +      full_tag_set.arch = arch
> +      full_tag_set.gc64 = gc64
> +      full_tag_set.jit = jit
> +
> +      -- Save the commit as a field, since we don't want to filter
> +      -- benchmarks by the commit (one point of data).
> +      local field_set = {commit = ('"%s"'):format(commit)}
> +
> +      for _, field in ipairs(REPORTED_FIELDS) do
> +          field_set[field] = bench[field]
> +      end
> +
> +      local line = influx_line(bench_name, full_tag_set, field_set)
> +      out_fh:write(line)
> +    end
> +    ::continue::
> +  end
> +end
> +
> +out_fh:close()

[-- Attachment #2: Type: text/html, Size: 7711 bytes --]

  reply	other threads:[~2025-11-18 12:31 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-24 10:50 [Tarantool-patches] [PATCH v1 luajit 00/41] LuaJIT performance testing Sergey Kaplun via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 01/41] perf: add LuaJIT-test-cleanup perf suite Sergey Kaplun via Tarantool-patches
2025-11-11 14:28   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 02/41] perf: introduce clock module Sergey Kaplun via Tarantool-patches
2025-11-11 14:28   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 03/41] perf: introduce bench module Sergey Kaplun via Tarantool-patches
2025-11-11 15:41   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 04/41] perf: adjust array3d in LuaJIT-benches Sergey Kaplun via Tarantool-patches
2025-11-13 11:06   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 05/41] perf: adjust binary-trees " Sergey Kaplun via Tarantool-patches
2025-11-13 11:06   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 06/41] perf: adjust chameneos " Sergey Kaplun via Tarantool-patches
2025-11-13 11:11   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 07/41] perf: adjust coroutine-ring " Sergey Kaplun via Tarantool-patches
2025-11-13 11:17   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 08/41] perf: adjust euler14-bit " Sergey Kaplun via Tarantool-patches
2025-11-13 11:44   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 09/41] perf: adjust fannkuch " Sergey Kaplun via Tarantool-patches
2025-11-17  8:36   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 10/41] perf: adjust fasta " Sergey Kaplun via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 11/41] perf: adjust k-nucleotide " Sergey Kaplun via Tarantool-patches
2025-11-17  8:36   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 12/41] perf: adjust life " Sergey Kaplun via Tarantool-patches
2025-11-17  8:35   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 13/41] perf: adjust mandelbrot-bit " Sergey Kaplun via Tarantool-patches
2025-11-17 13:26   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 14/41] perf: adjust mandelbrot " Sergey Kaplun via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 15/41] perf: adjust md5 " Sergey Kaplun via Tarantool-patches
2025-11-17 13:26   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 16/41] perf: adjust meteor " Sergey Kaplun via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 17/41] perf: adjust nbody " Sergey Kaplun via Tarantool-patches
2025-11-17 13:26   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 18/41] perf: adjust nsieve-bit-fp " Sergey Kaplun via Tarantool-patches
2025-11-17 13:26   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 19/41] perf: adjust nsieve-bit " Sergey Kaplun via Tarantool-patches
2025-11-17 13:26   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 20/41] perf: adjust nsieve " Sergey Kaplun via Tarantool-patches
2025-11-17 13:25   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 21/41] perf: adjust partialsums " Sergey Kaplun via Tarantool-patches
2025-11-17 13:25   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 22/41] perf: adjust pidigits-nogmp " Sergey Kaplun via Tarantool-patches
2025-11-17 13:25   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 23/41] perf: adjust ray " Sergey Kaplun via Tarantool-patches
2025-11-17 13:25   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 24/41] perf: adjust recursive-ack " Sergey Kaplun via Tarantool-patches
2025-11-17 13:25   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 25/41] perf: adjust recursive-fib " Sergey Kaplun via Tarantool-patches
2025-11-17 13:59   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 26/41] perf: adjust revcomp " Sergey Kaplun via Tarantool-patches
2025-11-17 13:59   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 27/41] perf: adjust scimark-2010-12-20 " Sergey Kaplun via Tarantool-patches
2025-11-17 13:56   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 28/41] perf: move <scimark_lib.lua> to <libs/> directory Sergey Kaplun via Tarantool-patches
2025-11-17 13:58   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 29/41] perf: adjust scimark-fft in LuaJIT-benches Sergey Kaplun via Tarantool-patches
2025-11-17 14:00   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 30/41] perf: adjust scimark-lu " Sergey Kaplun via Tarantool-patches
2025-10-24 11:00   ` Sergey Kaplun via Tarantool-patches
2025-10-24 11:01   ` Sergey Kaplun via Tarantool-patches
2025-11-17 14:07   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 31/41] perf: add scimark-mc " Sergey Kaplun via Tarantool-patches
2025-10-24 11:00   ` Sergey Kaplun via Tarantool-patches
2025-10-24 11:02   ` Sergey Kaplun via Tarantool-patches
2025-11-17 14:09   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 32/41] perf: adjust scimark-sor " Sergey Kaplun via Tarantool-patches
2025-10-24 11:00   ` Sergey Kaplun via Tarantool-patches
2025-10-24 11:02   ` Sergey Kaplun via Tarantool-patches
2025-11-17 14:11   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 10:50 ` [Tarantool-patches] [PATCH v1 luajit 33/41] perf: adjust scimark-sparse " Sergey Kaplun via Tarantool-patches
2025-10-24 11:00   ` Sergey Kaplun via Tarantool-patches
2025-10-24 11:03   ` Sergey Kaplun via Tarantool-patches
2025-11-17 14:15   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 11:00 ` [Tarantool-patches] [PATCH v1 luajit 34/41] perf: adjust series " Sergey Kaplun via Tarantool-patches
2025-11-17 14:19   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 11:00 ` [Tarantool-patches] [PATCH v1 luajit 35/41] perf: adjust spectral-norm " Sergey Kaplun via Tarantool-patches
2025-11-17 14:23   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 11:00 ` [Tarantool-patches] [PATCH v1 luajit 36/41] perf: adjust sum-file " Sergey Kaplun via Tarantool-patches
2025-10-24 11:00 ` [Tarantool-patches] [PATCH v1 luajit 37/41] perf: add CMake infrastructure Sergey Kaplun via Tarantool-patches
2025-11-18 12:21   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 11:00 ` [Tarantool-patches] [PATCH v1 luajit 38/41] perf: add aggregator helper for bench statistics Sergey Kaplun via Tarantool-patches
2025-11-18 12:31   ` Sergey Bronnikov via Tarantool-patches [this message]
2025-10-24 11:00 ` [Tarantool-patches] [PATCH v1 luajit 39/41] perf: add a script for the environment setup Sergey Kaplun via Tarantool-patches
2025-11-18 12:36   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 11:00 ` [Tarantool-patches] [PATCH v1 luajit 40/41] perf: provide CMake option to setup the benchmark Sergey Kaplun via Tarantool-patches
2025-11-18 12:51   ` Sergey Bronnikov via Tarantool-patches
2025-10-24 11:00 ` [Tarantool-patches] [PATCH v1 luajit 41/41] ci: introduce the performance workflow Sergey Kaplun via Tarantool-patches
2025-11-18 13:08   ` Sergey Bronnikov via Tarantool-patches
2025-11-18 13:13   ` Sergey Bronnikov via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4187d8d3-4d9d-466c-869c-f3dde532c5e5@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=sergeyb@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v1 luajit 38/41] perf: add aggregator helper for bench statistics' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox