| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a98addb commit 747fbb4
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,6 +82,17 @@ declare_args() { | |||
| 82 | 82 | # Sets -dENABLE_HUGEPAGE | |
| 83 | 83 | v8_enable_hugepage = false | |
| 84 | 84 | ||
| 85 | + # Sets -dV8_ENABLE_PRIVATE_MAPPING_FORK_OPTIMIZATION. | ||
| 86 | + # | ||
| 87 | + # This flag speeds up the performance of fork/execve on Linux systems for | ||
| 88 | + # embedders which use it (like Node.js). It works by marking the pages that | ||
| 89 | + # V8 allocates as MADV_DONTFORK. Without MADV_DONTFORK, the Linux kernel | ||
| 90 | + # spends a long time manipulating page mappings on fork and exec which the | ||
| 91 | + # child process doesn't generally need to access. | ||
| 92 | + # | ||
| 93 | + # See v8:7381 for more details. | ||
| 94 | + v8_enable_private_mapping_fork_optimization = false | ||
| 95 | + | ||
| 85 | 96 | # Sets -dENABLE_HANDLE_ZAPPING. | |
| 86 | 97 | v8_enable_handle_zapping = !is_on_release_branch || is_debug | |
| 87 | 98 | ||
@@ -862,6 +873,9 @@ config("features") { | |||
| 862 | 873 | if (v8_enable_hugepage) { | |
| 863 | 874 | defines += [ "ENABLE_HUGEPAGE" ] | |
| 864 | 875 | } | |
| 876 | + if (v8_enable_private_mapping_fork_optimization) { | ||
| 877 | + defines += [ "V8_ENABLE_PRIVATE_MAPPING_FORK_OPTIMIZATION" ] | ||
| 878 | + } | ||
| 865 | 879 | if (v8_enable_object_print) { | |
| 866 | 880 | defines += [ "OBJECT_PRINT" ] | |
| 867 | 881 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -174,6 +174,12 @@ void* Allocate(void* hint, size_t size, OS::MemoryPermission access, | |||
| 174 | 174 | int flags = GetFlagsForMemoryPermission(access, page_type); | |
| 175 | 175 | void* result = mmap(hint, size, prot, flags, kMmapFd, kMmapFdOffset); | |
| 176 | 176 | if (result == MAP_FAILED) return nullptr; | |
| 177 | + | ||
| 178 | + #if V8_ENABLE_PRIVATE_MAPPING_FORK_OPTIMIZATION | ||
| 179 | + // This is advisory, so we ignore errors. | ||
| 180 | + madvise(result, size, MADV_DONTFORK); | ||
| 181 | + #endif | ||
| 182 | + | ||
| 177 | 183 | #if ENABLE_HUGEPAGE | |
| 178 | 184 | if (result != nullptr && size >= kHugePageSize) { | |
| 179 | 185 | const uintptr_t huge_start = | |
| Back | FazBrowse Home | New Git URL |
0 commit comments