Node: build: make build faster (at least on Windows)

Created on 8 Apr 2017  路  22Comments  路  Source: nodejs/node

  • Version: *
  • Platform: Windows
  • Subsystem: build

__The problem__: even for minor changes building on Windows can take 10s of minutes.
This issue is for tracking several approaches to mitigate that.

  • [x] make GYP less aggressive in recreating .proj files
  • [x] better signaling to VS of the minimal change set
  • [x] use compiler cache
  • [x] make using ninja simpler
  • [x] allow for debug build to use /lib/ files as is (skip mksnapshot)
  • [ ] shortcut the ICU toolchain
  • [ ] allow decoupling of /deps/ from main executable compilation & linking
  • [ ] easy way to cloud-source parts of the compilation
build windows

Most helpful comment

Same scenario, just changing a .js file, but build with ninja

c:\code\node\out.ninja\out\Debug$ time < nul &echo.""&ninja -j 3 -v -f build.ninja node&time < nul
The current time is: 18:50:11.05
Enter the new time: ""
[1/5] C:\bin\dev\python27\python.exe gyp-win-tool action-wrapper environment.x64 node_js2c_target_node_js2c_bce0facc3e66b523ccf35ab2d859c2d9..rsp ..\..\..\
[2/5] C:\bin\dev\python27\python.exe gyp-win-tool stamp obj\node.actions_depends.stamp
[3/5] C:\bin\dev\python27\python.exe gyp-win-tool stamp obj\node.compile_depends.stamp
[4/5] ninja -t msvc -e environment.x64 -- "D:\bin\dev\VS\2017\BuildTools\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\cl.exe" /nologo /showIncludes /FC @obj\gen\node.node_javascript.obj.rsp /c gen\node_javascript.cc /Foobj\gen\node.node_javascript.obj /Fdobj\node.cc.pdb
[5/5] C:\bin\dev\python27\python.exe gyp-win-tool link-with-manifests environment.x64 True node.exe "C:\bin\dev\python27\python.exe gyp-win-tool link-wrapper environment.x64 False link.exe /nologo /OUT:node.exe @node.exe.rsp" 1 mt.exe rc.exe "obj\node.node.exe.intermediate.manifest" obj\node.node.exe.generated.manifest ..\..\..\src\res\node.exe.extra.manifest
The current time is: 18:51:07.85
Enter the new time:

56 seconds. I'm in love with ninja

All 22 comments

/cc @nodejs/build @nodejs/platform-windows

vcbuild.bat could definitely do with some love, thanks for picking this up @refack!

馃檹may the powers that be protect us from the evil that is cmd scripting

vcbuild.bat could definitely do with some love

Was thinking of rewriting it PowerShell

Was thinking of rewriting it PowerShell

Hmm, not sure what the rest of @nodejs/build and @nodejs/platform-windows would think of that, but it sounds like it might be a good idea to me. Fundamentally I think people would be more willing to learn and contribute to a Powershell build script than a batch one, and the tangled mess of gotos in vcbuild.bat doesn't seem particularly contributor-friendly.

Or maybe we should write it in js...

Actually could be js more specifically JScript. Windows does have a built in JScript runner

Timing example, after applying #12511 (a change in /lib/path.js)

C:\code\node>time < nul&vcbuild > nul&time < nul
The current time is: 14:07:53.76
Enter the new time: The current time is: 14:23:41.10
Enter the new time:

~16 minutes

Is that faster or slower than the before time?

