V8 代码缓存支持
¥V8 code cache support
当配置中将 useCodeCache
设置为 true
时,在生成单个可执行准备 blob 期间,Node.js 将编译 main
脚本以生成 V8 代码缓存。生成的代码缓存将成为准备 blob 的一部分,并注入到最终的可执行文件中。当单个可执行应用启动时,Node.js 不会从头开始编译 main
脚本,而是使用代码缓存来加速编译,然后执行脚本,这将提高启动性能。
¥When useCodeCache
is set to true
in the configuration, during the generation
of the single executable preparation blob, Node.js will compile the main
script to generate the V8 code cache. The generated code cache would be part of
the preparation blob and get injected into the final executable. When the single
executable application is launched, instead of compiling the main
script from
scratch, Node.js would use the code cache to speed up the compilation, then
execute the script, which would improve the startup performance.
注意:当 useCodeCache
为 true
时,import()
不起作用。
¥Note: import()
does not work when useCodeCache
is true
.