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 CF7281679204; Fri, 26 Dec 2025 11:20:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org CF7281679204 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1766737223; bh=wf1dC7lV4KwbhvJH1Z4EDqrucBMcBXeV1SAOZV4DOnw=; 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=O2eOdvHmWCAYSIevx77Y6dtriF3nx1Dx4sYsY6lI8iSWfAuK+zU9pu/34S8rMep5W M5YL+nv6BiDPS9aIHuQv4ubUHqBRJ/fojk2eJpPNuB9Vp/GzfY9dBTEdDz03usyBXY uDNLyvLMbnsrg01w3bEnDH9q2pjCL4mehQePiWp4= Received: from send264.i.mail.ru (send264.i.mail.ru [95.163.59.103]) (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 394241679200 for ; Fri, 26 Dec 2025 11:20:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 394241679200 Received: by exim-smtp-7b4fb89df9-dkm8m with esmtpa (envelope-from ) id 1vZ33d-00000000Boj-19m2; Fri, 26 Dec 2025 11:20:21 +0300 Date: Fri, 26 Dec 2025 11:20:19 +0300 To: Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org Message-ID: References: <8bfd29047e9f8af98dfc43ac86cfc390ebd03484.1761301736.git.skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD979975AF0D777FEBDD803ECE58504FBFD117E6A90C4FE9736182A05F5380850404EE062CC0C496D693DE06ABAFEAF6705C37CF099A4FFE923C3CE4153D521EAFE090598096E5E7227 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7D4A169723F56FEDEEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566657B88B02DF8C869EA30D41A9E8179701557A3A3267E345F514E7E637B1B4E97389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6957A4DEDD2346B42CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE76D0F27F7E6A6C418731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A549216264D757AE7D5002B1117B3ED696DEFF867E690C6B44E99897350C7C491E823CB91A9FED034534781492E4B8EEADDFC043C56F70D752BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D65918067F69A69B3BEBF4A88EE48E1F0A2FE81882B6725D8504F8DCB418CD7E840853E4F49C96B16F7FB8341EE9D5BE9A0A7616592B23550485727555324C81CC3091CF373CDBDF81DC8CD93680B12512CF4C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdtTL5f5BIXbKdRNbEP9Jn8= X-DA7885C5: 747DA1F62EC1135DF255D290C0D534F94DB2B91BBB0DFF355B86D5915A0081B7CF0FDF3384639B955B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393DDD5FD59B456EAD26BDC418042E2D28F715E69D6E49E7BF9D363A09F80C0F2C6E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 luajit 13/41] perf: adjust mandelbrot-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 answered your questions 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. > > > > The output is redirected to /dev/null. The check is skipped since it is > > very inconvenient to check the binary output, especially since it may be > > configured by the parameter. > > --- > > perf/LuaJIT-benches/mandelbrot-bit.lua | 86 +++++++++++++++++--------- > > 1 file changed, 57 insertions(+), 29 deletions(-) > > > > diff --git a/perf/LuaJIT-benches/mandelbrot-bit.lua b/perf/LuaJIT-benches/mandelbrot-bit.lua > > index 91d96975..a6b5e1f8 100644 > > --- a/perf/LuaJIT-benches/mandelbrot-bit.lua > > +++ b/perf/LuaJIT-benches/mandelbrot-bit.lua Added the comment with the short benchmark description, as we discussed offline: =================================================================== diff --git a/perf/LuaJIT-benches/mandelbrot-bit.lua b/perf/LuaJIT-benches/mandelbrot-bit.lua index 88df480e..53c3ad4e 100644 --- a/perf/LuaJIT-benches/mandelbrot-bit.lua +++ b/perf/LuaJIT-benches/mandelbrot-bit.lua @@ -1,3 +1,10 @@ +-- The benchmark to check the performance of multiple inner loops +-- with arithmetic operations. Bit variation. Calculates the +-- Mandelbrot Set on a bitmap and dumps output in the portable +-- bitmap format. +-- For the details see: +-- https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/mandelbrot.html + local bit = require("bit") local bench = require("bench").new(arg) =================================================================== > > @@ -1,33 +1,61 @@ > > - > > local bit = require("bit") > > +local bench = require("bench").new(arg) > > + > > +local N = tonumber(arg and arg[1]) or 5000 > > + > > +local function payload() > > + -- These functions must not be an upvalue but the stack slot. > please add here details about performance impact I suppose this is related to the open upvalue fetching overhead, but I'm not sure. I suggest to postponing this research out of scope of this issue. > > + local N = N > > + local bor, band = bit.bor, bit.band > > + local shl, shr, rol = bit.lshift, bit.rshift, bit.rol > > + local write, char, unpack = io.write, string.char, unpack > > + > > + local M, buf = 2/N, {} > > + write("P4\n", N, " ", N, "\n") > > + for y=0,N-1 do > please add spaces here and below Fixed the formating as you suggested: =================================================================== diff --git a/perf/LuaJIT-benches/mandelbrot-bit.lua b/perf/LuaJIT-benches/mandelbrot-bit.lua index a6b5e1f8..88df480e 100644 --- a/perf/LuaJIT-benches/mandelbrot-bit.lua +++ b/perf/LuaJIT-benches/mandelbrot-bit.lua @@ -11,30 +11,30 @@ local function payload() local shl, shr, rol = bit.lshift, bit.rshift, bit.rol local write, char, unpack = io.write, string.char, unpack - local M, buf = 2/N, {} + local M, buf = 2 / N, {} write("P4\n", N, " ", N, "\n") - for y=0,N-1 do - local Ci, b, p = y*M-1, -16777216, 0 - local Ciq = Ci*Ci - for x=0,N-1,2 do - local Cr, Cr2 = x*M-1.5, (x+1)*M-1.5 - local Zr, Zi, Zrq, Ziq = Cr, Ci, Cr*Cr, Ciq - local Zr2, Zi2, Zrq2, Ziq2 = Cr2, Ci, Cr2*Cr2, Ciq + for y = 0, N - 1 do + local Ci, b, p = y * M - 1, -16777216, 0 + local Ciq = Ci * Ci + for x = 0, N - 1, 2 do + local Cr, Cr2 = x * M - 1.5, (x + 1) * M - 1.5 + local Zr, Zi, Zrq, Ziq = Cr, Ci, Cr * Cr, Ciq + local Zr2, Zi2, Zrq2, Ziq2 = Cr2, Ci, Cr2 * Cr2, Ciq b = rol(b, 2) - for i=1,49 do - Zi = Zr*Zi*2 + Ci; Zi2 = Zr2*Zi2*2 + Ci - Zr = Zrq-Ziq + Cr; Zr2 = Zrq2-Ziq2 + Cr2 - Ziq = Zi*Zi; Ziq2 = Zi2*Zi2 - Zrq = Zr*Zr; Zrq2 = Zr2*Zr2 - if band(b, 2) ~= 0 and Zrq+Ziq > 4.0 then b = band(b, -3) end - if band(b, 1) ~= 0 and Zrq2+Ziq2 > 4.0 then b = band(b, -2) end + for i = 1, 49 do + Zi = Zr * Zi * 2 + Ci; Zi2 = Zr2 * Zi2 * 2 + Ci + Zr = Zrq - Ziq + Cr; Zr2 = Zrq2 - Ziq2 + Cr2 + Ziq = Zi * Zi; Ziq2 = Zi2 * Zi2 + Zrq = Zr * Zr; Zrq2 = Zr2 * Zr2 + if band(b, 2) ~= 0 and Zrq + Ziq > 4.0 then b = band(b, -3) end + if band(b, 1) ~= 0 and Zrq2 + Ziq2 > 4.0 then b = band(b, -2) end if band(b, 3) == 0 then break end end if b >= 0 then p = p + 1; buf[p] = b; b = -16777216; end end if b ~= -16777216 then if band(N, 1) ~= 0 then b = shr(b, 1) end - p = p + 1; buf[p] = shl(b, 8-band(N, 7)) + p = p + 1; buf[p] = shl(b, 8 - band(N, 7)) end write(char(unpack(buf, 1, p))) end =================================================================== > > + local Ci, b, p = y*M-1, -16777216, 0 > > + local Ciq = Ci*Ci > > + for x=0,N-1,2 do > > + local Cr, Cr2 = x*M-1.5, (x+1)*M-1.5 > > + local Zr, Zi, Zrq, Ziq = Cr, Ci, Cr*Cr, Ciq > > + local Zr2, Zi2, Zrq2, Ziq2 = Cr2, Ci, Cr2*Cr2, Ciq > > + b = rol(b, 2) > > + for i=1,49 do > > + Zi = Zr*Zi*2 + Ci; Zi2 = Zr2*Zi2*2 + Ci > > + Zr = Zrq-Ziq + Cr; Zr2 = Zrq2-Ziq2 + Cr2 > > + Ziq = Zi*Zi; Ziq2 = Zi2*Zi2 > > + Zrq = Zr*Zr; Zrq2 = Zr2*Zr2 > > + if band(b, 2) ~= 0 and Zrq+Ziq > 4.0 then b = band(b, -3) end > > + if band(b, 1) ~= 0 and Zrq2+Ziq2 > 4.0 then b = band(b, -2) end > > + if band(b, 3) == 0 then break end > > + end > > + if b >= 0 then p = p + 1; buf[p] = b; b = -16777216; end > > end > > - if b >= 0 then p = p + 1; buf[p] = b; b = -16777216; end > > - end > > - if b ~= -16777216 then > > - if band(N, 1) ~= 0 then b = shr(b, 1) end > > - p = p + 1; buf[p] = shl(b, 8-band(N, 7)) > > + if b ~= -16777216 then > > + if band(N, 1) ~= 0 then b = shr(b, 1) end > > + p = p + 1; buf[p] = shl(b, 8-band(N, 7)) > > + end > > + write(char(unpack(buf, 1, p))) > > end > > - write(char(unpack(buf, 1, p))) > > end -- Best regards, Sergey Kaplun