Just an example of a recompile after just changing a .js file :(

Mean while on "Ubuntu on Windows"

refael@refaelux:/mnt/d/code/node$ time BUILDTYPE=Debug make -C out -j3
make: Entering directory '/mnt/d/code/node/out'
  ACTION Regenerating Makefile
-fmake --ignore-environment --toplevel-dir=. -I/mnt/d/code/node/common.gypi -I/mnt/d/code/node/config.gypi --depth=. -Goutput_dir=/mnt/d/code/node/out --generator-output=/mnt/d/code/node/out -Dcomponent=static_library -Dlibrary=static_library -Dlinux_use_bundled_binutils=0 -Dlinux_use_bundled_gold=0 -Dlinux_use_gold_flags=0 node.gyp /mnt/d/code/node/node.gyp -I /mnt/d/code/node/common.gypi -I /mnt/d/code/node/config.gypi --depth=. --generator-output /mnt/d/code/node/out -Goutput_dir=/mnt/d/code/node/out -Dcomponent=static_library -Dlibrary=static_library -Dlinux_use_bundled_binutils=0 -Dlinux_use_bundled_gold=0 -Dlinux_use_gold_flags=0
  ACTION _mnt_d_code_node_node_gyp_node_js2c_host_node_js2c /mnt/d/code/node/out/Debug/obj/gen/node_javascript.cc
  TOUCH 77ac9600461e1dfdf3594f5e11b3cd135d0cbfd6.intermediate
  ACTION Generating inspector protocol sources from protocol json 77ac9600461e1dfdf3594f5e11b3cd135d0cbfd6.intermediate
  CXX(target) /mnt/d/code/node/out/Debug/obj.target/node/gen/node_javascript.o
  LINK(target) /mnt/d/code/node/out/Debug/node
rm 77ac9600461e1dfdf3594f5e11b3cd135d0cbfd6.intermediate
make: Leaving directory '/mnt/d/code/node/out'

real    1m25.091s
user    0m45.625s
sys     0m33.406s

[linux envy]

Not that much faster for me on Linux. C++ linking of Debug symbols is brutal. I worked with a program that had a 45 minute non-debug linktime once. Debug couldn't be linked, not enough memory on our machines.

Same scenario, just changing a .js file, but build with ninja

c:\code\node\out.ninja\out\Debug$ time < nul &echo.""&ninja -j 3 -v -f build.ninja node&time < nul
The current time is: 18:50:11.05
Enter the new time: ""
[1/5] C:\bin\dev\python27\python.exe gyp-win-tool action-wrapper environment.x64 node_js2c_target_node_js2c_bce0facc3e66b523ccf35ab2d859c2d9..rsp ..\..\..\
[2/5] C:\bin\dev\python27\python.exe gyp-win-tool stamp obj\node.actions_depends.stamp
[3/5] C:\bin\dev\python27\python.exe gyp-win-tool stamp obj\node.compile_depends.stamp
[4/5] ninja -t msvc -e environment.x64 -- "D:\bin\dev\VS\2017\BuildTools\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\cl.exe" /nologo /showIncludes /FC @obj\gen\node.node_javascript.obj.rsp /c gen\node_javascript.cc /Foobj\gen\node.node_javascript.obj /Fdobj\node.cc.pdb
[5/5] C:\bin\dev\python27\python.exe gyp-win-tool link-with-manifests environment.x64 True node.exe "C:\bin\dev\python27\python.exe gyp-win-tool link-wrapper environment.x64 False link.exe /nologo /OUT:node.exe @node.exe.rsp" 1 mt.exe rc.exe "obj\node.node.exe.intermediate.manifest" obj\node.node.exe.generated.manifest ..\..\..\src\res\node.exe.extra.manifest
The current time is: 18:51:07.85
Enter the new time:

56 seconds. I'm in love with ninja

@refack ninja and ccache are the two things that really help with build times. I don't think ccache is available on Windows though, we use it on all our Unix test infra.

Not that much faster for me on Linux. C++ linking of Debug symbols is brutal.

@rsam I think the 16 minutes was for release mode on windows looking at the command: C:\code\node>time < nul&vcbuild > nul&time < nul

@rsam I think the 16 minutes was for release mode on windows looking at the command: C:\codenode>time < nul&vcbuild > nul&time < nul

On a fully pre-built tree, after changing one .js file 馃う

Ah, I though out.ninja\out\Debug meant it was debug. That is pretty awful, I'm sure Windows devs will thank you if you can improve it.

ccache

This is something I wanted to build myself (maybe into ninja or GYP), hash the input files and tools versions, and do a lookup into some repository (node-pre-gyp style)

Should this remain open? If so, does it make sense to make it a tracking issue with some check boxes so it's obvious at a glance what parts are done and what parts aren't?

Don't triagathon me 馃懠
Yes, I'll break break this up. I have several better defined sub-tasks in mind.

/cc @nodejs/platform-windows now that we've grown in numbers, and at @Trott's behest, I've broken this issue down to several more tractable tasks. I'd be happy if we all pitched in (I've given most of the tasks some thought, but not enough work, so I'd be happy to discuss each of them).

I would prefer Powershell over JScript.

I would prefer Powershell over JScript.

Yep, that's https://github.com/nodejs/node/issues/12310 (I'm 80% there, just 80% more left) - https://gist.github.com/refack/969ecc6642981bfd7caef7d948d78076

There's been no further discussion in years with no clear action here. Closing.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielstaleiny picture danielstaleiny  路  3Comments

seishun picture seishun  路  3Comments

sandeepks1 picture sandeepks1  路  3Comments

stevenvachon picture stevenvachon  路  3Comments

willnwhite picture willnwhite  路  3Comments