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 44F3F15A808F; Mon, 17 Nov 2025 11:36:29 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 44F3F15A808F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1763368589; bh=eGWSDSMtbjYsEca44UXXRT4YllIphF1pSbbujCR2nBk=; 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=uUI8I9MRsMgJRPgnwVnM80GfYO3LIlrtWH7wuYVnSBYuWL2uWsoeVS4tT/liFSKq3 DHNAMk8YEG3jbBf2ccc5cwuuv/ggaaLMzlRpyYKWrW18C9Br03SpeQwpegILlW3rNI L67Q3w7z2K6c8kQphoLtzGg7OTXTILCT+LA7etIs= Received: from send219.i.mail.ru (send219.i.mail.ru [95.163.59.58]) (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 8959915A8090 for ; Mon, 17 Nov 2025 11:36:21 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8959915A8090 Received: by exim-smtp-77df68b9cf-2nbxc with esmtpa (envelope-from ) id 1vKuii-00000000VB1-2Cg7; Mon, 17 Nov 2025 11:36:20 +0300 Content-Type: multipart/alternative; boundary="------------wu0Tw9XwtONEft4CRq7ZqjP7" Message-ID: Date: Mon, 17 Nov 2025 11:36:20 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org References: In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9110BAFCBE6BD1D16B955D557669B9266277B9011FC74A41D182A05F53808504052829D009B0C4AAB3DE06ABAFEAF67058C24708130069F6EB90FB3693C7F7FA4A2605A7B24691806 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7AA1605287C7F04D6EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566D0BE23D09F2BEA509A8C78136ADD3817A3B02478122E7F2B0456C3678B4B56E6389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B64854413538E1713FCC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C2249B899183D4666AAE776E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8B89C074F960B19C4B3AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E735458315FA5AE40766C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A54C7BD21CB85C4E675002B1117B3ED696D63D92B31C3E2639C66B2B37046EC955823CB91A9FED034534781492E4B8EEAD9CFA8CFAC159CE19BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF96F75389F8017BC294A4DBED0262C8F2D526D994F1781B442E1C5806FED2AC9A9FED342E2040E994DD12B02666E493562F82089A531F4E0E127233FBA903AC5701878CC4263BE608111DC66A97D0BFE2913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVfFX+FmbwDW1JoUE9ZPAGPw= X-Mailru-Sender: 520A125C2F17F0B1A9638AD358559B5995D9472098F72C7D3DE06ABAFEAF67058C24708130069F6EB7CBEF92542CD7C8795FA72BAB74744FC77752E0C033A69EA16A481184E8BB1C9B38E6EA4F046BE03A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 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. --------------wu0Tw9XwtONEft4CRq7ZqjP7 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 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 > @@ -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? > 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" > +--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() --------------wu0Tw9XwtONEft4CRq7ZqjP7 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

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


@@ -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?
       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"
+-- 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()
--------------wu0Tw9XwtONEft4CRq7ZqjP7--