commit | ce4f4c89e4def37d447ad3adaafd777140dddf0d | [log] [tgz] |
---|---|---|
author | Darshan Sen <raisinten@gmail.com> | Thu Jun 16 12:09:22 2022 +0530 |
committer | Copybara-Service <copybara-worker@google.com> | Thu Jun 16 06:43:17 2022 -0700 |
tree | bc7b7ac220670d9fe272b16d682db4951cffec37 | |
parent | 31015832890b3bf249a503108135fe2c885fe183 [diff] |
posix: Replace DoubleForkAndExec() with ForkAndSpawn() The DoubleForkAndExec() function was taking over 622 milliseconds to run on macOS 11 (BigSur) on Intel i5-1038NG7. I did some debugging by adding some custom traces and found that the fork() syscall is the bottleneck here, i.e., the first fork() takes around 359 milliseconds and the nested fork() takes around 263 milliseconds. Replacing the nested fork() and exec() with posix_spawn() reduces the time consumption to 257 milliseconds! See https://github.com/libuv/libuv/pull/3064 to know why fork() is so slow on macOS and why posix_spawn() is a better replacement. Another point to note is that even base::LaunchProcess() from Chromium calls posix_spawnp() on macOS - https://source.chromium.org/chromium/chromium/src/+/8f8d82dea0fa8f11f57c74dbb65126f8daba58f7:base/process/launch_mac.cc;l=295-296 Change-Id: Ided12761884716fcf06119bc036eb4f985e8d53a Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3641386 Reviewed-by: Mark Mentovai <mark@chromium.org> Commit-Queue: Mark Mentovai <mark@chromium.org> GitOrigin-RevId: 460943dd9a71dc76f68182a8ede766d5543e5341
Crashpad is a crash-reporting system.
Crashpad’s source code is hosted in a Git repository at https://chromium.googlesource.com/crashpad/crashpad.