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 DAA4516B02CC; Fri, 26 Dec 2025 11:27:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org DAA4516B02CC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1766737632; bh=mvPZS3dScM+hMXFu1Xk/qH+pcm/7mmPqgRXYwSCLAjs=; 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=wdghodrWxwtNOTObhNVASBfp44zXEMxg4MZ8sPi6SLICHFTXB+CSEVGAs8f8bEIP/ /sgvecKSAqbFV64lPykrR29NyZRUF97Knu82SYQerVdUIG840TdeU61JljldvGwQpk w/bR5xlqPvujEBTqvaE/trEVW4l2RKbL8aTkmlMU= 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 16D4116B02E8 for ; Fri, 26 Dec 2025 11:27:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 16D4116B02E8 Received: by exim-smtp-7b4fb89df9-ljvk6 with esmtpa (envelope-from ) id 1vZ3AC-00000000Rex-43ht; Fri, 26 Dec 2025 11:27:09 +0300 Date: Fri, 26 Dec 2025 11:27:06 +0300 To: Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org Message-ID: References: <2a5ade826208e1646e13b9e5dfa5e3ae1545aa84.1761301736.git.skaplun@tarantool.org> <2dba4d8b-c82c-4eaf-a77f-bc4d2cb811f3@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2dba4d8b-c82c-4eaf-a77f-bc4d2cb811f3@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD979975AF0D777FEBD9A7AA89612843F49E05A58644225EC05182A05F5380850409DACA985AD48D6FB3DE06ABAFEAF6705B7E6BD6AF75690AFC3CE4153D521EAFEDAF06271CF5AE1BC X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE79A02CDD1178524C2EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566657B88B02DF8C869CFB14099F32F8BB7E8B935E7A8EDEB248551D006AE559D18389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6957A4DEDD2346B42CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE79E9721B410A3B6ED731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5D296D204FD37C3E25002B1117B3ED696DC4661E2DFD305EF19AC5B239BAD4335823CB91A9FED034534781492E4B8EEADB73CFAAED92B6E13BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659B8382A393EB98A3DAC6212ADC3C8DAB49090189CAC05E6EECFC9704ADAC56EE4AF3C97DF94AB3E5DB8341EE9D5BE9A0A6A6A45E262579BC949289EEEF31CA712C35AE18E4E540D7D8CD93680B12512CF4C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdtTL5f5BIXb4kovKO0jjv4= X-Mailru-Sender: 689FA8AB762F7393DDD5FD59B456EAD2DC40F975FA7711F9291205D8DB3419F4C773D17694773417E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F 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 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. Please, consider my answers below. On 17.11.25, Sergey Bronnikov wrote: > 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 Added the comment with the short benchmark description, as we discussed offline: =================================================================== diff --git a/perf/LuaJIT-benches/partialsums.lua b/perf/LuaJIT-benches/partialsums.lua index c9d48a2d..2e5967d2 100644 --- a/perf/LuaJIT-benches/partialsums.lua +++ b/perf/LuaJIT-benches/partialsums.lua @@ -1,3 +1,7 @@ +-- The benchmark to check the performance of FP arithmetic and +-- math functions. Calculates the partial sums of several series +-- in the single loop. + local bench = require("bench").new(arg) local DEFAULT_N = 1e7 =================================================================== > > @@ -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? It is the default for x86 arch. I've taken the values from PARAMS_x86, since this is the most important architecture for the Tarantool, see the commit message. > > > > -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? It is not the debug print, but verification of program correctness, also it prevents DCE by the compilers in the compiled languages. Here it is tested by the checker function. > > In a previous benches debug prints were left, but suppressed. No, there are no debug prints. Output to suppress is the program behaviour (like in the life benchmark) or the result of the program (like in the k-nucleotide). Since it is rather huge, to avoid saving the result in the file, it is better to drop it into the /dev/null to avoid dependence on the file system. > > Also I propose to use the same printf function in all benches for > consistency. There is no need for it since this is not the main payload of the benchmark. > > > +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 Added: =================================================================== diff --git a/perf/LuaJIT-benches/partialsums.lua b/perf/LuaJIT-benches/partialsums.lua index ab24b30a..c9d48a2d 100644 --- a/perf/LuaJIT-benches/partialsums.lua +++ b/perf/LuaJIT-benches/partialsums.lua @@ -8,18 +8,18 @@ bench:add({ 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 - 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) + 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 return {a1, a2, a3, a4, a5, a6, a7, a8, a9} =================================================================== > > + 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() > > -- Best regards, Sergey Kaplun