Skip to content

Commit 2ae3568

Browse files
PoC: ProjectService skipCleanup option
Point of comparison showing a code change to enable ProjectService instances to skip cleanups. I believe this would improve performance for 'single-run' (not long-lived) consumers.
1 parent a6a0f4a commit 2ae3568

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/server/editorServices.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ export interface ProjectServiceOptions {
628628
globalPlugins?: readonly string[];
629629
pluginProbeLocations?: readonly string[];
630630
allowLocalPluginLoads?: boolean;
631+
skipCleanup?: boolean;
631632
typesMapLocation?: string;
632633
serverMode?: LanguageServiceMode;
633634
session: Session<unknown> | undefined;
@@ -1292,6 +1293,7 @@ export class ProjectService {
12921293
public readonly typingsInstaller: ITypingsInstaller;
12931294
private readonly globalCacheLocationDirectoryPath: Path | undefined;
12941295
public readonly throttleWaitMilliseconds?: number;
1296+
private readonly skipCleanup: boolean | undefined;
12951297
/** @internal */
12961298
readonly eventHandler?: ProjectServiceEventHandler;
12971299
private readonly suppressDiagnosticEvents?: boolean;
@@ -1343,6 +1345,7 @@ export class ProjectService {
13431345
this.typingsInstaller = opts.typingsInstaller || nullTypingsInstaller;
13441346
this.throttleWaitMilliseconds = opts.throttleWaitMilliseconds;
13451347
this.eventHandler = opts.eventHandler;
1348+
this.skipCleanup = opts.skipCleanup;
13461349
this.suppressDiagnosticEvents = opts.suppressDiagnosticEvents;
13471350
this.globalPlugins = opts.globalPlugins || emptyArray;
13481351
this.pluginProbeLocations = opts.pluginProbeLocations || emptyArray;
@@ -4410,6 +4413,12 @@ export class ProjectService {
44104413
openFilesWithRetainedConfiguredProject: Set<Path> | undefined,
44114414
externalProjectsRetainingConfiguredProjects: Set<string> | undefined,
44124415
) {
4416+
// "Single-run" runs such as command-line linting don't need to prune,
4417+
// as everything will be discarded quickly anyway.
4418+
if (this.skipCleanup) {
4419+
return;
4420+
}
4421+
44134422
// This was postponed from closeOpenFile to after opening next file,
44144423
// so that we can reuse the project if we need to right away
44154424
// Remove all the non marked projects

0 commit comments

Comments
 (0)