Skip to content

The --parallel $NUM_JOBS parameter on Windows with Visual Studio makes builds very slow #241

Open
@LPGhatguy

Description

@LPGhatguy

Hello! Today I investigated build performance with cmake-rs and had some interesting findings.

This issue pertains to Windows and Visual Studio 17.13.2. The default CMake generator for my platform is used, Visual Studio 17 2022. My installed CMake version is 3.22.1.

I've been working on bindings to Jolt Physics. Part of that is invoking CMake to build JoltC and Jolt Physics. When I compile the library with CMake directly (i.e. cmake -B build; cmake --build build --config Release), I get a fast parallel build that's complete in a few seconds.

When using cmake-rs to invoke the build, the build takes a lot longer, around a minute and a half.

I was able to isolate this to cmake-rs passing the flag --parallel $NUM_JOBS on Windows. NUM_JOBS is 16 on my machine. Just deleting that block of code from cmake-rs makes the build around 6x faster.

If I build the library from CMake manually with --parallel 16, I do see a slower build, but only around 2x slower than normal. There may be something else going on either with CMake or Cargo that causes the remaining slowdown when the --parallel flag is passed.

Jolt's CMake config passes the /MP flag to the compiler, which enables multi-process parallelism.

Switching the CMake generator to Ninja instead of Visual Studio 17 2022 (the default) also seems to resolve the performance issue. I believe Ninja has a different strategy for parallelization compared with MSBuild.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions