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 6495816B02C5; Fri, 26 Dec 2025 11:08:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6495816B02C5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1766736511; bh=WtbvwrPw4yAOXUxcaFomEhRwSHBaFzCOTaUu8aivm7A=; 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=o8kcC1N5AfvdLXK+FJ4KJovzeSOI//VMnIPJDDod3pKhRYOfinqfCP2G2I1x/AsV6 FfM1jCfwvkDo/prqDNQFk8bSu5SH/H7hK5+BP44hS7ZO7DEWtD0vYVnLuI5x0q8+oo KgKItQArASaB39kURO/59dbwb8ivCGRp5ocu4JGM= Received: from send278.i.mail.ru (send278.i.mail.ru [95.163.59.117]) (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 43F9B16B02C6 for ; Fri, 26 Dec 2025 11:08:30 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 43F9B16B02C6 Received: by exim-smtp-7b4fb89df9-mqnbq with esmtpa (envelope-from ) id 1vZ2s9-00000000Nh3-1GAM; Fri, 26 Dec 2025 11:08:29 +0300 Date: Fri, 26 Dec 2025 11:08:27 +0300 To: Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org Message-ID: References: <3e3085c7a9bcb7d1a185e683c8d774a57cb7816a.1761301736.git.skaplun@tarantool.org> <5d871254-9296-4eea-9b85-b636c1f80a7e@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5d871254-9296-4eea-9b85-b636c1f80a7e@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD979975AF0D777FEBD136B1DE29D0A141801E96C80D96E6DBF182A05F5380850400E4D60C38971411E3DE06ABAFEAF670541B46A3853D072234F327FDBBEDA3D8193B27CBAA3F87F55 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE76C0A440987CA342DC2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6759CC434672EE6371C2A783ECEC0211ADC4224003CC836476D5A39DEEDB180909611E41BBFE2FEB2B1908C77DA452F17F082CD01A26F068AC200EC12173A9B030B59C9EFF9DB5FC859FA2833FD35BB23D9E625A9149C048EE33AC447995A7AD18CB629EEF1311BF91D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B974A882099E279BDA471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C5C8BF3F796D5A11743847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A574389735AFE84ED55002B1117B3ED6969BED9EA57F7043F41BDDAE3D1EA49BEA823CB91A9FED034534781492E4B8EEADA3A806F356AF31D6 X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE1918E10F71CB4DF9F96AB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659CE7A3F107F80A236E2CF81B67039CDBBE6122E49E0540356E0B1DFBC4B858DCA224F5C651CB4BC7CB8341EE9D5BE9A0A089C01EEB04587E9DFB0FEEB0AA48038D493718BB5EFBBD18CD93680B12512CF4C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdtTL5f5BIXbMTufFerJ+BY= X-DA7885C5: D77FF61DD779A0B2F255D290C0D534F95B0B461C34F57003436FFF3FEBE6B1C3BD4D0D382E4E694F5B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393DDD5FD59B456EAD259C802B66E873FA12B6336404C342932D06A5F224C73C888E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 luajit 05/41] perf: adjust binary-trees 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 13.11.25, Sergey Bronnikov wrote: > Hi, Sergey! > > thanks for the patch! > > 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. > > > > The test cases are split by the different types of trees: > > 1) stretched tree, > > 2) long-lived tree, > > 3) several trees with a depth of the power of 2, > > 4) iteration over all trees in the third test case. > > > > The number of items is the number of `ItemCheck()` first-level calls > > performed in the payload. > > --- > > > > I'm not sure that we should distinguish different subtests here. > > OTOH, how to calculate the amount of items correctly for the whole test > > instead? Discussed offline to leave different subtests for now. > > > > perf/LuaJIT-benches/binary-trees.lua | 94 ++++++++++++++++++++++------ > > 1 file changed, 76 insertions(+), 18 deletions(-) > > > > diff --git a/perf/LuaJIT-benches/binary-trees.lua b/perf/LuaJIT-benches/binary-trees.lua > > index bf040466..9d4dc7b4 100644 > > --- a/perf/LuaJIT-benches/binary-trees.lua > > +++ b/perf/LuaJIT-benches/binary-trees.lua > > @@ -1,3 +1,4 @@ Also, added the comment with the benchmark description as we discussed offline. =================================================================== diff --git a/perf/LuaJIT-benches/binary-trees.lua b/perf/LuaJIT-benches/binary-trees.lua index ae02a1ab..df288032 100644 --- a/perf/LuaJIT-benches/binary-trees.lua +++ b/perf/LuaJIT-benches/binary-trees.lua @@ -1,3 +1,9 @@ +-- The benchmark to check the performance of the GC and memory +-- allocator. Allocate, walk, and deallocate many bottom-up binary +-- trees. +-- For the details, see: +-- https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/binarytrees.html + local bench = require("bench").new(arg) local function BottomUpTree(item, depth) @@ -28,6 +34,8 @@ if maxdepth < N then maxdepth = N end local stretchdepth = maxdepth + 1 +-- Allocate a binary tree to "stretch" memory, check it exists, +-- and "deallocate" it. bench:add({ name = "stretch_depth_" .. tostring(stretchdepth), payload = function() @@ -41,9 +49,12 @@ bench:add({ end, }) +-- Allocate a long-lived binary tree that will live on while +-- other trees are allocated and "deallocated". -- This tree created once on the setup for the first test. local longlivedtree +-- Allocate, walk, and "deallocate" many bottom-up binary trees. for depth = mindepth, maxdepth, 2 do local iterations = 2 ^ (maxdepth - depth + mindepth) local tree_bench @@ -71,6 +82,7 @@ for depth = mindepth, maxdepth, 2 do bench:add(tree_bench) end +-- Check that the long-lived binary tree still exists. bench:add({ name = "longlived_depth_" .. tostring(maxdepth), payload = function() @@ -83,6 +95,7 @@ bench:add({ end, }) +-- All in one benchmark for the various trees. bench:add({ name = "all_in_one", payload = function() =================================================================== > > +local bench = require("bench").new(arg) > > > > local function BottomUpTree(item, depth) > > if depth > 0 then > > @@ -18,30 +19,87 @@ local function ItemCheck(tree) > > end > > end > > > > -local N = tonumber(arg and arg[1]) or 0 > > +local N = tonumber(arg and arg[1]) or 16 > Why 16? 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 mindepth = 4 > > local maxdepth = mindepth + 2 > > if maxdepth < N then maxdepth = N end > > > > -do > > - local stretchdepth = maxdepth + 1 > > - local stretchtree = BottomUpTree(0, stretchdepth) > > - io.write(string.format("stretch tree of depth %d\t check: %d\n", > > - stretchdepth, ItemCheck(stretchtree))) > > -end > > +local stretchdepth = maxdepth + 1 > > + > > +bench:add({ > > + name = "stretch_depth_" .. tostring(stretchdepth), > > + payload = function() > > + local stretchtree = BottomUpTree(0, stretchdepth) > > + local check = ItemCheck(stretchtree) > > + return check > > + end, > > + items = 1, > > + checker = function(check) > > + return check == -1 > it deserves a comment Added the corresponding comment to the `ItemCheck()`. =================================================================== diff --git a/perf/LuaJIT-benches/binary-trees.lua b/perf/LuaJIT-benches/binary-trees.lua index 9d4dc7b4..75c60332 100644 --- a/perf/LuaJIT-benches/binary-trees.lua +++ b/perf/LuaJIT-benches/binary-trees.lua @@ -11,6 +11,8 @@ local function BottomUpTree(item, depth) end end +-- The checker function. For the tree created with the given +-- `item` returns `item` - 1 (by induction). local function ItemCheck(tree) if tree[2] then return tree[1] + ItemCheck(tree[2]) - ItemCheck(tree[3]) =================================================================== > > + end, > > +}) > > > > -local longlivedtree = BottomUpTree(0, maxdepth) > > +-- This tree created once on the setup for the first test. > > +local longlivedtree > > I don't like that we should save a benchmark state in global variables. > > What if we allow setting a user-defined object that will have a state > > and this state will be passed to checker/payload functions? This changes the semantics of the benchmark. It is improtant that the state is created in the first benchmark and used later as an upvalue, for the example. > > > > > +bench:add({ > > + name = "all_in_once", > s/all_in_once/all_in_one/? Renamed: =================================================================== diff --git a/perf/LuaJIT-benches/binary-trees.lua b/perf/LuaJIT-benches/binary-trees.lua index 75c60332..ae02a1ab 100644 --- a/perf/LuaJIT-benches/binary-trees.lua +++ b/perf/LuaJIT-benches/binary-trees.lua @@ -84,7 +84,7 @@ bench:add({ }) bench:add({ - name = "all_in_once", + name = "all_in_one", payload = function() for depth = mindepth, maxdepth, 2 do local iterations = 2 ^ (maxdepth - depth + mindepth) =================================================================== > > + payload = function() -- Best regards, Sergey Kaplun