[Tarantool-patches] [PATCH v1 luajit 35/41] perf: adjust spectral-norm in LuaJIT-benches

Sergey Kaplun skaplun at tarantool.org
Fri Dec 26 11:37:22 MSK 2025


Hi, Sergey!
Thanks for the review.
Please, consider my answers below.

On 17.11.25, Sergey Bronnikov wrote:
> Hi, Sergey,
> 
>   thanks for the patch! See my comments below.
> 
> Sergey
> 
> 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.
> > ---
> >   perf/LuaJIT-benches/spectral-norm.lua | 40 +++++++++++++++++++--------
> >   1 file changed, 29 insertions(+), 11 deletions(-)
> >
> > diff --git a/perf/LuaJIT-benches/spectral-norm.lua b/perf/LuaJIT-benches/spectral-norm.lua
> > index ecc80112..6e63cd47 100644
> > --- a/perf/LuaJIT-benches/spectral-norm.lua
> > +++ b/perf/LuaJIT-benches/spectral-norm.lua

Added the comment with the short benchmark description, as we
discussed offline:

===================================================================
diff --git a/perf/LuaJIT-benches/spectral-norm.lua b/perf/LuaJIT-benches/spectral-norm.lua
index ae0a6b6d..7a7712a0 100644
--- a/perf/LuaJIT-benches/spectral-norm.lua
+++ b/perf/LuaJIT-benches/spectral-norm.lua
@@ -1,3 +1,10 @@
+-- The benchmark to check the performance of FP arithmetics and
+-- function call inlining in the inner loops.
+-- The benchmark calculates the spectral norm of an infinite
+-- matrix.
+-- For more details see:
+-- https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/spectralnorm.html
+
 local bench = require("bench").new(arg)
 
 local function A(i, j)
===================================================================

> > @@ -1,3 +1,4 @@
> > +local bench = require("bench").new(arg)
> >   
> >   local function A(i, j)
> >     local ij = i+j-1
> > @@ -25,16 +26,33 @@ local function AtAv(x, y, t, N)
> >     Atv(t, y, N)
> >   end
> >   
> > -local N = tonumber(arg and arg[1]) or 100
> > -local u, v, t = {}, {}, {}
> > -for i=1,N do u[i] = 1 end
> > +local N = tonumber(arg and arg[1]) or 3000
> Why it was changed to 3000?

It is the default for x86 arch. I've taken the values from PARAMS_x86,
since this is the most important architecture for the Tarantool, see the
commit message.

> >   
> > -for i=1,10 do AtAv(u, v, t, N) AtAv(v, u, t, N) end
> > +bench:add({
> > +  name = "spectral_norm",
> > +  checker = function(res)
> > +    -- XXX: Empirical value.
> > +    if N > 66 then
> > +      assert(math.abs(res - 1.27422) < 0.00001)
> > +    end
> > +    return true
> > +  end,
> > +  payload = function()
> > +    local u, v, t = {}, {}, {}
> > +    for i=1,N do u[i] = 1 end
> add more whitespaces, here and below

Added:

===================================================================
diff --git a/perf/LuaJIT-benches/spectral-norm.lua b/perf/LuaJIT-benches/spectral-norm.lua
index 6e63cd47..ae0a6b6d 100644
--- a/perf/LuaJIT-benches/spectral-norm.lua
+++ b/perf/LuaJIT-benches/spectral-norm.lua
@@ -39,15 +39,15 @@ bench:add({
   end,
   payload = function()
     local u, v, t = {}, {}, {}
-    for i=1,N do u[i] = 1 end
+    for i = 1, N do u[i] = 1 end
 
-    for i=1,10 do AtAv(u, v, t, N) AtAv(v, u, t, N) end
+    for _ = 1, 10 do AtAv(u, v, t, N) AtAv(v, u, t, N) end
 
     local vBv, vv = 0, 0
-    for i=1,N do
+    for i = 1, N do
       local ui, vi = u[i], v[i]
-      vBv = vBv + ui*vi
-      vv = vv + vi*vi
+      vBv = vBv + ui * vi
+      vv = vv + vi * vi
     end
     return math.sqrt(vBv / vv)
   end,
===================================================================

<snipped>

-- 
Best regards,
Sergey Kaplun


More information about the Tarantool-patches mailing list