[Tarantool-patches] [PATCH v1 luajit 36/41] perf: adjust sum-file in LuaJIT-benches
Sergey Kaplun
skaplun at tarantool.org
Fri Dec 26 11:38:24 MSK 2025
Hi, Sergey!
Thanks for the review.
Please, consider my answers below.
On 23.12.25, Sergey Bronnikov wrote:
> on execution I got an error:
>
> ./build/src/luajit: perf/LuaJIT-benches/sum-file.lua:11: attempt to
> perform arithmetic on local 'line' (a string value)
How do you run the benchmark?
| LUA_PATH="perf/utils/?.lua;;" src/luajit perf/LuaJIT-benches/sum-file.lua < perf/LuaJIT-benches/SUMCOL_5000.txt
| -------------------------------------------------------------------------------------------------------------
| Benchmark Time CPU Iterations UserCounters...
| -------------------------------------------------------------------------------------------------------------
| sum_file 6.21 s 6.20 s 4 items_per_second=3.219M/s
The input file contains only numbers. See the comment in the test.
>
> On 10/24/25 14:00, Sergey Kaplun wrote:
> > This patch adjusts the aforementioned test to use the benchmark
> > framework introduced before. The default arguments are adjusted
> > according to the <PARAM_x86.txt> file. The arguments to the script still
> > can be provided in the command line run.
> >
> > The input for the test is redirected from the generated file
> > <SUMCOL_5000.txt>. This file is the result of concatenation of the
> > <SUMCOL_1.txt> 5000 times.
> > ---
> > perf/LuaJIT-benches/sum-file.lua | 29 ++++++++++++++++++++++++-----
> > 1 file changed, 24 insertions(+), 5 deletions(-)
> >
> > diff --git a/perf/LuaJIT-benches/sum-file.lua b/perf/LuaJIT-benches/sum-file.lua
> > index c9e618fd..270c1865 100644
> > --- a/perf/LuaJIT-benches/sum-file.lua
> > +++ b/perf/LuaJIT-benches/sum-file.lua
> > @@ -1,6 +1,25 @@
Added the comment with the short benchmark description, as we
discussed offline:
===================================================================
diff --git a/perf/LuaJIT-benches/sum-file.lua b/perf/LuaJIT-benches/sum-file.lua
index 270c1865..6af2b4a5 100644
--- a/perf/LuaJIT-benches/sum-file.lua
+++ b/perf/LuaJIT-benches/sum-file.lua
@@ -1,3 +1,7 @@
+-- The benchmark to check the performance of reading lines from
+-- stdin and sum the given numbers (the strings converted to
+-- numbers by the VM automatically).
+
local bench = require("bench").new(arg)
-- XXX: The input file is generated from <SUMCOL_1.txt> by
===================================================================
> > +local bench = require("bench").new(arg)
<snipped>
> > +-- XXX: The input file is generated from <SUMCOL_1.txt> by
> > +-- repeating it 5000 times. The <SUMCOL_1.txt> contains 1000 lines
> > +-- with the total sum of 500.
> > +bench:add({
> > + name = "sum_file",
> > + payload = function()
> > + local sum = 0
> > + for line in io.lines() do
> > + sum = sum + line
> You obviously cannot sum a string and a number.
I can:
| luajit -e 'print(1 + "1")'
| 2
I haven't changed this line.
> > + end
<snipped>
--
Best regards,
Sergey Kaplun
More information about the Tarantool-patches
mailing list