Skip to content

How can I improve the build speed of node js? #35888

Description

@TheEpicFace007

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

Activity

  1. added
    buildIssues and PRs related to Node.js builds or CI infrastructure.
    windowsIssues and PRs related to the Windows platform.
    on Oct 30, 2020
  2. bzoz commented on Nov 2, 2020

    @bzoz
    Contributor

    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.

  3. bzoz commented on Nov 2, 2020

    @bzoz
    Contributor

    Opened an issue with this regression: #35921, @ViniDalvino thanks for bringing this up to our attention!

  4. tniessen commented on Nov 4, 2020

    @tniessen
    Member

    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.

  5. TheEpicFace007 commented on Nov 4, 2020

    @TheEpicFace007
    Author

    Does the issue might be due to me building node exclusively with the build script(vcbuild.bat)? @tniessen @bzoz

  6. devsnek commented on Nov 4, 2020

    @devsnek
    Member

    @ViniDalvino out of curiosity are you using the -j flag when you build? for example if your cpu has 8 logical cores, you can do make -j8.

  7. TheEpicFace007 commented on Nov 5, 2020

    @TheEpicFace007
    Author

    @devsnek it's not a valid command line option. I think msvc multithread the build automatically anyway

  8. bzoz commented on Nov 5, 2020

    @bzoz
    Contributor

    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.

  9. tniessen commented on Nov 5, 2020

    @tniessen
    Member

    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.

  10. TheEpicFace007 commented on Nov 5, 2020

    @TheEpicFace007
    Author

    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.

  11. tniessen commented on Nov 5, 2020

    @tniessen
    Member

    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.

  12. TheEpicFace007 commented on Nov 5, 2020

    @TheEpicFace007
    Author

    @tniessen The CPU usage seem fine.
    ![
    image
    ](CPU Usage)

  13. gengjiawen commented on Nov 12, 2020

    @gengjiawen
    Member

    Any chance we can bring ninja on windows ? cc @nodejs/gyp

    The increment build on windows still unbearable.

  14. TheEpicFace007 commented on Jan 8, 2022

    @TheEpicFace007
    Author

    I don't have any but thanks for suggesting ccache for improving build speed @scardracs +1

  15. aleclarson commented on Jan 25, 2022

    @aleclarson
    Contributor

    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?

  16. mmarchini commented on Jan 25, 2022

    @mmarchini
    Contributor

    @aleclarson Yes, there is a build flag that can be used for that (as per BUILDING.md):

    $ ./configure --node-builtin-modules-path $(pwd)
  17. StefanStojanovic commented on Jul 25, 2024

    @StefanStojanovic
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildIssues and PRs related to Node.js builds or CI infrastructure.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions