-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uv_spawn is slow when parent process allocates mmap with MAP_JIT flag #3050
uv_spawn is slow when parent process allocates mmap with MAP_JIT flag #3050
Comments
Thanks for the repro. I don't run Big Sur so I have no way to test myself but your analysis sounds right.
Switching to At the very least you'll need:
I won't be working on that myself but you or anyone else is welcome to send a pull request. |
The slow speed is unfortunate, but what's worse is that it locks the JavaScript thread (in Electron, freezing the app UI), before nodejs' 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)? |
Thanks for the added context! I will work on the fix this week. |
@deepak1556 Do you think this will be fixed this year? Is there any way we can help? Our Electron app is unusable on Big Sur because it relies heavily on child processes, so we’re trying to determine if we should build workarounds or contribute to the fix. Thanks again for the help! |
@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 |
@deepak1556 thanks! Taking a crack at it today, although don't get your hopes up too high since we're new to this codebase 😅. Will report back by the end of the day. |
@deepak1556 @bnoordhuis we've made some progress here: descriptinc@58cf78e (shoutout to @jpcanepa!) It's incomplete but seems promising so far. Using the repro project https://github.com/deepak1556/libuv-spawn we're seeing Any tips on porting the file descriptor ( |
I want to make sure that eveyrone involved here is aware that that PR (#3064) is in draft because I need help. I can continue trying to bang things into compiling correctly, but I kind of hope that someone (@deepak1556?, @bnoordhuis?) can chip in as well. |
As a bit of expectation management: I have very little time at the moment. |
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 |
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 libuv/libuv#3064, with the addition of API availability annotations to fix a build warning (since Electron compiles with the `-Wunguarded-availability-new` flag). This patch should be removed when libuv PR 3064 is merged. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com> Electron patch prepared by: Pat DeSantis <pdesantis3@gmail.com>
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 libuv/libuv#3064, with the addition of API availability annotations to fix a build warning (since Electron compiles with the `-Wunguarded-availability-new` flag). This patch should be removed when libuv PR 3064 is merged. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com> Electron patch prepared by: Pat DeSantis <pdesantis3@gmail.com>
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 libuv/libuv#3064, with the addition of API availability annotations to fix a build warning (since Electron compiles with the `-Wunguarded-availability-new` flag). This patch should be removed when libuv PR 3064 is merged. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com> Electron patch prepared by: Pat DeSantis <pdesantis3@gmail.com>
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 libuv/libuv#3064, with the addition of API availability annotations to fix a build warning (since Electron compiles with the `-Wunguarded-availability-new` flag). This patch should be removed when libuv PR 3064 is merged. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com> Electron patch prepared by: Pat DeSantis <pdesantis3@gmail.com>
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 libuv/libuv#3064, with the addition of API availability annotations to fix a build warning (since Electron compiles with the `-Wunguarded-availability-new` flag). This patch should be removed when libuv PR 3064 is merged. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com> Electron patch prepared by: Pat DeSantis <pdesantis3@gmail.com>
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 libuv/libuv#3064, with the addition of API availability annotations to fix a build warning (since Electron compiles with the `-Wunguarded-availability-new` flag). This patch should be removed when libuv PR 3064 is merged. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com> Electron patch prepared by: Pat DeSantis <pdesantis3@gmail.com>
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 libuv/libuv#3064, with the addition of API availability annotations to fix a build warning (since Electron compiles with the `-Wunguarded-availability-new` flag). This patch should be removed when libuv PR 3064 is merged. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com> Electron patch prepared by: Pat DeSantis <pdesantis3@gmail.com>
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 libuv/libuv#3064, with the addition of API availability annotations to fix a build warning (since Electron compiles with the `-Wunguarded-availability-new` flag). This patch should be removed when libuv PR 3064 is merged. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com> Electron patch prepared by: Pat DeSantis <pdesantis3@gmail.com>
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 libuv/libuv#3064, with the addition of API availability annotations to fix a build warning (since Electron compiles with the `-Wunguarded-availability-new` flag). This patch should be removed when libuv PR 3064 is merged. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com> Electron patch prepared by: Pat DeSantis <pdesantis3@gmail.com>
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 libuv/libuv#3064, with the addition of API availability annotations to fix a build warning (since Electron compiles with the `-Wunguarded-availability-new` flag). This patch should be removed when libuv PR 3064 is merged. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com> Electron patch prepared by: Pat DeSantis <pdesantis3@gmail.com>
Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a cherry-pick of libuv/libuv#3064. This patch should be removed when Electron's libuv version is updated to a version containing this fix. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a cherry-pick of libuv/libuv#3064. This patch should be removed when Electron's libuv version is updated to a version containing this fix. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
What's the latest on this? |
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 ? |
Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a cherry-pick of libuv/libuv#3064. This patch should be removed when Electron's libuv version is updated to a version containing this fix. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
Will this ever be solved? Any alternative to this program? |
With Big Sur possibly now in maintenance mode - is Kraken working better in Monterey? |
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. |
Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a cherry-pick of libuv/libuv#3064. This patch should be removed when Electron's libuv version is updated to a version containing this fix. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a cherry-pick of libuv/libuv#3064. This patch should be removed when Electron's libuv version is updated to a version containing this fix. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
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. hoping that there will be a fix for this soon. |
@lingster try |
Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a cherry-pick of libuv/libuv#3064. This patch should be removed when Electron's libuv version is updated to a version containing this fix. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a cherry-pick of libuv/libuv#3064. This patch should be removed when Electron's libuv version is updated to a version containing this fix. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a cherry-pick of libuv/libuv#3064. This patch should be removed when Electron's libuv version is updated to a version containing this fix. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a cherry-pick of libuv/libuv#3064. This patch should be removed when Electron's libuv version is updated to a version containing this fix. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
I am using Big Sur and it everything worked perfectly well till previous week, and now it stopped. 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. |
Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a cherry-pick of libuv/libuv#3064. This patch should be removed when Electron's libuv version is updated to a version containing this fix. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a cherry-pick of libuv/libuv#3064. This patch should be removed when Electron's libuv version is updated to a version containing this fix. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
Spawning child processes in an Electron application with a hardened runtime has become slow in macOS Big Sur. This patch is a cherry-pick of libuv/libuv#3064. This patch should be removed when Electron's libuv version is updated to a version containing this fix. Fixes: libuv/libuv#3050 Fixes: electron#26143 PR-URL: libuv/libuv#3064 Authored-by: Juan Pablo Canepa <jpcanepa@gmail.com> Co-authored-by: Marcello Bastéa-Forte <marcello@descript.com>
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 have become slow. This is because fork() seems to physically copy all JIT memory regions (no-copy-on-write). On previous OS, these regions weren't accessible at all in the forked process, explaining the regression. The fix is to use posix_spawn() on macOS. This spawns a new process directly, without copying any memory mappings. Note that fork() is still used on earlier versions of macOS if the necessary posix_spawn() platform-specific extensions are not available. Fixes: libuv#3050 PR-URL: libuv#3064 Reviewed-By: Jameson Nash <vtjnash@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Fixes: libuv#3050 Refs: libuv#3086 Refs: libuv#3064 Refs: libuv#3107 Refs: libuv#3064 This reverts commit 217fdf4, then fixes several issues with it: * remove error fast-cleanup code that triggers a nodejs bug Refs: libuv#3107 (comment) * protect posix_spawn from EINTR This is not a documented valid error, but seems to have been observed. * ignore setuid/setgid syscall This kernel function is not permitted unless the process is setuid root, so disable this syscall. Falling back to fork/exec should be okay for the rare cases that the user decides they need to do setuid(getuid()) or setuid(geteuid()) for the child. Refs: libuv#3107 (comment) * improve posix_spawn path search Ports the improvements in musl back to this function * fix some additional problems and formatting issues We previously might fail to start a watcher, in rare failure cases, resulting in a zombie that we would fail to kill. Also avoid creating the signal-pipe unless required (addresses a review comment from Apple) * fix fd->fd mapping reuse There was a chance that when duplicating the fd's into stdio_count+fd we might be closing a currently opened fd with that value.
Repro Steps : https://github.com/deepak1556/libuv-spawn
The issue is derived from electron/electron#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.
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 ?
The text was updated successfully, but these errors were encountered: