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 E17B915DEA8F; Mon, 17 Nov 2025 16:27:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org E17B915DEA8F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1763386032; bh=26d/eefwHh55yGB03VCz/YTnaLzIqoLB9kd22EwoKdA=; 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=vDw9yGlH0hVWeoGFTVQY8pvpyGsiQxEuYAkQECeXbzNc5K7LWj0QDGI+9/YU15EZM AfMApy6GdkPcr1DiE4Pq/AgpwAHa7deBMK2nT5ZMNp2lm+QOk6EXGrqDzg1Y6Umy4I 0twL5ORhDGCONFWT/1YP8dQeTEuaQmH+rFVJRBcM= Received: from send218.i.mail.ru (send218.i.mail.ru [95.163.59.57]) (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 955F515B787C for ; Mon, 17 Nov 2025 16:25:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 955F515B787C Received: by exim-smtp-77df68b9cf-k4thg with esmtpa (envelope-from ) id 1vKzEv-00000000Aek-2ttN; Mon, 17 Nov 2025 16:25:54 +0300 Content-Type: multipart/alternative; boundary="------------B6D6hibmykMMhtOL6fAXtJKX" Message-ID: <2dba4d8b-c82c-4eaf-a77f-bc4d2cb811f3@tarantool.org> Date: Mon, 17 Nov 2025 16:25:53 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org References: <2a5ade826208e1646e13b9e5dfa5e3ae1545aa84.1761301736.git.skaplun@tarantool.org> In-Reply-To: <2a5ade826208e1646e13b9e5dfa5e3ae1545aa84.1761301736.git.skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9110BAFCBE6BD1D1653542A3C566A35071F51746500054719182A05F538085040FCF2B932D31718113DE06ABAFEAF670533216458B6947C1E3C1CBB97E487F8EE7B820C60925959D8 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE71107D7B19CDFFE90EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566D0BE23D09F2BEA509D4C270C34396E86408A415DC94CB97D72A52A8CF6B89FF7389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B652D31B9D28593E51CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C224958C1606C78F2434E76E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8B6A4E49BB0F3BA1413AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E7356436AE5DD6441DC7C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A548E0CA10FF4EC0065002B1117B3ED6964D4AB074F254C2E469995D676B7B4CBE823CB91A9FED034534781492E4B8EEAD9CFA8CFAC159CE19BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF38C609E8DCB74B9C617725ADBF6394B062F2F699D787128F26A28BDDFA0B9113B268D298D11CBB1ADD12B02666E49356643FF642A91C7E4BE17169D636A2256920EC087716A4D2C6111DC66A97D0BFE2913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVfFX+FmbwDW1DhfxDG3lkto= X-Mailru-Sender: 520A125C2F17F0B1A9638AD358559B59D1809F016444C0343DE06ABAFEAF670533216458B6947C1EB7CBEF92542CD7C8795FA72BAB74744FC77752E0C033A69EA16A481184E8BB1C9B38E6EA4F046BE03A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 luajit 21/41] perf: adjust partialsums 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. --------------B6D6hibmykMMhtOL6fAXtJKX Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Sergey, thanks for the patch! See my comments. 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/partialsums.lua | 69 ++++++++++++++++++----------- > 1 file changed, 42 insertions(+), 27 deletions(-) > > diff --git a/perf/LuaJIT-benches/partialsums.lua b/perf/LuaJIT-benches/partialsums.lua > index 46bb9da3..ab24b30a 100644 > --- a/perf/LuaJIT-benches/partialsums.lua > +++ b/perf/LuaJIT-benches/partialsums.lua > @@ -1,29 +1,44 @@ > +local bench = require("bench").new(arg) > > -local n = tonumber(arg[1]) > -local function pr(fmt, x) io.write(string.format(fmt, x)) end > +local DEFAULT_N = 1e7 > +local n = tonumber(arg[1]) or DEFAULT_N Why 1e7 is default? > > -local a1, a2, a3, a4, a5, a6, a7, a8, a9, alt = 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 > -local sqrt, sin, cos = math.sqrt, math.sin, math.cos > -for k=1,n do > - local k2, sk, ck = k*k, sin(k), cos(k) > - local k3 = k2*k > - a1 = a1 + (2/3)^k > - a2 = a2 + 1/sqrt(k) > - a3 = a3 + 1/(k2+k) > - a4 = a4 + 1/(k3*sk*sk) > - a5 = a5 + 1/(k3*ck*ck) > - a6 = a6 + 1/k > - a7 = a7 + 1/k2 > - a8 = a8 + alt/k > - a9 = a9 + alt/(k+k-1) > - alt = -alt > -end > -pr("%.9f\t(2/3)^k\n", a1) > -pr("%.9f\tk^-0.5\n", a2) > -pr("%.9f\t1/k(k+1)\n", a3) > -pr("%.9f\tFlint Hills\n", a4) > -pr("%.9f\tCookson Hills\n", a5) > -pr("%.9f\tHarmonic\n", a6) > -pr("%.9f\tRiemann Zeta\n", a7) > -pr("%.9f\tAlternating Harmonic\n", a8) > -pr("%.9f\tGregory\n", a9) debug prints were lost, is it intentional? In a previous benches debug prints were left, but suppressed. Also I propose to use the same printf function in all benches for consistency. > +bench:add({ > + name = "partialsums", > + payload = function() > + local a1, a2, a3, a4, a5, a6, a7, a8, a9, alt = 1, 0, 0, 0, 0, 0, 0, 0, 0, 1 > + local sqrt, sin, cos = math.sqrt, math.sin, math.cos > + for k=1,n do please add more whitespaces, here and below > + local k2, sk, ck = k*k, sin(k), cos(k) > + local k3 = k2*k > + a1 = a1 + (2/3)^k > + a2 = a2 + 1/sqrt(k) > + a3 = a3 + 1/(k2+k) > + a4 = a4 + 1/(k3*sk*sk) > + a5 = a5 + 1/(k3*ck*ck) > + a6 = a6 + 1/k > + a7 = a7 + 1/k2 > + a8 = a8 + alt/k > + a9 = a9 + alt/(k+k-1) > + alt = -alt > + end > + return {a1, a2, a3, a4, a5, a6, a7, a8, a9} > + end, > + checker = function(a) > + if n == DEFAULT_N then > + assert(a[1] == 2.99999999999999866773) > + assert(a[2] == 6323.09512394020111969439) > + assert(a[3] == 0.99999989999981531152) > + assert(a[4] == 30.31454593111029183206) > + assert(a[5] == 42.99523427973661426904) > + assert(a[6] == 16.69531136585727182364) > + assert(a[7] == 1.64493396684725956547) > + assert(a[8] == 0.69314713056010635039) > + assert(a[9] == 0.78539813839744787582) > + end > + return true > + end, > + items = n, > +}) > + > +bench:run_and_report() > --------------B6D6hibmykMMhtOL6fAXtJKX Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi, Sergey,

