You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How can I improve the build speed of node js? #35888
I was playing with the code source of node however I find the build speed really slow(1h30m). Is there any way I can improove the build speed of node js?
My compiler is msvc
Sorry, but you will just need a beefier PC to build Node faster. A good multi-core CPU and an NVME drive will do wonders. The first, clean build is exceptionally hard, subsequent ones should be faster though.
That said, there is indeed a regression in Node build files introduced in #32698. You can try building this commit (one before the change): b79829c. Depending on your configuration, it should be slightly faster.
In the long term, we will probably switch to a better build system, see nodejs/TSC#901. Unfortunately, building Node.js with its dependencies is super slow, especially on Windows. As @bzoz wrote, only the first build should take hours, and subsequent incremental builds should complete within minutes.
Yeah, vcbuild.bat does not use -j, it should use the max amount of cores by default. There is this regression, where for some targets it would not do that, I've made #35932 to fix it.
That said, @ViniDalvino you will still need a better PC. I have a hunch that even with this change it will take ~1h to build Node on your box - you can test that by checking out my PR code and running vcbuild.
That said, @ViniDalvino you will still need a better PC. I have a hunch that even with this change it will take ~1h to build Node on your box - you can test that by checking out my PR code and running vcbuild.
That should only be true for a complete rebuild, and incremental builds should be much faster. If incremental builds take ~1h on any modern hardware, that's on us or on the build tools.
@ViniDalvino I have developed on terribly slow machines in the past, and based on my own experience, I would suggest considering using Linux for Node.js development. I developed Node.js on Windows for a long time, but it cannot really compete with development on Linux for me. I should probably just buy a better computer as suggested above, but things are much smoother on Linux than on Windows.
Would node need to be built through the solution in visual studio in order to be quick? What I mean is that if you compile node through visual studio you can select what you compile; As example don't have to compile v8 everytime.
You can try and use the Windows task manager to check CPU and memory utilization. CPU utilization should be close to 100% during compilation if everything is working correctly.
Activity
bzoz commentedon Nov 2, 2020
Hi, thanks for the report.
Sorry, but you will just need a beefier PC to build Node faster. A good multi-core CPU and an NVME drive will do wonders. The first, clean build is exceptionally hard, subsequent ones should be faster though.
That said, there is indeed a regression in Node build files introduced in #32698. You can try building this commit (one before the change): b79829c. Depending on your configuration, it should be slightly faster.
bzoz commentedon Nov 2, 2020
Opened an issue with this regression: #35921, @ViniDalvino thanks for bringing this up to our attention!
tniessen commentedon Nov 4, 2020
In the long term, we will probably switch to a better build system, see nodejs/TSC#901. Unfortunately, building Node.js with its dependencies is super slow, especially on Windows. As @bzoz wrote, only the first build should take hours, and subsequent incremental builds should complete within minutes.
TheEpicFace007 commentedon Nov 4, 2020
Does the issue might be due to me building node exclusively with the build script(vcbuild.bat)? @tniessen @bzoz
devsnek commentedon Nov 4, 2020
@ViniDalvino out of curiosity are you using the
-jflag when you build? for example if your cpu has 8 logical cores, you can domake -j8.TheEpicFace007 commentedon Nov 5, 2020
@devsnek it's not a valid command line option. I think msvc multithread the build automatically anyway
bzoz commentedon Nov 5, 2020
Yeah,
vcbuild.batdoes not use-j, it should use the max amount of cores by default. There is this regression, where for some targets it would not do that, I've made #35932 to fix it.That said, @ViniDalvino you will still need a better PC. I have a hunch that even with this change it will take ~1h to build Node on your box - you can test that by checking out my PR code and running
vcbuild.tniessen commentedon Nov 5, 2020
That should only be true for a complete rebuild, and incremental builds should be much faster. If incremental builds take ~1h on any modern hardware, that's on us or on the build tools.
@ViniDalvino I have developed on terribly slow machines in the past, and based on my own experience, I would suggest considering using Linux for Node.js development. I developed Node.js on Windows for a long time, but it cannot really compete with development on Linux for me. I should probably just buy a better computer as suggested above, but things are much smoother on Linux than on Windows.
TheEpicFace007 commentedon Nov 5, 2020
Would node need to be built through the solution in visual studio in order to be quick? What I mean is that if you compile node through visual studio you can select what you compile; As example don't have to compile v8 everytime.
tniessen commentedon Nov 5, 2020
You can try and use the Windows task manager to check CPU and memory utilization. CPU utilization should be close to 100% during compilation if everything is working correctly.
TheEpicFace007 commentedon Nov 5, 2020
@tniessen The CPU usage seem fine.


gengjiawen commentedon Nov 12, 2020
Any chance we can bring ninja on windows ? cc @nodejs/gyp
The increment build on windows still unbearable.
TheEpicFace007 commentedon Jan 8, 2022
I don't have any but thanks for suggesting ccache for improving build speed @scardracs +1
aleclarson commentedon Jan 25, 2022
Is there a way to avoid compiling the
lib/*modules into the binary, so I can tweak/debug the JS internals without a slow feedback loop?mmarchini commentedon Jan 25, 2022
@aleclarson Yes, there is a build flag that can be used for that (as per BUILDING.md):
$ ./configure --node-builtin-modules-path $(pwd)StefanStojanovic commentedon Jul 25, 2024
This issue had no activity in the last two and a half years, so I'll close it. Feel free to reopen it, or open a new issue if needed.