From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 7D62016744E8; Mon, 29 Dec 2025 17:17:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7D62016744E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1767017861; bh=xmJltUnNF4OQc2OraZ1P6UFgPc0hISSgFUxPnFl61po=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=nWhxdQrUXTmMBZpwF2Mr/dC5/HHvPrnwTvr2JOYqM5X4LLmpcHVqZN8n9cPwyJTYe 9DeN9mmL0B4jk70vrLl28rrRJIrIP9NN/mG/Bb6GonqQMoNaQ6G7fQaO6hH45TclZp sfU7/gOcQDW0tHqln4UOTUefZDXfnO5YF23I7m/I= Received: from send172.i.mail.ru (send172.i.mail.ru [95.163.59.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id F083F16744E8 for ; Mon, 29 Dec 2025 17:17:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F083F16744E8 Received: by exim-smtp-7b4fb89df9-lft7n with esmtpa (envelope-from ) id 1vaE42-00000000Lrg-2M4u; Mon, 29 Dec 2025 17:17:39 +0300 Content-Type: multipart/alternative; boundary="------------EMDcfv8YZp6N87jCcTPcAdQp" Message-ID: <1e6d9871-b7ce-4136-8c0d-f0eab6c6ff80@tarantool.org> Date: Mon, 29 Dec 2025 17:17:38 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org References: <1fa15638dd1db8690aa5f91cc80d9331f54c842f.1766738771.git.skaplun@tarantool.org> In-Reply-To: <1fa15638dd1db8690aa5f91cc80d9331f54c842f.1766738771.git.skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD979975AF0D777FEBD136B1DE29D0A141801E96C80D96E6DBF182A05F5380850407158C87367D4B24B3DE06ABAFEAF6705521660313894D32B0DDD1C039072FB1BE49391A50CB82CE1 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE71BDE6A359BD5B800EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566FFA32339A312E8EB4567C6173F151D30258D186F04ECEE799D7A364CBC02EB9C389733CBF5DBD5E913377AFFFEAFD269A417C69337E82CC2CC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92176DF2183F8FC7C0D9442B0B5983000E8941B15DA834481F9449624AB7ADAF37BA3038C0950A5D3613377AFFFEAFD269176DF2183F8FC7C0BCF2C0F5768D5B7A7B076A6E789B0E97A8DF7F3B2552694AD5FFEEA1DED7F25D49FD398EE364050F9647ADFADE5905B103CEA74F0D118906B3661434B16C20ACC84D3B47A649675FE827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8B851EDB9C5A93305EEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A54ADB021774F33C205002B1117B3ED69618CFC7CD32743A82C81EEE05487B0209823CB91A9FED034534781492E4B8EEAD220496FFA5CD4785BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D6593A03AD15D70117F8CF2D39FA16191FC998A27FEA12619C23129934B8C0D90EC93A71937621137635B8341EE9D5BE9A0AC27D4BC54B3F7022969BE551C30B026D376A20ED49BE712D8CD93680B12512CF4C41F94D744909CE2512F26BEC029E55448553D2254B8D95CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVTZJppT4ZVHRLtjXZildCcQ= X-Mailru-Sender: 811C44EDE0507D1FF7A5115BD94F8393C2DCA28A0678CEBD459FBC39F2FFFE83F641C44FF0786F15480B638DC6DBEA0E645D15D82EE4B272BD6E4642A116CA93524AA66B5ACBE6721EF430B9A63E2A504198E0F3ECE9B5443453F38A29522196 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 luajit 09/41] perf: adjust fannkuch in LuaJIT-benches X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------EMDcfv8YZp6N87jCcTPcAdQp Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Sergey! thanks for the patch! LGTM Sergey On 12/26/25 12:17, Sergey Kaplun wrote: > This patch adjusts the aforementioned test to use the benchmark > framework introduced before. The default arguments are adjusted > according to the file. The arguments to the script still > can be provided in the command line run. > --- > perf/LuaJIT-benches/fannkuch.lua | 44 +++++++++++++++++++++++++++++--- > 1 file changed, 41 insertions(+), 3 deletions(-) > > diff --git a/perf/LuaJIT-benches/fannkuch.lua b/perf/LuaJIT-benches/fannkuch.lua > index 2a4cd426..f51e0eaf 100644 > --- a/perf/LuaJIT-benches/fannkuch.lua > +++ b/perf/LuaJIT-benches/fannkuch.lua > @@ -1,3 +1,11 @@ > +-- 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) > local p, q, s, odd, check, maxflips = {}, {}, {}, true, 0, 0 > @@ -6,7 +14,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. > @@ -46,5 +53,36 @@ 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 "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 } > + > +local function factorial(n) > + local fact = 1 > + for i = 2, n do > + fact = fact * i > + end > + return fact > +end > + > +bench:add({ > + name = "fannkuch", > + payload = function() > + return fannkuch(n) > + end, > + checker = function(res) > + if n > #FANNKUCH then > + -- Not precomputed, so can't check. > + return true > + else > + return res == FANNKUCH[n] > + end > + end, > + -- Assume that we count permutations here. > + items = factorial(n), > +}) > + > +bench:run_and_report() --------------EMDcfv8YZp6N87jCcTPcAdQp Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi, Sergey!

thanks for the patch! LGTM

Sergey

On 12/26/25 12:17, 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/fannkuch.lua | 44 +++++++++++++++++++++++++++++---
 1 file changed, 41 insertions(+), 3 deletions(-)

diff --git a/perf/LuaJIT-benches/fannkuch.lua b/perf/LuaJIT-benches/fannkuch.lua
index 2a4cd426..f51e0eaf 100644
--- a/perf/LuaJIT-benches/fannkuch.lua
+++ b/perf/LuaJIT-benches/fannkuch.lua
@@ -1,3 +1,11 @@
+-- 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)
   local p, q, s, odd, check, maxflips = {}, {}, {}, true, 0, 0
@@ -6,7 +14,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.
@@ -46,5 +53,36 @@ 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 "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 }
+
+local function factorial(n)
+  local fact = 1
+  for i = 2, n do
+    fact = fact * i
+  end
+  return fact
+end
+
+bench:add({
+  name = "fannkuch",
+  payload = function()
+    return fannkuch(n)
+  end,
+  checker = function(res)
+    if n > #FANNKUCH then
+      -- Not precomputed, so can't check.
+      return true
+    else
+      return res == FANNKUCH[n]
+    end
+  end,
+  -- Assume that we count permutations here.
+  items = factorial(n),
+})
+
+bench:run_and_report()
--------------EMDcfv8YZp6N87jCcTPcAdQp--