build: delay-load rarely used system DLLs on Windows

node.exe imports crypt32, dbghelp, iphlpapi, ole32, shell32, userenv
and winmm, so every process loads them, and the DLLs they depend on,
at start-up. They are only needed by less common code paths such as
the system certificate store, network interface queries and
diagnostic reports.

Delay-load them so they are loaded on first use. On Windows 11 this
takes `node -e 0` from 35 to 26 loaded images and saves about 2.5 ms
per process.

Signed-off-by: Alexandre Zollinger Chohfi <alzollin@microsoft.com>
PR-URL: https://github.com/nodejs/node/pull/67098
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
This commit is contained in:
Alexandre Zollinger Chohfi authored and GitHub committed 2026-11-28 18:18:32 +00:00
1 parent 8b26c7d3d7
commit 7dc685b002
1 file changed
+18
+18
View File
@@ -723,6 +723,24 @@
}],
[ 'OS=="win"', {
'sources': [ 'src/res/node.rc' ],
# These system DLLs are only needed by less common code paths
# (system certificate store, network interface queries,
# diagnostic reports and so on). Loading them on first use
# instead of at process start-up saves about 2.5 ms per process.
'libraries': [ 'delayimp.lib' ],
'msvs_settings': {
'VCLinkerTool': {
'DelayLoadDLLs': [
'crypt32.dll',
'dbghelp.dll',
'iphlpapi.dll',
'ole32.dll',
'shell32.dll',
'userenv.dll',
'winmm.dll',
],
},
},
}],
],
}],