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 D5CC11679206; Fri, 26 Dec 2025 11:24:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org D5CC11679206 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1766737486; bh=Izi0XqJvqBFZJB1nCD9iTkw5Y0UxJBMT3cG1sWkeQ+4=; 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=pmlm2VsnE/SODs6rjx7jGw86rvj9McLrQ34B8pFTh9IfWzpYy6AvNOAhoPjCSvefS qLg2MZvQcH8s0jbTQStNbURSEPa0wfNeooXAGKXwbVI4mRJ7TuQg3GYiyuDjzYejZb bt9ym9sBDS4inG6K6ZH+WpFsVU2i3XT8HXM1LTaY= Received: from send106.i.mail.ru (send106.i.mail.ru [89.221.237.201]) (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 6815C167921E for ; Fri, 26 Dec 2025 11:24:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6815C167921E Received: by exim-smtp-7b4fb89df9-h9qw9 with esmtpa (envelope-from ) id 1vZ37r-00000000TEY-1bkX; Fri, 26 Dec 2025 11:24:43 +0300 Date: Fri, 26 Dec 2025 11:24:41 +0300 To: Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org Message-ID: References: <771ce40700f63e508869a55a973d8f852ee93a06.1761301736.git.skaplun@tarantool.org> <29e184ea-8946-42e0-a594-dcfa74ac9792@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <29e184ea-8946-42e0-a594-dcfa74ac9792@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD979975AF0D777FEBDD803ECE58504FBFD117E6A90C4FE9736182A05F53808504028F4D61877A1E8A83DE06ABAFEAF6705621E1D96AFC4D9DBC3CE4153D521EAFE59C33E53B579784F X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE786614E11AFA257BFC2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6759CC434672EE6371C2A783ECEC0211ADC4224003CC836476D5A39DEEDB180909611E41BBFE2FEB2B7B4699E5C84C05A194250ACB75968F4FFE7B6115514D4CC453E710F2838C476D9FA2833FD35BB23D9E625A9149C048EE9ECD01F8117BC8BEA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18CB629EEF1311BF91D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6753C3A5E0A5AB5B7089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A5323C16ABC74CCCE95002B1117B3ED6964AA8BB0B47A484AB886DC9BC01168B20823CB91A9FED034534781492E4B8EEADDFC043C56F70D752BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659F38D537474EF5732E4E76587739DCCB69D12318CD20058E957CB5C1F55A308C3F3A93617D88F52DCB8341EE9D5BE9A0ABC7BF683FB58AB3827B3DBCB20B32D129453CC043719EEAA8CD93680B12512CF4C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdtTL5f5BIXbsDcrxtoYCzA= X-DA7885C5: 780709618A761A15F255D290C0D534F9EFE36831C749F08A4761B4FB2BB2349CDF53A98BB3B34E0B5B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393DDD5FD59B456EAD273B2CA864F3E4C96D37EF568E78CB39812EAF3822E357217E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 luajit 17/41] perf: adjust nbody 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! See 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/nbody.lua | 127 ++++++++++++++++++++-------------- > > 1 file changed, 74 insertions(+), 53 deletions(-) > > > > diff --git a/perf/LuaJIT-benches/nbody.lua b/perf/LuaJIT-benches/nbody.lua > > index e0ff8f77..f01c20a3 100644 > > --- a/perf/LuaJIT-benches/nbody.lua > > +++ b/perf/LuaJIT-benches/nbody.lua > > @@ -1,56 +1,12 @@ Added the comment with the short benchmark description, as we discussed offline: =================================================================== diff --git a/perf/LuaJIT-benches/nbody.lua b/perf/LuaJIT-benches/nbody.lua index 335a43a5..4370b4d7 100644 --- a/perf/LuaJIT-benches/nbody.lua +++ b/perf/LuaJIT-benches/nbody.lua @@ -1,3 +1,9 @@ +-- Benchmark to check the performance of FP arithmetics. +-- It models the orbits of Jovian planets, using the simple +-- symplectic-integrator. +-- For the details see: +-- https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/nbody.html + local bench = require("bench").new(arg) local sqrt = math.sqrt =================================================================== > > +local bench = require("bench").new(arg) > > > > local sqrt = math.sqrt > > > > local PI = 3.141592653589793 > > local SOLAR_MASS = 4 * PI * PI > > local DAYS_PER_YEAR = 365.24 > > -local bodies = { > > - { -- Sun > > - x = 0, > > - y = 0, > > - z = 0, > > - vx = 0, > > - vy = 0, > > - vz = 0, > > - mass = SOLAR_MASS > > - }, > > - { -- Jupiter > > - x = 4.84143144246472090e+00, > > - y = -1.16032004402742839e+00, > > - z = -1.03622044471123109e-01, > > - vx = 1.66007664274403694e-03 * DAYS_PER_YEAR, > > - vy = 7.69901118419740425e-03 * DAYS_PER_YEAR, > > - vz = -6.90460016972063023e-05 * DAYS_PER_YEAR, > > - mass = 9.54791938424326609e-04 * SOLAR_MASS > > - }, > > - { -- Saturn > > - x = 8.34336671824457987e+00, > > - y = 4.12479856412430479e+00, > > - z = -4.03523417114321381e-01, > > - vx = -2.76742510726862411e-03 * DAYS_PER_YEAR, > > - vy = 4.99852801234917238e-03 * DAYS_PER_YEAR, > > - vz = 2.30417297573763929e-05 * DAYS_PER_YEAR, > > - mass = 2.85885980666130812e-04 * SOLAR_MASS > > - }, > > - { -- Uranus > > - x = 1.28943695621391310e+01, > > - y = -1.51111514016986312e+01, > > - z = -2.23307578892655734e-01, > > - vx = 2.96460137564761618e-03 * DAYS_PER_YEAR, > > - vy = 2.37847173959480950e-03 * DAYS_PER_YEAR, > > - vz = -2.96589568540237556e-05 * DAYS_PER_YEAR, > > - mass = 4.36624404335156298e-05 * SOLAR_MASS > > - }, > > - { -- Neptune > > - x = 1.53796971148509165e+01, > > - y = -2.59193146099879641e+01, > > - z = 1.79258772950371181e-01, > > - vx = 2.68067772490389322e-03 * DAYS_PER_YEAR, > > - vy = 1.62824170038242295e-03 * DAYS_PER_YEAR, > > - vz = -9.51592254519715870e-05 * DAYS_PER_YEAR, > > - mass = 5.15138902046611451e-05 * SOLAR_MASS > > - } > > -} > > +local bodies > > +local nbody > > > > local function advance(bodies, nbody, dt) > > for i=1,nbody do > > @@ -110,10 +66,75 @@ local function offsetMomentum(b, nbody) > > b[1].vz = -pz / SOLAR_MASS > > end > > > > -local N = tonumber(arg and arg[1]) or 1000 > > -local nbody = #bodies > > +local DEFAULT_N = 5e6 > > +local N = tonumber(arg and arg[1]) or DEFAULT_N > > > > -offsetMomentum(bodies, nbody) > > -io.write( string.format("%0.9f",energy(bodies, nbody)), "\n") > > -for i=1,N do advance(bodies, nbody, 0.01) end > > -io.write( string.format("%0.9f",energy(bodies, nbody)), "\n") > > +bench:add({ > > + name = "nbody", > > + payload = function() > > + bodies = { > > + { -- Sun > > + x = 0, > > + y = 0, > > + z = 0, > > + vx = 0, > > + vy = 0, > > + vz = 0, > > + mass = SOLAR_MASS > > + }, > > + { -- Jupiter > > + x = 4.84143144246472090e+00, > > + y = -1.16032004402742839e+00, > > + z = -1.03622044471123109e-01, > > + vx = 1.66007664274403694e-03 * DAYS_PER_YEAR, > > + vy = 7.69901118419740425e-03 * DAYS_PER_YEAR, > > + vz = -6.90460016972063023e-05 * DAYS_PER_YEAR, > > + mass = 9.54791938424326609e-04 * SOLAR_MASS > > + }, > > + { -- Saturn > > + x = 8.34336671824457987e+00, > > + y = 4.12479856412430479e+00, > > + z = -4.03523417114321381e-01, > > + vx = -2.76742510726862411e-03 * DAYS_PER_YEAR, > > + vy = 4.99852801234917238e-03 * DAYS_PER_YEAR, > > + vz = 2.30417297573763929e-05 * DAYS_PER_YEAR, > > + mass = 2.85885980666130812e-04 * SOLAR_MASS > > + }, > > + { -- Uranus > > + x = 1.28943695621391310e+01, > > + y = -1.51111514016986312e+01, > > + z = -2.23307578892655734e-01, > > + vx = 2.96460137564761618e-03 * DAYS_PER_YEAR, > > + vy = 2.37847173959480950e-03 * DAYS_PER_YEAR, > > + vz = -2.96589568540237556e-05 * DAYS_PER_YEAR, > > + mass = 4.36624404335156298e-05 * SOLAR_MASS > > + }, > > + { -- Neptune > > + x = 1.53796971148509165e+01, > > + y = -2.59193146099879641e+01, > > + z = 1.79258772950371181e-01, > > + vx = 2.68067772490389322e-03 * DAYS_PER_YEAR, > > + vy = 1.62824170038242295e-03 * DAYS_PER_YEAR, > > + vz = -9.51592254519715870e-05 * DAYS_PER_YEAR, > > + mass = 5.15138902046611451e-05 * SOLAR_MASS > > + } > > + } > > + nbody = #bodies > > + > > + offsetMomentum(bodies, nbody) > Two `io.write()` were lost. It is intentional? Yes, it is checked via the corresponding assertions. > > + > > + assert(energy(bodies, nbody) == -0.16907516382852447179, > > + "Correct start energy") > > + for i=1,N do advance(bodies, nbody, 0.01) end > s/1,/1, / Fixed: =================================================================== diff --git a/perf/LuaJIT-benches/nbody.lua b/perf/LuaJIT-benches/nbody.lua index f01c20a3..335a43a5 100644 --- a/perf/LuaJIT-benches/nbody.lua +++ b/perf/LuaJIT-benches/nbody.lua @@ -125,7 +125,7 @@ bench:add({ assert(energy(bodies, nbody) == -0.16907516382852447179, "Correct start energy") - for i=1,N do advance(bodies, nbody, 0.01) end + for _ = 1, N do advance(bodies, nbody, 0.01) end end, checker = function() if N == DEFAULT_N then =================================================================== > > + end, > > + checker = function() > > + if N == DEFAULT_N then > > + assert(energy(bodies, nbody) == -0.16908313397890917251, > > + "Correct result energy") > > + end > > + return true > > + end, > > + items = N, > > +}) > > + > > +bench:run_and_report() -- Best regards, Sergey Kaplun