[Tarantool-patches] [PATCH v1 luajit 15/41] perf: adjust md5 in LuaJIT-benches

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


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

On 17.11.25, Sergey Bronnikov wrote:
> Hi, Sergey,
> 
> thanks for the patch! See  my comments.
> 
> 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/md5.lua | 27 ++++++++++++++++++++-------
> >   1 file changed, 20 insertions(+), 7 deletions(-)
> >
> > diff --git a/perf/LuaJIT-benches/md5.lua b/perf/LuaJIT-benches/md5.lua
> > index fdf6b4a7..5ec67527 100644
> > --- a/perf/LuaJIT-benches/md5.lua
> > +++ b/perf/LuaJIT-benches/md5.lua

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

===================================================================
diff --git a/perf/LuaJIT-benches/md5.lua b/perf/LuaJIT-benches/md5.lua
index 2a96de95..556a0cd5 100644
--- a/perf/LuaJIT-benches/md5.lua
+++ b/perf/LuaJIT-benches/md5.lua
@@ -1,3 +1,8 @@
+-- Benchmark to check the performance of the bit operations.
+-- Calculates the MD5 hash sum from the fixed string.
+-- For more details about the MD5 algorithm see:
+-- https://en.wikipedia.org/wiki/MD5
+
 local bit = require("bit")
 local bench = require("bench").new(arg)
 
===================================================================

> > @@ -1,5 +1,6 @@
> > -
> >   local bit = require("bit")
> > +local bench = require("bench").new(arg)
> > +
> >   local tobit, tohex, bnot = bit.tobit or bit.cast, bit.tohex, bit.bnot
> >   local bor, band, bxor = bit.bor, bit.band, bit.bxor
> >   local lshift, rshift, rol, bswap = bit.lshift, bit.rshift, bit.rol, bit.bswap
> > @@ -147,7 +148,7 @@ assert(md5('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789') ==
> >   assert(md5('12345678901234567890123456789012345678901234567890123456789012345678901234567890') ==
> >          '57edf4a22be3c955ac49da2e2107b67a')
> >   
> > -local N = tonumber(arg and arg[1]) or 10000
> > +local N = tonumber(arg and arg[1]) or 20000
> this deserves a comment, why 20000 instead 10000?

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.

> >   
> >     -- Credits: William Shakespeare, Romeo and Juliet
> >   local txt = [[Rebellious subjects, enemies to peace,
> > @@ -176,8 +177,20 @@ Once more, on pain of death, all men depart.]]
> >     txt = txt..txt..txt..txt
> >     txt = txt..txt..txt..txt
> >   
> > -for i=1,N do
> > -  res = md5(txt)
> > -end
> > -assert(res == 'a831e91e0f70eddcb70dc61c6f82f6cd')
> > -
> > +bench:add({
> > +  name = 'md5',
> > +  payload = function()
> > +    local res
> > +    for i=1,N do
> s/1,/1, /

Fixed:

===================================================================
diff --git a/perf/LuaJIT-benches/md5.lua b/perf/LuaJIT-benches/md5.lua
index 5ec67527..2a96de95 100644
--- a/perf/LuaJIT-benches/md5.lua
+++ b/perf/LuaJIT-benches/md5.lua
@@ -181,7 +181,7 @@ bench:add({
   name = 'md5',
   payload = function()
     local res
-    for i=1,N do
+    for _ = 1, N do
       res = md5(txt)
     end
     return res
===================================================================

> > +      res = md5(txt)
> > +    end
> > +    return res
> > +  end,
> > +  checker = function(res)
> > +    assert(res == 'a831e91e0f70eddcb70dc61c6f82f6cd')
> > +    return true
> > +  end,
> > +  items = N,
> > +})
> > +
> > +bench:run_and_report()

-- 
Best regards,
Sergey Kaplun


More information about the Tarantool-patches mailing list