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 5503216AFFE9; Fri, 26 Dec 2025 12:24:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5503216AFFE9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1766741092; bh=4yE1w+aNA+AEJYdn8goi7j0hXBj1ZZj85jnR0YpPJZc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Wr9E1l//VYnLb2TnIPEmqWTP0E6vWUkwOmLH/wqEfXDpFte5fC33oGyuUbx3tpbd+ xiDrHtXolpLjjJYVektgwH7QMEIhMMcTEiqpj0XMFlMyo2B3Vv03E9dcqVMoqBiitl b7nvYKZ4/YFkAmgV+z6qAdaiHaw8v+rNiAUbF+MQ= 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 3C9D416C6587 for ; Fri, 26 Dec 2025 12:18:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3C9D416C6587 Received: by exim-smtp-7b4fb89df9-lft7n with esmtpa (envelope-from ) id 1vZ3xz-000000008Cp-41EL; Fri, 26 Dec 2025 12:18:36 +0300 To: Sergey Bronnikov Date: Fri, 26 Dec 2025 12:17:44 +0300 Message-ID: <23d14fcc8fd6ba47ea75bd636993d9093fc41a7b.1766738771.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD979975AF0D777FEBD826642AD4A5343575326B9AFFB3FD97C182A05F538085040FBAB0656C6F1467F3DE06ABAFEAF6705BD734DCAF6AAB88BB4FA2C6BBBE99EF9ACCB5262BB561CA2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE736691C7D10565E03C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6759CC434672EE6371C2A783ECEC0211ADC4224003CC836476D5A39DEEDB180909611E41BBFE2FEB2B7B4699E5C84C05A1BDD5A865A6FFD99694236136F7BB7BEB73AB095DB10CC5FE9FA2833FD35BB23D9E625A9149C048EE1E561CDFBCA1751F6FD1C55BDD38FC3FD2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BC908CD1B87A134A2A471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C2C2559B29ED8195043847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A58C9BA01E3313BBEE5002B1117B3ED69664861209F3368237A9DAB4B68AE4D22F823CB91A9FED034534781492E4B8EEADF1165EFABA1780A6C79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659EBE8DE3EE25850EBA888729904C477FB7C53A0F1F70BEB41E89F79E112886871F875CC0AF052833AB8341EE9D5BE9A0A6A1B2128E93C6D7505D8439B09F6DFF09B4D4AD16CF908D06536EB022892E5344C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdtTL5f5BIXb6UWHsBKnpYU= X-Mailru-Sender: 689FA8AB762F7393DDD5FD59B456EAD2A7F80A34FD3EDD568700636FE984EBB8DD2B628584ADF0F2E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 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 Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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 | 91 ++++++++++++++++++-------- 1 file changed, 63 insertions(+), 28 deletions(-) diff --git a/perf/LuaJIT-benches/mandelbrot-bit.lua b/perf/LuaJIT-benches/mandelbrot-bit.lua index 91d96975..53c3ad4e 100644 --- a/perf/LuaJIT-benches/mandelbrot-bit.lua +++ b/perf/LuaJIT-benches/mandelbrot-bit.lua @@ -1,33 +1,68 @@ +-- 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 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. + 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 + 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() -- 2.52.0