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 EF5BC16744E0; Mon, 29 Dec 2025 17:15:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org EF5BC16744E0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1767017725; bh=mk/l5C67vNRpDxChUpDN369K3WpxPx/CIbV+vTKIsLY=; 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=xBbhzRxirnLOSd/YOy4R7YGr8TlRzGZBFDThQN+Tefy1/nSmdAhZ9OPpDykvPG94G X4Q+26eyy0t5ef14hHEC5yeL0UWSZLo6SU/eJSD9X25twS8vXEi6Hbk5Mim24WaF2V ZC0L5N7GuX7Ik7f0mc8n1qnWen2oUkuuUaRrcyHk= Received: from send36.i.mail.ru (send36.i.mail.ru [89.221.237.131]) (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 6C7BA16744DF for ; Mon, 29 Dec 2025 17:15:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6C7BA16744DF Received: by exim-smtp-7b4fb89df9-xh88n with esmtpa (envelope-from ) id 1vaE1r-00000000CiE-1lk9; Mon, 29 Dec 2025 17:15:23 +0300 Content-Type: multipart/alternative; boundary="------------2OsKkH2AOd5PsaY9tWfRNa69" Message-ID: <575dcc6d-dbb0-44d6-ae0f-14304413aa5c@tarantool.org> Date: Mon, 29 Dec 2025 17:15:23 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org References: <388c8793a03f3a9bf0dbe4f4f8fde40687c4573f.1766738771.git.skaplun@tarantool.org> In-Reply-To: <388c8793a03f3a9bf0dbe4f4f8fde40687c4573f.1766738771.git.skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD979975AF0D777FEBD136B1DE29D0A141801E96C80D96E6DBF182A05F53808504057203ED8E52286133DE06ABAFEAF6705C9CB159F246379B60DDD1C039072FB1B9799EF890AE2F8A9 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7544B1CCE26E01C74EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566FFA32339A312E8EBAA2C1895839DB16016A2345FFF62CD705C7BF412FFA97F3D389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B64854413538E1713FCC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C2249B899183D4666AAE776E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8B89C074F960B19C4B3AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E73557739F23D657EF2BB5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A5B6E287ABDC4665CE5002B1117B3ED696857187E472BC8DB8559C6C5561145D6F823CB91A9FED034534781492E4B8EEAD2B25D9E4C92BC8ACBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659132994FB756F850D27D98586E5A132C2D8F655EBD70F67AAFBC1D4D997B9947CF9E11DBA10DB32C4B8341EE9D5BE9A0A19FDCF63EF13DBA71C0B3EACB4B4F4E4EAD96081CA3F40AA8CD93680B12512CF4C41F94D744909CE2512F26BEC029E55448553D2254B8D95CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVTZJppT4ZVHRVPRZDQOhhOY= X-Mailru-Sender: 811C44EDE0507D1FF7A5115BD94F83938591F16F9847FCA320C74B26AAFF934531C6A5F4800E04C5B6C8E3010CC636A9645D15D82EE4B272BD6E4642A116CA93524AA66B5ACBE6721EF430B9A63E2A504198E0F3ECE9B5443453F38A29522196 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 luajit 08/41] perf: adjust euler14-bit 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. --------------2OsKkH2AOd5PsaY9tWfRNa69 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Sergey! thanks for the patch! Generally LGTM, but the test failed on my machine with: $ ./build/src/luajit perf/LuaJIT-benches/euler14-bit.lua ./build/src/luajit: not enough memory 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/euler14-bit.lua | 65 ++++++++++++++++++++++------- > 1 file changed, 49 insertions(+), 16 deletions(-) > > diff --git a/perf/LuaJIT-benches/euler14-bit.lua b/perf/LuaJIT-benches/euler14-bit.lua > index 537f2bf3..c4ae3713 100644 > --- a/perf/LuaJIT-benches/euler14-bit.lua > +++ b/perf/LuaJIT-benches/euler14-bit.lua > @@ -1,22 +1,55 @@ > +-- The benchmark to check the performance of bitwise operations. > +-- It finds the longest Collatz sequence using bitwise arithmetic. > +-- For the details see: > +--https://projecteuler.net/problem=14 > + > +local bench = require("bench").new(arg) > > local bit = require("bit") > local bnot, bor, band = bit.bnot, bit.bor, bit.band > local shl, shr = bit.lshift, bit.rshift > > -local N = tonumber(arg and arg[1]) or 10000000 > -local cache, m, n = { 1 }, 1, 1 > -if arg and arg[2] then cache = nil end > -for i=2,N do > - local j = i > - for len=1,1000000000 do > - j = bor(band(shr(j,1), band(j,1)-1), band(shl(j,1)+j+1, bnot(band(j,1)-1))) > - if cache then > - local x = cache[j]; if x then j = x+len; break end > - elseif j == 1 then > - j = len+1; break > +local DEFAULT_N = 2e7 > +local N = tonumber(arg and arg[1]) or DEFAULT_N > +local drop_cache = arg and arg[2] > + > +bench:add({ > + name = "euler14_bit", > + payload = function() > + local cache, m, n = { 1 }, 1, 1 > + if drop_cache then cache = nil end > + for i = 2, N do > + local j = i > + for len = 1, 1000000000 do > + j = bor( > + band(shr(j, 1), band(j, 1) - 1), > + band(shl(j, 1) + j + 1, bnot(band(j, 1) - 1)) > + ) > + if cache then > + local x = cache[j] > + if x then > + j = x + len > + break > + end > + elseif j == 1 then > + j = len + 1 > + break > + end > + end > + if cache then cache[i] = j end > + if j > m then m, n = j, i end > end > - end > - if cache then cache[i] = j end > - if j > m then m, n = j, i end > -end > -io.write("Found ", n, " (chain length: ", m, ")\n") > + return {n = n, m = m} > + end, > + checker = function(res) > + if N ~= DEFAULT_N then > + -- Test only for the default. > + return true > + else > + return res.n == 18064027 and res.m == 623 > + end > + end, > + items = N, > +}) > + > +bench:run_and_report() --------------2OsKkH2AOd5PsaY9tWfRNa69 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

