microsoft / microsoft/react-native-windows

--singleproc flag not respected on machines with more than 16GB of memory

Open
#12,181 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area: CLI bug Workstream: ES Compliance SFI
Dominant language
C++
Stars
17.3k
Forks
1.2k
Avg merge
1d 13h
Merged PRs (30d)
33

Description

Problem Description

As noted in this code (thanks to @ryfow for the investigation), if a computer has more than 16GB of memory and the --singleproc flag is passed, we will not respect the --singleproc flag because of the OR check.

// Building projects in parallel increases compiler memory usage and
// doesn't lead to dramatic performance gains (See #4739). Only enable
// parallel builds on machines with >16GB of memory to avoid OOM errors
const highMemory = totalmem() > 16 * 1024 * 1024 * 1024;
const enableParallelBuilds = singleproc === false || highMemory;
Steps To Reproduce
  1. Make sure you're on a computer with more than 16GB of memory.
  2. Run the following commands in the directory of your choice:
npx react-native init test
cd test
npx react-native-windows-init
yarn windows --singleproc --logging
  1. Note that the argument /maxCpuCount is logged when we log the arguments passed to MSBuild.
Expected Results

I expect that /maxCpuCount is not passed to MSBuild when the --singleproc flag is passed.

CLI version

11.3.7

Environment
System:
  OS: Windows 10 10.0.19045
  CPU: (16) x64 11th Gen Intel(R) Core(TM) i7-11850H @ 2.50GHz
  Memory: 19.97 GB / 31.73 GB
Binaries:
  Node:
    version: 18.18.0
    path: C:\Program Files\nodejs\node.EXE
  Yarn:
    version: 1.22.19
    path: ~\AppData\Roaming\npm\yarn.CMD
  npm:
    version: 9.8.1
    path: C:\Program Files\nodejs\npm.CMD
  Watchman: Not Found
SDKs:
  Android SDK: Not Found
  Windows SDK:
    AllowDevelopmentWithoutDevLicense: Enabled
    AllowAllTrustedApps: Enabled
    Versions:
      - 10.0.19041.0
      - 10.0.22621.0
IDEs:
  Android Studio: Not Found
  Visual Studio:
    - 17.7.34031.279 (Visual Studio Professional 2022)
Languages:
  Java: Not Found
  Ruby: Not Found
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.5
    wanted: 0.72.5
  react-native-windows:
    installed: 0.72.9
    wanted: 0.72.9
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found
Target Platform Version

10.0.19041

Target Device(s)

Desktop

Visual Studio Version

Visual Studio 2022

Build Configuration

Debug

Snack, code example, screenshot, or link to a repository

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect packages/@react-native-windows/cli/src/utils/msbuildtools.ts around the highMemory and MSBuild argument logic at the referenced lines. Reproduce the yarn windows --singleproc --logging command on a machine with more than 16GB of memory, then verify that /maxCpuCount is absent when the flag is used.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
build-system, cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.