thanks for the patch! See my comments.

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.
---
 perf/LuaJIT-benches/partialsums.lua | 69 ++++++++++++++++++-----------
 1 file changed, 42 insertions(+), 27 deletions(-)

diff --git a/perf/LuaJIT-benches/partialsums.lua b/perf/LuaJIT-benches/partialsums.lua
index 46bb9da3..ab24b30a 100644
--- a/perf/LuaJIT-benches/partialsums.lua
+++ b/perf/LuaJIT-benches/partialsums.lua
@@ -1,29 +1,44 @@
+local bench = require("bench").new(arg)
 
-local n = tonumber(arg[1])
-local function pr(fmt, x) io.write(string.format(fmt, x)) end
+local DEFAULT_N = 1e7
+local n = tonumber(arg[1]) or DEFAULT_N
Why 1e7 is default?
 
-local a1, a2, a3, a4, a5, a6, a7, a8, a9, alt = 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
-local sqrt, sin, cos = math.sqrt, math.sin, math.cos
-for k=1,n do
-  local k2, sk, ck = k*k, sin(k), cos(k)
-  local k3 = k2*k
-  a1 = a1 + (2/3)^k
-  a2 = a2 + 1/sqrt(k)
-  a3 = a3 + 1/(k2+k)
-  a4 = a4 + 1/(k3*sk*sk)
-  a5 = a5 + 1/(k3*ck*ck)
-  a6 = a6 + 1/k
-  a7 = a7 + 1/k2
-  a8 = a8 + alt/k
-  a9 = a9 + alt/(k+k-1)
-  alt = -alt
-end
-pr("%.9f\t(2/3)^k\n", a1)
-pr("%.9f\tk^-0.5\n", a2)
-pr("%.9f\t1/k(k+1)\n", a3)
-pr("%.9f\tFlint Hills\n", a4)
-pr("%.9f\tCookson Hills\n", a5)
-pr("%.9f\tHarmonic\n", a6)
-pr("%.9f\tRiemann Zeta\n", a7)
-pr("%.9f\tAlternating Harmonic\n", a8)
-pr("%.9f\tGregory\n", a9)

debug prints were lost, is it intentional?

In a previous benches debug prints were left, but suppressed.

Also I propose to use the same printf function in all benches for consistency.

+bench:add({
+  name = "partialsums",
+  payload = function()
+    local a1, a2, a3, a4, a5, a6, a7, a8, a9, alt = 1, 0, 0, 0, 0, 0, 0, 0, 0, 1
+    local sqrt, sin, cos = math.sqrt, math.sin, math.cos
+    for k=1,n do
please add more whitespaces, here and below
+      local k2, sk, ck = k*k, sin(k), cos(k)
+      local k3 = k2*k
+      a1 = a1 + (2/3)^k
+      a2 = a2 + 1/sqrt(k)
+      a3 = a3 + 1/(k2+k)
+      a4 = a4 + 1/(k3*sk*sk)
+      a5 = a5 + 1/(k3*ck*ck)
+      a6 = a6 + 1/k
+      a7 = a7 + 1/k2
+      a8 = a8 + alt/k
+      a9 = a9 + alt/(k+k-1)
+      alt = -alt
+    end
+    return {a1, a2, a3, a4, a5, a6, a7, a8, a9}
+  end,
+  checker = function(a)
+    if n == DEFAULT_N then
+      assert(a[1] == 2.99999999999999866773)
+      assert(a[2] == 6323.09512394020111969439)
+      assert(a[3] == 0.99999989999981531152)
+      assert(a[4] == 30.31454593111029183206)
+      assert(a[5] == 42.99523427973661426904)
+      assert(a[6] == 16.69531136585727182364)
+      assert(a[7] == 1.64493396684725956547)
+      assert(a[8] == 0.69314713056010635039)
+      assert(a[9] == 0.78539813839744787582)
+    end
+    return true
+  end,
+  items = n,
+})
+
+bench:run_and_report()

--------------B6D6hibmykMMhtOL6fAXtJKX--