forked from mirrors/gecko-dev
Bug 1900847 - Use posix_spawnp instead of fork/execvp for JS shell tests. r=mgaudet
`fork` can be slow, especially for jstests. This reduces our jstests time from ~140 seconds to ~100 seconds on my machine. `os.posix_spawnp` is available since Python 3.8 and conveniently that's also the minimum Python version we currently require. Differential Revision: https://phabricator.services.mozilla.com/D212777
This commit is contained in:
parent
8d1c9d2b83
commit
d3824dae47
1 changed files with 15 additions and 17 deletions
|
|
@ -35,26 +35,24 @@ def spawn_test(test, prefix, tempdir, passthrough, run_skipped, show_cmd):
|
|||
if show_cmd:
|
||||
print(escape_cmdline(cmd))
|
||||
|
||||
if not passthrough:
|
||||
if passthrough:
|
||||
os.execvp(cmd[0], cmd)
|
||||
return
|
||||
|
||||
(rout, wout) = os.pipe()
|
||||
(rerr, werr) = os.pipe()
|
||||
|
||||
rv = os.fork()
|
||||
file_actions = [
|
||||
(os.POSIX_SPAWN_CLOSE, rout),
|
||||
(os.POSIX_SPAWN_CLOSE, rerr),
|
||||
(os.POSIX_SPAWN_DUP2, wout, 1),
|
||||
(os.POSIX_SPAWN_DUP2, werr, 2),
|
||||
]
|
||||
pid = os.posix_spawnp(cmd[0], cmd, os.environ, file_actions=file_actions)
|
||||
|
||||
# Parent.
|
||||
if rv:
|
||||
os.close(wout)
|
||||
os.close(werr)
|
||||
return Task(test, prefix, tempdir, rv, rout, rerr)
|
||||
|
||||
# Child.
|
||||
os.close(rout)
|
||||
os.close(rerr)
|
||||
|
||||
os.dup2(wout, 1)
|
||||
os.dup2(werr, 2)
|
||||
|
||||
os.execvp(cmd[0], cmd)
|
||||
return Task(test, prefix, tempdir, pid, rout, rerr)
|
||||
|
||||
|
||||
def get_max_wait(tasks, timeout):
|
||||
|
|
|
|||
Loading…
Reference in a new issue