[Tarantool-patches] [PATCH v1 luajit 19/41] perf: adjust nsieve-bit in LuaJIT-benches

Sergey Kaplun skaplun at tarantool.org
Fri Dec 26 11:25:49 MSK 2025


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

On 17.11.25, Sergey Bronnikov wrote:
> Hi, Sergey,
> 
> thanks for the patch!
> 
> Sergey
> 
> On 10/24/25 13:50, 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/nsieve-bit.lua | 35 +++++++++++++++++++++++++-----
> >   1 file changed, 30 insertions(+), 5 deletions(-)
> >
> > diff --git a/perf/LuaJIT-benches/nsieve-bit.lua b/perf/LuaJIT-benches/nsieve-bit.lua
> > index 820a3726..4858e9e2 100644
> > --- a/perf/LuaJIT-benches/nsieve-bit.lua
> > +++ b/perf/LuaJIT-benches/nsieve-bit.lua
> > @@ -1,3 +1,4 @@

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

===================================================================
diff --git a/perf/LuaJIT-benches/nsieve-bit.lua b/perf/LuaJIT-benches/nsieve-bit.lua
index e2c6f52c..dd85dad5 100644
--- a/perf/LuaJIT-benches/nsieve-bit.lua
+++ b/perf/LuaJIT-benches/nsieve-bit.lua
@@ -1,3 +1,9 @@
+-- Benchmark to check the performance of bitwise arithmetics and
+-- access to the array structure. This benchmark finds all prime
+-- numbers in a given segment. This is the bit variation.
+-- For the details see:
+-- https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
+
 local bench = require("bench").new(arg)
 
 local bit = require("bit")
===================================================================

> > +local bench = require("bench").new(arg)
> >   
> >   local bit = require("bit")
> >   local band, bxor, rshift, rol = bit.band, bit.bxor, bit.rshift, bit.rol
> > @@ -17,11 +18,35 @@ local function nsieve(p, m)
> >     return count
> >   end
> >   
> > -local N = tonumber(arg and arg[1]) or 1
> > +local DEFAULT_N = 12
> Why 12?

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.

> > +local N = tonumber(arg and arg[1]) or DEFAULT_N
> >   if N < 2 then N = 2 end
> >   local primes = {}
> >   
> > -for i=0,2 do
> add more whitespaces, here and below

This is removed line, fixed in the corresponding added line.

> > -  local m = (2^(N-i))*10000
> > -  io.write(string.format("Primes up to %8d %8d\n", m, nsieve(primes, m)))
> io.write is lost, is it intentional?

Yes, it is checked via the checker function.

> > -end
> > +local benchmark
> > +benchmark = {
> > +  name = "nsieve_bit",
> > +  payload = function()
> > +    local res = {}
> > +    local items = 0
> > +    for i=0,2 do
> > +      local m = (2^(N-i))*10000
> add more whitespaces

Fixed.

===================================================================
diff --git a/perf/LuaJIT-benches/nsieve-bit.lua b/perf/LuaJIT-benches/nsieve-bit.lua
index 4858e9e2..e2c6f52c 100644
--- a/perf/LuaJIT-benches/nsieve-bit.lua
+++ b/perf/LuaJIT-benches/nsieve-bit.lua
@@ -29,8 +29,8 @@ benchmark = {
   payload = function()
     local res = {}
     local items = 0
-    for i=0,2 do
-      local m = (2^(N-i))*10000
+    for i = 0, 2 do
+      local m = (2 ^ (N - i)) * 10000
       items = items + m
       res[i] = nsieve(primes, m)
     end
===================================================================

> > +      items = items + m

<snipped>

-- 
Best regards,
Sergey Kaplun


More information about the Tarantool-patches mailing list