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 3299D16744CA; Mon, 29 Dec 2025 17:10:12 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 3299D16744CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1767017412; bh=1gZChijd69VhuScIUlpCat3SHdqft+Uhml3qoAwD4hY=; 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=hi8HB3zIUJF+e/zGAfh6x3TbIPzQhkz6AA16I1MjumULq18Y9bV2EqFBibSQp09le ir52FGSC380sgZYlmcw7NB7QCOhBp+Sao6GD3Q+VswLfYtsyzDugPInPKBwZhLK85J QEi6zQ5N8M6HvQpmY0qxifV1Zw0YyYw8ME5nAosE= Received: from send129.i.mail.ru (send129.i.mail.ru [89.221.237.224]) (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 1004216744CA for ; Mon, 29 Dec 2025 17:10:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1004216744CA Received: by exim-smtp-7b4fb89df9-pmfc6 with esmtpa (envelope-from ) id 1vaDwn-00000000GCD-2sKC; Mon, 29 Dec 2025 17:10:10 +0300 Content-Type: multipart/alternative; boundary="------------GEZh850bOALuBsBf0VnHuRx0" Message-ID: <559c57b4-fa03-457f-9e19-bf0629ec8d1c@tarantool.org> Date: Mon, 29 Dec 2025 17:10:09 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org References: <442e37ae075f4d22517a035eaee2e5e37d1a5cc1.1766738771.git.skaplun@tarantool.org> In-Reply-To: <442e37ae075f4d22517a035eaee2e5e37d1a5cc1.1766738771.git.skaplun@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD979975AF0D777FEBD136B1DE29D0A14187F3E33C5CB109B4B182A05F5380850409D5B75E58244171B3DE06ABAFEAF67054E4BF77A9C05EB100DDD1C039072FB1BB14F0FA0E0289DA8 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7051A6EFB787CE9C4EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637FE9EFE935CD7C6AE8638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B229E95F2757D55ADE2E070BE324C7D3C46778AFD2E34D842FF6B57BC7E64490618DEB871D839B73339E8FC8737B5C2249D082881546D93491CC7F00164DA146DAFE8445B8C89999729449624AB7ADAF37F6B57BC7E64490611E7FA7ABCAF51C92176DF2183F8FC7C0A3E989B1926288338941B15DA834481F9449624AB7ADAF37BA3038C0950A5D3613377AFFFEAFD269176DF2183F8FC7C0BCF2C0F5768D5B7A7B076A6E789B0E97A8DF7F3B2552694AD5FFEEA1DED7F25D49FD398EE364050F9647ADFADE5905B103CEA74F0D118906B3661434B16C20ACC84D3B47A649675FE827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8B851EDB9C5A93305EEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A5D42416D659F56EED5002B1117B3ED696CB8E05D776A7D22130C8F815570A3530823CB91A9FED034534781492E4B8EEAD9CFA8CFAC159CE19BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D6596335979D0750BC4CE3D23CEE98C4CFF642CEDA094F1D29E5C3C7414A5FF5EB8AEA73EAC6CE28862AB8341EE9D5BE9A0A2ABB9E5FBDCF1C366F3705A673DA8331299EB2B9B7FCB60F8CD93680B12512CF4C41F94D744909CE2512F26BEC029E55448553D2254B8D95CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVTZJppT4ZVHRIqvggwB+CyU= X-Mailru-Sender: 811C44EDE0507D1FF7A5115BD94F8393AC61451CC95DF62E0045A77C8BEB847D3BCD098D5D3F1157EE648204527A2A2D645D15D82EE4B272BD6E4642A116CA93524AA66B5ACBE6721EF430B9A63E2A504198E0F3ECE9B5443453F38A29522196 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v2 luajit 07/41] perf: adjust coroutine-ring 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. --------------GEZh850bOALuBsBf0VnHuRx0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Sergey! thanks for the patch! LGTM Sergey On 12/26/25 12:17, 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/coroutine-ring.lua | 64 +++++++++++++++++--------- > 1 file changed, 43 insertions(+), 21 deletions(-) > > diff --git a/perf/LuaJIT-benches/coroutine-ring.lua b/perf/LuaJIT-benches/coroutine-ring.lua > index 1e8c5ef6..747a2ecc 100644 > --- a/perf/LuaJIT-benches/coroutine-ring.lua > +++ b/perf/LuaJIT-benches/coroutine-ring.lua > @@ -1,3 +1,11 @@ > +-- The benchmark to check the performance of coroutine interaction > +-- to test possible "death by concurrency," when one coroutine +-- is active and others are waiting their turn. > +-- For the details see: +-- > https://pybenchmarks.org/u64q/performance.php?test=threadring + +local > bench = require("bench").new(arg) > + > -- The Computer Language Benchmarks Game > --http://shootout.alioth.debian.org/ > -- contributed by Sam Roberts > @@ -7,36 +15,50 @@ local n = tonumber(arg and arg[1]) or 2e7 > > -- fixed size pool > local poolsize = 503 > -local threads = {} > > -- cache these to avoid global environment lookups > -local create = coroutine.create > -local resume = coroutine.resume > local yield = coroutine.yield > > -local id = 1 > -local token = 0 > -local ok > - > local body = function(token) > while true do > token = yield(token + 1) > end > end > > --- create all threads > -for id = 1, poolsize do > - threads[id] = create(body) > -end > +bench:add({ > + name = "coroutine_ring", > + payload = function() > + -- Cache to avoid upvalue lookups. > + local token = 0 > + local n = n > + local poolsize = poolsize > > --- send the token > -repeat > - if id == poolsize then > - id = 1 > - else > - id = id + 1 > - end > - ok, token = resume(threads[id], token) > -until token == n > + -- Cache these to avoid global environment lookups. > + local create = coroutine.create > + local resume = coroutine.resume > + > + local id = 1 > + local ok > + > + -- Create all threads. > + local threads = {} > + for id = 1, poolsize do > + threads[id] = create(body) > + end > + > + -- Send the token. > + repeat > + if id == poolsize then > + id = 1 > + else > + id = id + 1 > + end > + ok, token = resume(threads[id], token) > + until token == n > + return id > + end, > + checker = function(id) return id == (n % poolsize + 1) end, > + items = n, > +}) > > -io.write(id, "\n") > +bench:run_and_report() --------------GEZh850bOALuBsBf0VnHuRx0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

