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 714C416AFFCB; Fri, 26 Dec 2025 12:21:51 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 714C416AFFCB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1766740911; bh=WKJR4KKFwIprrBCVM8EZ9LKK8RrrU4U/HEYteE19A4M=; 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=i/adE2QgVQzQ2qDhcdYINouS/aQUSA77q2xUFI4BN3ayol+tZG5uS2UbhM9er9p5W EYAmEHowvx/Iif5xLrNk5/4jKX+t02/tVXaeb1qbHsCuMDniEGlJTGRzji0q4BTudQ QaZT8k+i4V7y51QP1VR/+ao23mfHbseRKYrpC2as= Received: from send83.i.mail.ru (send83.i.mail.ru [89.221.237.178]) (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 8C8DB16C6581 for ; Fri, 26 Dec 2025 12:18:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8C8DB16C6581 Received: by exim-smtp-7b4fb89df9-lft7n with esmtpa (envelope-from ) id 1vZ3xq-000000008Cp-28gf; Fri, 26 Dec 2025 12:18:26 +0300 To: Sergey Bronnikov Date: Fri, 26 Dec 2025 12:17:38 +0300 Message-ID: <442e37ae075f4d22517a035eaee2e5e37d1a5cc1.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: 4F1203BC0FB41BD979975AF0D777FEBD5FB5867E87496E3ED186ABB0F1A32B63182A05F538085040420667B85AF38BC43DE06ABAFEAF67051251D75D4CF086D1B4FA2C6BBBE99EF9CC5F390AC6C99595 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE76D24A1449B9F25A2EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC83A81C8FD4AD23D82A6BABE6F325AC2E85FA5F3EDFCBAA7353EFBB55337566657B88B02DF8C8696F11B1054AD1BE2E8EDCD39A7D089D1A1132624710720133389733CBF5DBD5E913377AFFFEAFD269176DF2183F8FC7C0C26CFBAC0749D213D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B55D5BE2F85BDEC5FA471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C2C2559B29ED8195043847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A5DE92CBFDFA067FA95002B1117B3ED696887AEA6BAE11E49F3D2BBC1EF78EDEBE823CB91A9FED034534781492E4B8EEADD0953842B444AAC3C79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0AD73CAD6646DEDE191716CD42B3DD1D34CAB70F9BE574AE9C625B6776AC983F447FC0B9F89525902EE6F57B2FD27647F25E66C117BDB76D659F9929B9304B3AC4F7AB2938DDC51224FF596EDCA57C92DFE64E70166905A79EADD5A359C8A1C5158B8341EE9D5BE9A0AE6ED2D0A271701FC05D8439B09F6DFF022AA756EDC8284A66536EB022892E5344C41F94D744909CECFA6C6B0C050A61A8CAF69B82BA93681CD72808BE417F3B9E0E7457915DAA85F X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVdtTL5f5BIXbVFpjQHa4ERM= X-Mailru-Sender: 689FA8AB762F7393DDD5FD59B456EAD29D9DB5A5287FA9368700636FE984EBB898F41BE63C08EED3E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: [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 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. --- 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() -- 2.52.0