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 7F59515DEA91; Mon, 17 Nov 2025 16:29:14 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7F59515DEA91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1763386154; bh=rT8U5y07tF572thFjOeSGELHHA61iuymkRGS80ll6wM=; 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=zmrCZEUwcmZc26Ja7HoC2+SK83rtMXI3SeksfYcCdRXmNjhteHdBhsA4CnbMXRbGl QRYi1231378dWhUzMaQFam47Enufz/1VH97g7ZHLSicAK3IpDmr0AzsUSrrB/vGcX4 OgsHsrQFQmTLC5FQBR9vnaWFiKcscKbRd2aLAGC0= Received: from send175.i.mail.ru (send175.i.mail.ru [95.163.59.14]) (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 1D0BD15DEA91 for ; Mon, 17 Nov 2025 16:26:16 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1D0BD15DEA91 Received: by exim-smtp-77df68b9cf-k4thg with esmtpa (envelope-from ) id 1vKzFH-00000000Aek-0Xz0; Mon, 17 Nov 2025 16:26:15 +0300 Content-Type: multipart/alternative; boundary="------------gn1jXvUAetqNwe8ihdZHD0xo" Message-ID: Date: Mon, 17 Nov 2025 16:26:14 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org References: <8bfd29047e9f8af98dfc43ac86cfc390ebd03484.1761301736.git.skaplun@tarantool.org> Content-Language: en-US In-Reply-To: <8bfd29047e9f8af98dfc43ac86cfc390ebd03484.1761301736.git.skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD9110BAFCBE6BD1D160D3FAA8110F1443D3B6E995AD069BC4E182A05F5380850400F2549AFAED4B2DB3DE06ABAFEAF6705E8B33AC5A125B9DB3C1CBB97E487F8EECC29A3283896A6B0 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7D9B0C78E17BAE9D7EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566D0BE23D09F2BEA506D1448BC8BD00467408A415DC94CB97D79F8D98ABB9F9469389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B64854413538E1713FCC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C2249B899183D4666AAE776E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8B89C074F960B19C4B3AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B0B7D0EA88DDEDAC722CA9DD8327EE4930A3850AC1BE2E7358CCB3ED2A1DE2304C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A55114673E0940E75E5002B1117B3ED69631DB27F9BD6F096C4869453249F34FA4823CB91A9FED034534781492E4B8EEAD14747542773C033FBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF7F47CB8FB2AADD10DE50CD3C8E1C0CEA3A97C42804A3AB98C44811C6955F498F35D9E4C97941E9B1DD12B02666E4935636E24172F4B97C81E17169D636A2256971F014284DB13964111DC66A97D0BFE2913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVfFX+FmbwDW1bnOpKaGt7+A= X-Mailru-Sender: 520A125C2F17F0B1A9638AD358559B5979FE287AD6C14B553DE06ABAFEAF6705E8B33AC5A125B9DBB7CBEF92542CD7C8795FA72BAB74744FC77752E0C033A69EA16A481184E8BB1C9B38E6EA4F046BE03A5DB60FBEB33A8A0DA7A0AF5A3A8387 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 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. --------------gn1jXvUAetqNwe8ihdZHD0xo 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. > > 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 > @@ -1,33 +1,61 @@ > - > local bit = require("bit") > -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 N = tonumber(arg and arg[1]) or 100 > -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 > - 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 > + > +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 > + 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 > + 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 > + > +local stdout = io.output() > + > +bench:add({ > + name = "mandelbrot_bit", > + items = N, > + -- XXX: This is inconvenient to have the binary file in the > + -- repository for the comparison. If the check is needed, run > + -- the payload manually. > + skip_check = true, > + setup = function() > + io.output("/dev/null") > + end, > + teardown = function() > + io.output(stdout) > + end, > + payload = payload, > +}) > + > +bench:run_and_report() > --------------gn1jXvUAetqNwe8ihdZHD0xo 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.

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
@@ -1,33 +1,61 @@
-
 local bit = require("bit")
-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 N = tonumber(arg and arg[1]) or 100
-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
-    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
+
+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
+  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
+    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
+
+local stdout = io.output()
+
+bench:add({
+  name = "mandelbrot_bit",
+  items = N,
+  -- XXX: This is inconvenient to have the binary file in the
+  -- repository for the comparison. If the check is needed, run
+  -- the payload manually.
+  skip_check = true,
+  setup = function()
+    io.output("/dev/null")
+  end,
+  teardown = function()
+    io.output(stdout)
+  end,
+  payload = payload,
+})
+
+bench:run_and_report()

--------------gn1jXvUAetqNwe8ihdZHD0xo--