Hi, Sergey!

thanks for the patch! Generally LGTM, but the test failed on my machine with:

$ ./build/src/luajit perf/LuaJIT-benches/euler14-bit.lua 
./build/src/luajit: not enough memory

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/euler14-bit.lua | 65 ++++++++++++++++++++++-------
 1 file changed, 49 insertions(+), 16 deletions(-)

diff --git a/perf/LuaJIT-benches/euler14-bit.lua b/perf/LuaJIT-benches/euler14-bit.lua
index 537f2bf3..c4ae3713 100644
--- a/perf/LuaJIT-benches/euler14-bit.lua
+++ b/perf/LuaJIT-benches/euler14-bit.lua
@@ -1,22 +1,55 @@
+-- The benchmark to check the performance of bitwise operations.
+-- It finds the longest Collatz sequence using bitwise arithmetic.
+-- For the details see:
+-- https://projecteuler.net/problem=14
+
+local bench = require("bench").new(arg)
 
 local bit = require("bit")
 local bnot, bor, band = bit.bnot, bit.bor, bit.band
 local shl, shr = bit.lshift, bit.rshift
 
-local N = tonumber(arg and arg[1]) or 10000000
-local cache, m, n = { 1 }, 1, 1
-if arg and arg[2] then cache = nil end
-for i=2,N do
-  local j = i
-  for len=1,1000000000 do
-    j = bor(band(shr(j,1), band(j,1)-1), band(shl(j,1)+j+1, bnot(band(j,1)-1)))
-    if cache then
-      local x = cache[j]; if x then j = x+len; break end
-    elseif j == 1 then
-      j = len+1; break
+local DEFAULT_N = 2e7
+local N = tonumber(arg and arg[1]) or DEFAULT_N
+local drop_cache = arg and arg[2]
+
+bench:add({
+  name = "euler14_bit",
+  payload = function()
+    local cache, m, n = { 1 }, 1, 1
+    if drop_cache then cache = nil end
+    for i = 2, N do
+      local j = i
+      for len = 1, 1000000000 do
+        j = bor(
+          band(shr(j, 1), band(j, 1) - 1),
+          band(shl(j, 1) + j + 1, bnot(band(j, 1) - 1))
+        )
+        if cache then
+          local x = cache[j]
+          if x then
+            j = x + len
+            break
+          end
+        elseif j == 1 then
+          j = len + 1
+          break
+        end
+      end
+      if cache then cache[i] = j end
+      if j > m then m, n = j, i end
     end
-  end
-  if cache then cache[i] = j end
-  if j > m then m, n = j, i end
-end
-io.write("Found ", n, " (chain length: ", m, ")\n")
+    return {n = n, m = m}
+  end,
+  checker = function(res)
+    if N ~= DEFAULT_N then
+      -- Test only for the default.
+      return true
+    else
+      return res.n == 18064027 and res.m == 623
+    end
+  end,
+  items = N,
+})
+
+bench:run_and_report()
--------------2OsKkH2AOd5PsaY9tWfRNa69--