Skip to content

Commit 47fc815

Browse files
committed
TOOLS/command-test.lua: add test for async subprocess command blocking
On master, this takes around 4000ms for me. While with #14973 it completes in 10ms
1 parent ef531e1 commit 47fc815

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

TOOLS/lua/command-test.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ mp.observe_property("vo-configured", "bool", function(_, v)
107107
-- Runs detached; should be killed on player exit (forces timeout)
108108
mp.command_native({_flags={"async"}, name = "subprocess",
109109
playback_only = false, args = {"sleep", "inf"}})
110+
111+
-- Rapidly dispatching many subprocesses asynchronously must not block the
112+
-- main thread. If it takes multiple seconds we're blocking the main thread.
113+
local rapid_done = 0
114+
local rapid_start = mp.get_time()
115+
for _ = 1, 1000 do
116+
mp.command_native_async({name = "subprocess", args = {"true"}},
117+
function(_, _, _)
118+
rapid_done = rapid_done + 1
119+
if rapid_done == 1000 then
120+
print(string.format("done rapid subprocess dispatch in %.3fms",
121+
(mp.get_time() - rapid_start) * 1000))
122+
end
123+
end)
124+
end
110125
end)
111126

112127
local counter

0 commit comments

Comments
 (0)