Skip to content

Commit

Permalink
Lower defaultNumJobs to prevent UI freezing and stop using --parallel…
Browse files Browse the repository at this point in the history
… when CMakePresets is used and parallelJobs is not set (#4300)

* Lower defaultNumJobs to prevent UI freezing.
* Stop using --parallel if parallelJobs is not set.
* Remove undefined from parallelJobs type.
  • Loading branch information
sean-mcmanus authored Feb 26, 2025
1 parent 0343171 commit 2006d33
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/cmakeProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ export class CMakeProject {
buildPreset,
lightNormalizePath(this.folderPath || '.'),
this.sourceDir,
this.workspaceContext.config.parallelJobs,
this.workspaceContext.config.numJobs,
this.getPreferredGeneratorName(),
true,
this.configurePreset?.name);
Expand Down
8 changes: 4 additions & 4 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { Environment } from '@cmt/environmentVariables';
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
export function defaultNumJobs (): number {
return os.cpus().length + 2;
return os.cpus().length;
}

const log = logging.createLogger('config');
Expand Down Expand Up @@ -171,7 +171,7 @@ export interface ExtensionConfigurationSettings {
configureArgs: string[];
buildArgs: string[];
buildToolArgs: string[];
parallelJobs: number | undefined;
parallelJobs: number;
ctestPath: string;
ctest: { parallelJobs: number; allowParallelJobs: boolean; testExplorerIntegrationEnabled: boolean; testSuiteDelimiter: string };
parseBuildDiagnostics: boolean;
Expand Down Expand Up @@ -372,7 +372,7 @@ export class ConfigurationReader implements vscode.Disposable {
get buildToolArgs(): string[] {
return this.configData.buildToolArgs;
}
get parallelJobs(): number | undefined {
get parallelJobs(): number {
return this.configData.parallelJobs;
}
get ctestParallelJobs(): number | null {
Expand Down Expand Up @@ -485,7 +485,7 @@ export class ConfigurationReader implements vscode.Disposable {
}

get numJobs(): number | undefined {
if (this.parallelJobs === undefined) {
if (this.isDefaultValue("parallelJobs")) {
return undefined;
} else if (this.parallelJobs === 0) {
return defaultNumJobs();
Expand Down
4 changes: 2 additions & 2 deletions src/presets/preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { errorHandlerHelper, expandString, ExpansionErrorHandler, ExpansionOptio
import paths from '@cmt/paths';
import { compareVersions, VSInstallation, vsInstallations, enumerateMsvcToolsets, varsForVSInstallation, getVcVarsBatScript } from '@cmt/installs/visualStudio';
import { EnvironmentUtils, EnvironmentWithNull } from '@cmt/environmentVariables';
import { defaultNumJobs, UseVsDeveloperEnvironment } from '@cmt/config';
import { UseVsDeveloperEnvironment } from '@cmt/config';

nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
const localize: nls.LocalizeFunc = nls.loadMessageBundle();
Expand Down Expand Up @@ -1585,7 +1585,7 @@ async function getBuildPresetInheritsImpl(folder: string, name: string, workspac
name: defaultBuildPreset.name,
displayName: defaultBuildPreset.displayName,
description: defaultBuildPreset.description,
jobs: parallelJobs || defaultNumJobs(),
jobs: parallelJobs,
configurePreset
};
return getBuildPresetInheritsHelper(folder, preset, workspaceFolder, sourceDir, parallelJobs, preferredGeneratorName, true, usePresetsPlusIncluded, errorHandler);
Expand Down

0 comments on commit 2006d33

Please sign in to comment.