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 227C816B02D9; Fri, 26 Dec 2025 11:12:56 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 227C816B02D9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1766736776; bh=H5OuoFQEGAdXTyCWK2UXHhLpx48CJY9na2as5t64lGI=; 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=Jbyz2DL0YsaeePJQlEB/NSprTGxKdm7TLdEyBqxQSnuQs3CVITCrAMq9Yw7OVVkDp sPvjXne1O+KDVBwl4Ix3dBSnSJy3maRAoD3Bjik+xkcH7Zmm7cXBiPOQb3S2X78yZA eN4h1+hGkHQHqarkRro1HpXR8VMHfmUz6FFS8ilU= 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 D9AFA16B02D8 for ; Fri, 26 Dec 2025 11:12:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D9AFA16B02D8 Received: by exim-smtp-7b4fb89df9-pmfc6 with esmtpa (envelope-from ) id 1vZ2wP-00000000DLX-3wlH; Fri, 26 Dec 2025 11:12:54 +0300 Date: Fri, 26 Dec 2025 11:12:51 +0300 To: Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org Message-ID: References: <9e59b7af-1244-4541-bb23-ceb133ed85ed@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9e59b7af-1244-4541-bb23-ceb133ed85ed@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD979975AF0D777FEBD826642AD4A534357A371A8F1BADBE128182A05F5380850403B499DF8009D68493DE06ABAFEAF6705CA5323E4234774E74F327FDBBEDA3D81A7398ABDDC9FB8BB X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE742D9BD90C58D50E0EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566657B88B02DF8C8698A1FDEE106DC8B598E5C609A2D225289B62033C0B32CD260389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B64854413538E1713FCC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE79E9721B410A3B6ED731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5C28F2D47AE617BD15002B1117B3ED696733847AFB5C31B25C638DF663A625AFA823CB91A9FED034534781492E4B8EEAD5E90D3DD2A5B7EAFBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659967278E40817DA47F51ED721232F84B744C79614D84B6D582FAE0BE7181A05F6B418FA182DD31EACB8341EE9D5BE9A0A00A73DC9A6F398FB02EACA749EE48F8B5BC540BF035D2EB38CD93680B12512CF4C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdtTL5f5BIXbJQOUsApV+mY= X-DA7885C5: 1AFA043A73EED2A7F255D290C0D534F9383E0DE984FC2946AFE72A7926794FAEACEB6E90344DF02D5B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393DDD5FD59B456EAD2865CA42351140A51ADD6D52C8E1EDA67E848A358C5F3A639E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 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 Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! Thanks for the review. Fixed your comments and added the description for the benchmark. On 13.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 file. The arguments to the script still > > can be provided in the command line run. > > --- > > perf/LuaJIT-benches/euler14-bit.lua | 52 ++++++++++++++++++++--------- > > 1 file changed, 36 insertions(+), 16 deletions(-) > > > > diff --git a/perf/LuaJIT-benches/euler14-bit.lua b/perf/LuaJIT-benches/euler14-bit.lua > > index 537f2bf3..7c521deb 100644 > > --- a/perf/LuaJIT-benches/euler14-bit.lua > > +++ b/perf/LuaJIT-benches/euler14-bit.lua > > @@ -1,22 +1,42 @@ Also, added the comment with the benchmark description as we discussed offline. =================================================================== diff --git a/perf/LuaJIT-benches/euler14-bit.lua b/perf/LuaJIT-benches/euler14-bit.lua index 54311abe..c4ae3713 100644 --- a/perf/LuaJIT-benches/euler14-bit.lua +++ b/perf/LuaJIT-benches/euler14-bit.lua @@ -1,3 +1,8 @@ +-- 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 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 > > > > +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 > s/2,/2, / > > + local j = i > > + for len=1,1000000000 do > s/1,/1, / > > + j = bor(band(shr(j,1), band(j,1)-1), band(shl(j,1)+j+1, bnot(band(j,1)-1))) > please add whitespaces, here and below > > + if cache then > > + local x = cache[j]; if x then j = x+len; break end > whitespaces > > + elseif j == 1 then > > + j = len+1; break > s/+/ + / Refactor this part of the code to make it more clear. See the iterative patch below: =================================================================== diff --git a/perf/LuaJIT-benches/euler14-bit.lua b/perf/LuaJIT-benches/euler14-bit.lua index 7c521deb..54311abe 100644 --- a/perf/LuaJIT-benches/euler14-bit.lua +++ b/perf/LuaJIT-benches/euler14-bit.lua @@ -13,14 +13,22 @@ bench:add({ payload = function() local cache, m, n = { 1 }, 1, 1 if drop_cache then cache = nil end - for i=2,N do + 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))) + 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 + local x = cache[j] + if x then + j = x + len + break + end elseif j == 1 then - j = len+1; break + j = len + 1 + break end end if cache then cache[i] = j end =================================================================== > > + end > > + end > > + if cache then cache[i] = j end > > + if j > m then m, n = j, i end > > + end > > + return {n = n, m = m} > > + end, > > + checker = function(res) > > +bench:run_and_report() -- Best regards, Sergey Kaplun