Skip to content

Commit a23d070

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 a23d070

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

TOOLS/lua/command-test.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ 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_start = mp.get_time()
114+
for i = 1, 1000 do
115+
mp.command_native_async({name = "subprocess", args = {"true"}},
116+
function() end)
117+
end
118+
print(string.format("done rapid subprocess dispatch in %.3fms",
119+
(mp.get_time() - rapid_start) * 1000))
110120
end)
111121

112122
local counter

0 commit comments

Comments
 (0)