[Tarantool-patches] [PATCH v1 luajit 04/41] perf: adjust array3d in LuaJIT-benches
Sergey Kaplun
skaplun at tarantool.org
Fri Dec 26 11:07:23 MSK 2025
Hi, Sergey!
Thanks for the review!
Please consider my comments below.
On 13.11.25, Sergey Bronnikov wrote:
> Hi, Sergey!
>
> thanks for the patch!
>
> On 10/24/25 13:50, Sergey Kaplun wrote:
<snipped>
Also, added the comment with the benchmark description as we discussed
offline.
===================================================================
diff --git a/perf/LuaJIT-benches/array3d.lua b/perf/LuaJIT-benches/array3d.lua
index 1062fff0..4d88432d 100644
--- a/perf/LuaJIT-benches/array3d.lua
+++ b/perf/LuaJIT-benches/array3d.lua
@@ -1,3 +1,7 @@
+-- The benchmark to measure simple operations on array-like data
+-- structures.
+-- Here, a 3D array is represented as a contiguous 1D array.
+
local bench = require("bench").new(arg)
local function array_set(self, x, y, z, p)
===================================================================
> > -local arr = array_new(dim, dim, dim, packed)
> >
> > -for x,y,z inarr:points() do
> > -arr:set(x, y, z, x*x)
> > -end
> > -assert(arr.image[dim^3-1] == (dim-1)^2)
> > +bench:add({
> > + name = "array3d",
> > + checker = function(arr)
> > + assert(arr.image[dim^3-1] == (dim-1)^2)
> > + return true
> > + end,
> > + payload = function()
> > + local arr = array_new(dim, dim, dim, packed)
> > + for x,y,z inarr:points() do
> please add whitespaces after commas
Added:
===================================================================
diff --git a/perf/LuaJIT-benches/array3d.lua b/perf/LuaJIT-benches/array3d.lua
index 75ab5b01..1062fff0 100644
--- a/perf/LuaJIT-benches/array3d.lua
+++ b/perf/LuaJIT-benches/array3d.lua
@@ -60,7 +60,7 @@ bench:add({
end,
payload = function()
local arr = array_new(dim, dim, dim, packed)
- for x,y,z in arr:points() do
+ for x, y, z in arr:points() do
arr:set(x, y, z, x*x)
end
return arr
===================================================================
But I'm not sure that we need to refactor each part of the code this
way. Anyway, I'm OK with reformatting this since we already touched this
chunk.
> > +arr:set(x, y, z, x*x)
> > + end
> > + return arr
> > + end,
> > + items = dim * dim * dim,
> > + -- Limit the number of iterations to avoid OOM errors for
> > + -- non-GC64 builds.
> > + iterations = 5,
Replaced to 4 iterations, since sometimes it strikes the OOM on the
runner.
===================================================================
diff --git a/perf/LuaJIT-benches/array3d.lua b/perf/LuaJIT-benches/array3d.lua
index 4d88432d..80562706 100644
--- a/perf/LuaJIT-benches/array3d.lua
+++ b/perf/LuaJIT-benches/array3d.lua
@@ -72,7 +72,7 @@ bench:add({
items = dim * dim * dim,
-- Limit the number of iterations to avoid OOM errors for
-- non-GC64 builds.
- iterations = 5,
+ iterations = 4,
})
bench:run_and_report()
===================================================================
> > +})
> >
> > +bench:run_and_report()
>
> Looks like benchmark min time does not work as expected:
>
> [1] ~/sources/MRG/tarantool/third_party/luajit $ time ./build/src/luajit
> perf/LuaJIT-benches/array3d.lua --benchmark_min_time=10
> -------------------------------------------------------------------------------------------------------------
> Benchmark Time CPU Iterations
> UserCounters...
> -------------------------------------------------------------------------------------------------------------
> array3d 2.10 s 2.13 s
> 5 items_per_second=64.370M/s
>
> real 0m2.333s
> user 0m1.869s
> sys 0m0.461s
> [1] ~/sources/MRG/tarantool/third_party/luajit $
>
> --benchmark_min_time set to 10 sec, but benchmark.lua reports "2.10 s"
> and time reported by `time` utility
>
> is less than 10 sec.
It works exactly as expected, since this option is superseded by the
`iterations` value in the becnhmark configuration, see the corresponding
comment in the code for the rationale in this particular benchmark.
Also, it is mentioned in the commit message.
--
Best regards,
Sergey Kaplun
More information about the Tarantool-patches
mailing list