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 903CB16B02D1; Fri, 26 Dec 2025 11:11:54 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 903CB16B02D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1766736714; bh=Z4iiBIyFOUWRvWnmX3o2b2eTrV0k0jAq/M4lzNuFIds=; 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=JmhoHGYdxc9GfRo5ap98JZvd/a7eZybYBQp6NTS3xAujOdV2GQm0bxrSftM8AUO0t InnayJNUTbG2TDn4KSFtk0F+QnUWUOx8LxZTbeS7+x1+wKQal+5Opw5knuPsPalpbn HhP/FS8myRi2KisQSElViZrX4zXds+M5FysKMbIo= Received: from send242.i.mail.ru (send242.i.mail.ru [95.163.59.81]) (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 B6C0B16B02CC for ; Fri, 26 Dec 2025 11:11:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B6C0B16B02CC Received: by exim-smtp-7b4fb89df9-tpcsk with esmtpa (envelope-from ) id 1vZ2vP-000000001S3-30Eh; Fri, 26 Dec 2025 11:11:52 +0300 Date: Fri, 26 Dec 2025 11:11:49 +0300 To: Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org Message-ID: References: <7b761c35d6f2126d36a1d6057fb59b1020b53b99.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: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD979975AF0D777FEBD826642AD4A5343575326B9AFFB3FD97C182A05F538085040B998FD4305204DCC3DE06ABAFEAF67058682FF3C700322A54F327FDBBEDA3D81ACCB5262BB521CA2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE74EB183AD45C8BEFBEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566657B88B02DF8C869BFE9F529F816B1DEB9B3603FFFCAC48D279BC09A10B6B0A8389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C07E7E81EEA8A9722B8941B15DA834481FCF19DD082D7633A0EF3E4896CB9E6436389733CBF5DBD5E9D5E8D9A59859A8B6957A4DEDD2346B42CC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB86D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE79E9721B410A3B6ED731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5B327C8015BD5A93C5002B1117B3ED696EFA0DA4980935D7E8B25839F35DFE037823CB91A9FED034534781492E4B8EEAD5E90D3DD2A5B7EAFBDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D6594BEF8A686776E428EAE289305EBCB8CB90066AAD819C8D9892181D2BF30E0BEC993D29730432D7B4B8341EE9D5BE9A0AB7B9D51D33679B133168CA02D5D0B7BE2394E5DD6711C8BE8CD93680B12512CF4C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdtTL5f5BIXb582ePzpOsgM= X-DA7885C5: 634D316ED9CDC980F255D290C0D534F95663B68F3EBA4CFF4A0640B1806363B33E72F795356EE0845B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393DDD5FD59B456EAD2DAD04ED0DBD12993718E01BD462861EB2970632D586FFCDDE49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v1 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 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! Fixes your comments and added the description to the benchmark. On 13.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. > > --- > > perf/LuaJIT-benches/coroutine-ring.lua | 45 ++++++++++++++++---------- > > 1 file changed, 28 insertions(+), 17 deletions(-) > > > > diff --git a/perf/LuaJIT-benches/coroutine-ring.lua b/perf/LuaJIT-benches/coroutine-ring.lua > > index 1e8c5ef6..1b86a5ba 100644 > > --- a/perf/LuaJIT-benches/coroutine-ring.lua > > +++ b/perf/LuaJIT-benches/coroutine-ring.lua > > @@ -1,3 +1,5 @@ Also, added the comment with the benchmark description as we discussed offline. =================================================================== diff --git a/perf/LuaJIT-benches/coroutine-ring.lua b/perf/LuaJIT-benches/coroutine-ring.lua index 1b86a5ba..8efe7b2a 100644 --- a/perf/LuaJIT-benches/coroutine-ring.lua +++ b/perf/LuaJIT-benches/coroutine-ring.lua @@ -1,3 +1,9 @@ +-- 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 =================================================================== > > +local bench = require("bench").new(arg) > > + > > -- The Computer Language Benchmarks Game > > --http://shootout.alioth.debian.org/ > > -- contributed by Sam Roberts > > +bench:add({ > > + name = "coroutine_ring", > > + payload = function() > > + local token = 0 > a single whitespace before "=" Fixed. See the iterative patch below. > > + -- create all threads > First letter is in uppercase and a dot at the end. Fixed. See the iterative patch below. > > + local threads = {} > a single whitespace before "=" Fixed. See the iterative patch below. > > + for id = 1, poolsize do > > + threads[id] = create(body) > > + end > > + > > + -- send the token > First letter is in uppercase and a dot at the end. Fixed: =================================================================== diff --git a/perf/LuaJIT-benches/coroutine-ring.lua b/perf/LuaJIT-benches/coroutine-ring.lua index 1b86a5ba..e1455205 100644 --- a/perf/LuaJIT-benches/coroutine-ring.lua +++ b/perf/LuaJIT-benches/coroutine-ring.lua @@ -27,14 +27,14 @@ end bench:add({ name = "coroutine_ring", payload = function() - local token = 0 - -- create all threads - local threads = {} + local token = 0 + -- Create all threads. + local threads = {} for id = 1, poolsize do threads[id] = create(body) end - -- send the token + -- Send the token. repeat if id == poolsize then id = 1 =================================================================== > > + 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, > > +}) > > + > > +bench:run_and_report() > > > > -io.write(id, "\n") I've also refactored the benchmark to make it performance match the original version: =================================================================== diff --git a/perf/LuaJIT-benches/coroutine-ring.lua b/perf/LuaJIT-benches/coroutine-ring.lua index 8efe7b2a..747a2ecc 100644 --- a/perf/LuaJIT-benches/coroutine-ring.lua +++ b/perf/LuaJIT-benches/coroutine-ring.lua @@ -17,13 +17,8 @@ local n = tonumber(arg and arg[1]) or 2e7 local poolsize = 503 -- cache these to avoid global environment lookups -local create = coroutine.create -local resume = coroutine.resume local yield = coroutine.yield -local id = 1 -local ok - local body = function(token) while true do token = yield(token + 1) @@ -33,7 +28,18 @@ end bench:add({ name = "coroutine_ring", payload = function() + -- Cache to avoid upvalue lookups. local token = 0 + local n = n + local poolsize = poolsize + + -- 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 =================================================================== Also, removed excess empty line at the end of the file: =================================================================== diff --git a/perf/LuaJIT-benches/coroutine-ring.lua b/perf/LuaJIT-benches/coroutine-ring.lua index 8efe7b2a..747a2ecc 100644 --- a/perf/LuaJIT-benches/coroutine-ring.lua +++ b/perf/LuaJIT-benches/coroutine-ring.lua @@ -56,4 +62,3 @@ bench:add({ }) bench:run_and_report() - =================================================================== -- Best regards, Sergey Kaplun