Skip to content
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

chore: enable v8_enable_private_mapping_fork_optimization by default #39253

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions build/args/all.gn
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@ v8_builtins_profiling_log_file = ""
# https://chromium.googlesource.com/chromium/src/+/main/docs/dangling_ptr.md
# TODO(vertedinde): hunt down dangling pointers on Linux
enable_dangling_raw_ptr_checks = false

# This flag speeds up the performance of fork/execve on linux systems.
# Ref: https://chromium-review.googlesource.com/c/v8/v8/+/4602858
v8_enable_private_mapping_fork_optimization = true
1 change: 1 addition & 0 deletions patches/v8/.patches
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build_gn.patch
do_not_export_private_v8_symbols_on_windows.patch
fix_build_deprecated_attribute_for_older_msvc_versions.patch
chore_allow_customizing_microtask_policy_per_context.patch
fix_compile_error_on_macos_with_fork_optimization.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Tue, 15 Aug 2023 23:59:59 +0900
Subject: fix: compile error on macOS with
v8_enable_private_mapping_fork_optimization=true

Follow-up to https://chromium-review.googlesource.com/c/v8/v8/+/4602858,
we are trying to enable this flag in Electron without any OS conditions in
args.gn which results in a compilation failure on macOS due to the lack of MADV_DONTFORK.

Given that Node.js and Electron both use posix_spawn on macOS which
by default does not copy MAP_JIT locations, it would be safe to isolate
the change only for linux.

Change-Id: I58ad50e557016fa573d7a27f33a60e2e5b7d1804
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4780212
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Auto-Submit: Deepak Mohan (Robo) <hop2deep@gmail.com>
Cr-Commit-Position: refs/heads/main@{#89557}

diff --git a/src/base/platform/platform-posix.cc b/src/base/platform/platform-posix.cc
index 77fd9e8f6dd5938d38344ffb0074fb70a0969fd9..73cdbdb19df2aecf3046b2bb2b6cb121f4dc5ca7 100644
--- a/src/base/platform/platform-posix.cc
+++ b/src/base/platform/platform-posix.cc
@@ -161,7 +161,7 @@ void* Allocate(void* hint, size_t size, OS::MemoryPermission access,
void* result = mmap(hint, size, prot, flags, kMmapFd, kMmapFdOffset);
if (result == MAP_FAILED) return nullptr;

-#if V8_ENABLE_PRIVATE_MAPPING_FORK_OPTIMIZATION
+#if V8_OS_LINUX && V8_ENABLE_PRIVATE_MAPPING_FORK_OPTIMIZATION
// This is advisory, so we ignore errors.
madvise(result, size, MADV_DONTFORK);
#endif