Hi, Sergey!

thanks for the patch! LGTM

Sergey

On 12/26/25 12:17, 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.
---
 perf/LuaJIT-benches/coroutine-ring.lua | 64 +++++++++++++++++---------
 1 file changed, 43 insertions(+), 21 deletions(-)

diff --git a/perf/LuaJIT-benches/coroutine-ring.lua b/perf/LuaJIT-benches/coroutine-ring.lua
index 1e8c5ef6..747a2ecc 100644
--- a/perf/LuaJIT-benches/coroutine-ring.lua
+++ b/perf/LuaJIT-benches/coroutine-ring.lua
@@ -1,3 +1,11 @@
+-- The benchmark to check the performance of coroutine interaction
+-- to test possible "death by concurrency," when one coroutine
+-- is active and others are waiting their turn.
+-- For the details see:
+-- https://pybenchmarks.org/u64q/performance.php?test=threadring
+
+local bench = require("bench").new(arg)
+
 -- The Computer Language Benchmarks Game
 -- http://shootout.alioth.debian.org/
 -- contributed by Sam Roberts
@@ -7,36 +15,50 @@ local n         = tonumber(arg and arg[1]) or 2e7
 
 -- fixed size pool
 local poolsize  = 503
-local threads   = {}
 
 -- cache these to avoid global environment lookups
-local create    = coroutine.create
-local resume    = coroutine.resume
 local yield     = coroutine.yield
 
-local id        = 1
-local token     = 0
-local ok
-
 local body = function(token)
   while true do
     token = yield(token + 1)
   end
 end
 
--- create all threads
-for id = 1, poolsize do
-  threads[id] = create(body)
-end
+bench:add({
+  name = "coroutine_ring",
+  payload = function()
+    -- Cache to avoid upvalue lookups.
+    local token = 0
+    local n = n
+    local poolsize = poolsize
 
--- send the token
-repeat
-  if id == poolsize then
-    id = 1
-  else
-    id = id + 1
-  end
-  ok, token = resume(threads[id], token)
-until token == n
+    -- Cache these to avoid global environment lookups.
+    local create = coroutine.create
+    local resume = coroutine.resume
+
+    local id = 1
+    local ok
+
+    -- Create all threads.
+    local threads = {}
+    for id = 1, poolsize do
+      threads[id] = create(body)
+    end
+
+    -- Send the token.
+    repeat
+      if id == poolsize then
+        id = 1
+      else
+        id = id + 1
+      end
+      ok, token = resume(threads[id], token)
+    until token == n
+    return id
+  end,
+  checker = function(id) return id == (n % poolsize + 1) end,
+  items = n,
+})
 
-io.write(id, "\n")
+bench:run_and_report()
--------------GEZh850bOALuBsBf0VnHuRx0--