Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4f4d0b8

Browse filesBrowse files
kvakilRafaelGSS
authored andcommitted
child_process: improve spawn performance on Linux
Speed up child_process.spawn by enabling the new V8 build flag which makes fork/exec faster. Here are the results of running the existing benchmark. Note that this optimization helps more for applications with larger heaps, so this is somewhat of an underestimate of the real world performance benefits. ```console $ ./node benchmark/compare.js --runs 15 \ --new ./node \ --old ~/node-v20/out/Release/node \ --filter params child_process > cpr $ node-benchmark-compare cpr confidence improvement (***) methodName='exec' n=1000 *** 60.84 % ±5.43% methodName='execFile' n=1000 *** 53.72 % ±3.33% methodName='execFileSync' n=1000 *** 9.10 % ±0.84% methodName='execSync' n=1000 *** 10.44 % ±0.97% methodName='spawn' n=1000 *** 53.10 % ±2.90% methodName='spawnSync' n=1000 *** 8.64 % ±1.22% 0.01 false positives, when considering a 0.1% risk acceptance (***) ``` Fixes: #25382 Fixes: #14917 Refs: nodejs/performance#93 Refs: nodejs/performance#89 PR-URL: #48523 Refs: v8/v8@1a782f6 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
1 parent d91b0fd commit 4f4d0b8
Copy full SHA for 4f4d0b8

File tree

Expand file treeCollapse file tree

1 file changed

+18
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+18
-1
lines changed
Open diff view settings
Collapse file

‎tools/v8_gypfiles/features.gypi‎

Copy file name to clipboardExpand all lines: tools/v8_gypfiles/features.gypi
+18-1Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,21 @@
7272
'v8_enable_etw_stack_walking': 1,
7373
}, {
7474
'v8_enable_etw_stack_walking': 0,
75-
}]
75+
}],
76+
['OS=="linux"', {
77+
# Sets -dV8_ENABLE_PRIVATE_MAPPING_FORK_OPTIMIZATION.
78+
#
79+
# This flag speeds up the performance of fork/execve on Linux systems for
80+
# embedders which use it (like Node.js). It works by marking the pages that
81+
# V8 allocates as MADV_DONTFORK. Without MADV_DONTFORK, the Linux kernel
82+
# spends a long time manipulating page mappings on fork and exec which the
83+
# child process doesn't generally need to access.
84+
#
85+
# See v8:7381 for more details.
86+
'v8_enable_private_mapping_fork_optimization': 1,
87+
}, {
88+
'v8_enable_private_mapping_fork_optimization': 0,
89+
}],
7690
],
7791
'is_debug%': 0,
7892

@@ -320,6 +334,9 @@
320334
['v8_enable_hugepage==1', {
321335
'defines': ['ENABLE_HUGEPAGE',],
322336
}],
337+
['v8_enable_private_mapping_fork_optimization==1', {
338+
'defines': ['V8_ENABLE_PRIVATE_MAPPING_FORK_OPTIMIZATION'],
339+
}],
323340
['v8_enable_vtunejit==1', {
324341
'defines': ['ENABLE_VTUNE_JIT_INTERFACE',],
325342
}],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.