<!DOCTYPE html>
<html data-lt-installed="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body style="padding-bottom: 1px;">
<p>Hi, Sergey!</p>
<p>thanks for the patch! LGTM</p>
<p>Sergey</p>
<div class="moz-cite-prefix">On 12/26/25 12:17, Sergey Kaplun wrote:<br>
</div>
<blockquote type="cite"
cite="mid:442e37ae075f4d22517a035eaee2e5e37d1a5cc1.1766738771.git.skaplun@tarantool.org">
<pre wrap="" class="moz-quote-pre">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,<a class="moz-txt-link-rfc2396E" href="whenonecoroutine+--isactiveandothersarewaitingtheirturn.+--Forthedetailssee:+--https://pybenchmarks.org/u64q/performance.php?test=threadring++localbench=require(">" 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("</a>bench").new(arg)
+
-- The Computer Language Benchmarks Game
-- <a class="moz-txt-link-freetext" href="http://shootout.alioth.debian.org/">http://shootout.alioth.debian.org/</a>
-- 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()
</pre>
</blockquote>
</body>
<lt-container></lt-container>
</html>