libuv: uv_spawn is slow when parent process allocates mmap with MAP_JIT flag
- Version: tip-of-tree (1.x)
- Platform: macOS Big Sur (11.0.1)
Repro Steps : https://github.com/deepak1556/libuv-spawn
The issue is derived from https://github.com/electron/electron/issues/26143
Applications running on hardened runtime based on chromium/electron create mmap regions using MAP_JIT flag. With Big Sur the fork() calls done by uv_spawn have become slow. Theory is that before big sur fork() didn’t have access to the JIT memory regions but they do now.
// Using the repro linked above
$ sudo dtruss -e ./out/Default/uv_spawn --use-jit
45600 fork() = 7815 0
42260 fork() = 7816 0
$ sudo dtruss -e ./out/Default/uv_spawn
558 fork() = 7801 0
391 fork() = 7800 0
Chromium’s own child process spawning code doesn’t suffer from this new behaviour because it uses posix_spawn.
Is it in the interest of libuv project to make the change to use posix_spawn atleast for macOS >= 11.0 ?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 98
- Comments: 28 (7 by maintainers)
Links to this issue
Commits related to this issue
- darwin,libuv: use posix_spawn Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a squashed version of https://github.com/lib... — committed to descriptinc/electron by pdesantis 4 years ago
- darwin,libuv: use posix_spawn Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a squashed version of https://github.com/lib... — committed to descriptinc/electron by pdesantis 4 years ago
- darwin,libuv: use posix_spawn Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a squashed version of https://github.com/lib... — committed to descriptinc/electron by pdesantis 4 years ago
- darwin,libuv: use posix_spawn Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a squashed version of https://github.com/lib... — committed to descriptinc/electron by pdesantis 4 years ago
- fix: patch libuv to use posix_spawn on macOS Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a squashed version of https:/... — committed to descriptinc/electron by pdesantis 4 years ago
- darwin,libuv: use posix_spawn Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a squashed version of https://github.com/lib... — committed to descriptinc/electron by pdesantis 4 years ago
- darwin,libuv: use posix_spawn Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a squashed version of https://github.com/lib... — committed to descriptinc/electron by pdesantis 3 years ago
- darwin,libuv: use posix_spawn Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a squashed version of https://github.com/lib... — committed to descriptinc/electron by pdesantis 3 years ago
- darwin,libuv: use posix_spawn Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a squashed version of https://github.com/lib... — committed to descriptinc/electron by pdesantis 3 years ago
- darwin,libuv: use posix_spawn Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a squashed version of https://github.com/lib... — committed to descriptinc/electron by pdesantis 3 years ago
- darwin,libuv: use posix_spawn Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a squashed version of https://github.com/lib... — committed to descriptinc/electron by pdesantis 3 years ago
- darwin,libuv: use posix_spawn Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a squashed version of https://github.com/lib... — committed to descriptinc/electron by pdesantis 3 years ago
- perf: patch libuv to use posix_spawn on macOS patch libuv to fix a performance regression in macOS >= 11 Spawning child processes in an Electron application with a hardened runtime has become slow i... — committed to descriptinc/electron by pdesantis 3 years ago
- darwin,libuv: use posix_spawn Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a squashed version of https://github.com/lib... — committed to descriptinc/electron by pdesantis 3 years ago
- macos: use posix_spawn instead of fork Applications running on hardened runtime based on Chromium/Electron create mmap regions using MAP_JIT flag. With macOS Big Sur the fork() calls done by uv_spawn... — committed to descriptinc/libuv by jpcanepa 4 years ago
- perf: patch libuv to use posix_spawn on macOS (#27026) * perf: patch libuv to use posix_spawn on macOS patch libuv to fix a performance regression in macOS >= 11 Spawning child processes in an ... — committed to electron/electron by pdesantis 3 years ago
- perf: patch libuv to use posix_spawn on macOS patch libuv to fix a performance regression in macOS >= 11 Spawning child processes in an Electron application with a hardened runtime has become slow i... — committed to electron/electron by pdesantis 3 years ago
- perf: patch libuv to use posix_spawn on macOS patch libuv to fix a performance regression in macOS >= 11 Spawning child processes in an Electron application with a hardened runtime has become slow i... — committed to electron/electron by pdesantis 3 years ago
- perf: patch libuv to use posix_spawn on macOS patch libuv to fix a performance regression in macOS >= 11 Spawning child processes in an Electron application with a hardened runtime has become slow i... — committed to electron/electron by pdesantis 3 years ago
- perf: patch libuv to use posix_spawn on macOS (#27656) * perf: patch libuv to use posix_spawn on macOS patch libuv to fix a performance regression in macOS >= 11 Spawning child processes in an ... — committed to electron/electron by trop[bot] 3 years ago
Any progress here?
I add to apply the fix for the latest build of gitkraken so i guess it’s still ongoing or gitkraken has not included the fix released if it’s exists.
What i don’t get is that some apps suffered the same issue after Bug Sur was out (from memory i can only name VScode but they was more than 2 apps) and they managed to get a fix out quite quickly. Is there something special about this lib or it’s just on Gitkraken side ?
Thanks for the added context! I will work on the fix this week.
Looking forward to seeing this fixed so GitKraken will run again without it being slowed down (issue)!
Reopening because https://github.com/libuv/libuv/pull/3064 was reverted.
FWIW, the PR #3064 seems to be done, just needs some attention for a final review, to get it merged.
Will this ever be solved? Any alternative to this program?
@darkguy2008 it was merged, but then reverted in https://github.com/libuv/libuv/pull/3107.
With Big Sur possibly now in maintenance mode - is Kraken working better in Monterey? Removing code-signing isn’t a way forward in my book.
I am using Big Sur and it everything worked perfectly well till previous week, and now it stopped.
codesign ...doesn’t seems to resolve the issue.Is there any solution to this? Did this somehow reoccur? I like gitkraken, but will be force to stop paying yearly subscription, since it is not useable for me at the moment.
Thank you for any help.
If anyone wants a quick overview on this whole situation; this issue summarises it nicely.
Right now, the fix is at #3257 but Apple needs to diagnose a kernel bug before that can be merged.
The slow speed is unfortunate, but what’s worse is that it locks the JavaScript thread (in Electron, freezing the app UI), before nodejs’
spawn()call even returns.I’m not familiar with what part of that is node vs libuv, but is it possible for this slow part to happen asynchronously (since the rest of the spawn api is async)?
As a bit of expectation management: I have very little time at the moment.
@pdesantis the issue is on our projects’ December iteration task but can’t promise a date and I haven’t started on it. I also was not aware if anyone else wanted to work on it. So, feel free to contribute!
All the relevant api swaps that @bnoordhuis pointed are to be made in
src/unix/process.c, specifically under fnuv__process_child_initanduv_spawn@lingster try
sudo ...I’ve just tried using GitKraken’s new cli-terminal using Monterey and GitKraken grinds to a halt as the renderer consumes vast amounts of cpu time. Running the workaround:
codesign --remove-signature /Applications/GitKraken.app/Contents/Frameworks/GitKraken\ Helper\ \(Renderer\).appreturns the following error:/Applications/GitKraken.app/Contents/Frameworks/GitKraken Helper (Renderer).app: internal error in Code Signing subsystemhoping that there will be a fix for this soon.
I’ve updated the PR so that now it builds correctly with CMake and Autotools, and there are only two open questions: a failing unit test case due to a behavior difference from the fork/execvp flow and a question about one of the
posix_spawn_*_npfunction calls.