Skip to content

Commit

Permalink
fix(core): consider available cpus when deciding whether to use worke…
Browse files Browse the repository at this point in the history
…rs to build the project graph (#7617)
  • Loading branch information
leosvelperez authored and FrozenPandaz committed Nov 11, 2021
1 parent cd2ee09 commit b00d3e5
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -165,14 +165,16 @@ async function buildProjectGraphUsingContext(
return r;
}

async function buildExplicitDependencies(
function buildExplicitDependencies(
ctx: ProjectGraphProcessorContext,
builder: ProjectGraphBuilder
) {
let totalNumOfFilesToProcess = totalNumberOfFilesToProcess(ctx);
// using workers has an overhead, so we only do it when the number of
// files we need to process is >= 100
if (totalNumOfFilesToProcess < 100) {
// files we need to process is >= 100 and there are more than 2 CPUs
// to be able to use at least 2 workers (1 worker per CPU and
// 1 CPU for the main thread)
if (totalNumOfFilesToProcess < 100 || os.cpus().length < 3) {
return buildExplicitDependenciesWithoutWorkers(ctx, builder);
} else {
return buildExplicitDependenciesUsingWorkers(
Expand Down

0 comments on commit b00d3e5

Please sign in to comment.