[Tarantool-patches] [PATCH v1 luajit 09/41] perf: adjust fannkuch in LuaJIT-benches
Sergey Kaplun
skaplun at tarantool.org
Fri Dec 26 11:13:57 MSK 2025
Hi, Sergey!
Thanks for the review!
Fixed your comments and updated the branch.
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.
> > ---
> >
> > I'm not sure that amount of permutations is the correct items count.
> > Have you any other suggestions?
> >
> > perf/LuaJIT-benches/fannkuch.lua | 37 +++++++++++++++++++++++++++++---
> > 1 file changed, 34 insertions(+), 3 deletions(-)
> >
> > diff --git a/perf/LuaJIT-benches/fannkuch.lua b/perf/LuaJIT-benches/fannkuch.lua
> > index 2a4cd426..c963c66f 100644
> > --- a/perf/LuaJIT-benches/fannkuch.lua
> > +++ b/perf/LuaJIT-benches/fannkuch.lua
>
> I'm highly recommend adding description to benchmarks.
>
> At least to the tests from "benchmarks game" suite.
>
> You can use descriptions from the [1] and [2].
>
> 1. https://benchmarksgame-team.pages.debian.net/benchmarksgame/
>
> 2.
> https://en.wikipedia.org/wiki/The_Computer_Language_Benchmarks_Game#Benchmark_programs
Added the short description, as you suggested:
===================================================================
diff --git a/perf/LuaJIT-benches/fannkuch.lua b/perf/LuaJIT-benches/fannkuch.lua
index 2328e058..f51e0eaf 100644
--- a/perf/LuaJIT-benches/fannkuch.lua
+++ b/perf/LuaJIT-benches/fannkuch.lua
@@ -1,3 +1,10 @@
+-- The benchmark that checks the performance of operations on
+-- small integers and vectors of integers and the performance of
+-- inner loops of the benchmark. The benchmark finds the maximum
+-- number of flips in the table needed for any permutation.
+-- For the details see:
+-- https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/fannkuchredux.html
+
local bench = require("bench").new(arg)
local function fannkuch(n)
===================================================================
>
>
> > @@ -1,3 +1,4 @@
> > +local bench = require("bench").new(arg)
> >
> > local function fannkuch(n)
> > local p, q, s, odd, check, maxflips = {}, {}, {}, true, 0, 0
> > @@ -6,7 +7,7 @@ local function fannkuch(n)
> > -- Print max. 30 permutations.
> > if check < 30 then
> > if not p[n] then return maxflips end -- Catch n = 0, 1, 2.
> > - io.write(unpack(p)); io.write("\n")
> > + -- io.write(unpack(p)); io.write("\n")
> isn't better to remove at all?
OK, removed:
===================================================================
diff --git a/perf/LuaJIT-benches/fannkuch.lua b/perf/LuaJIT-benches/fannkuch.lua
index c963c66f..ceb13ca6 100644
--- a/perf/LuaJIT-benches/fannkuch.lua
+++ b/perf/LuaJIT-benches/fannkuch.lua
@@ -7,7 +7,6 @@ local function fannkuch(n)
-- Print max. 30 permutations.
if check < 30 then
if not p[n] then return maxflips end -- Catch n = 0, 1, 2.
- -- io.write(unpack(p)); io.write("\n")
check = check + 1
end
-- Copy and flip.
===================================================================
> > check = check + 1
> > end
> > -- Copy and flip.
> > @@ -46,5 +47,35 @@ local function fannkuch(n)
> > until false
> > end
> >
> > -local n = tonumber(arg and arg[1]) or 1
> > -io.write("Pfannkuchen(", n, ") = ", fannkuch(n), "\n")
> > +local n = tonumber(arg and arg[1]) or 11
> > +
> > +-- Precomputed numbers taken from:
> please add description of the paper as well: "Performing Lisp Analysis
> of the FANNKUCH Benchmark"
Added:
===================================================================
diff --git a/perf/LuaJIT-benches/fannkuch.lua b/perf/LuaJIT-benches/fannkuch.lua
index ceb13ca6..2328e058 100644
--- a/perf/LuaJIT-benches/fannkuch.lua
+++ b/perf/LuaJIT-benches/fannkuch.lua
@@ -48,7 +48,8 @@ end
local n = tonumber(arg and arg[1]) or 11
--- Precomputed numbers taken from:
+-- Precomputed numbers taken from "Performing Lisp Analysis of the
+-- FANNKUCH Benchmark":
-- https://dl.acm.org/doi/pdf/10.1145/382109.382124
local FANNKUCH = { 0, 1, 2, 4, 7, 10, 16, 22, 30, 38, 51, 65, 80 }
===================================================================
> > +--https://dl.acm.org/doi/pdf/10.1145/382109.382124
> > +local FANNKUCH = { 0, 1, 2, 4, 7, 10, 16, 22, 30, 38, 51, 65, 80 }
> > +
<snipped>
--
Best regards,
Sergey Kaplun
More information about the Tarantool-patches
mailing list