Increase the idle time before which ensureProject for open file is called (#37121)

* Increase timeout for ensuring projects for open files

* Condense the project/file printing in the log (given now we have project printed anytime its structure changes)
This commit is contained in:
Sheetal Nandi
2020-03-11 16:47:11 -07:00
committed by GitHub
parent d34af449ca
commit 243186685b
2 changed files with 15 additions and 21 deletions

View File

@@ -773,7 +773,7 @@ namespace ts.server {
private delayEnsureProjectForOpenFiles() {
this.pendingEnsureProjectForOpenFiles = true;
this.throttledOperations.schedule("*ensureProjectForOpenFiles*", /*delay*/ 250, () => {
this.throttledOperations.schedule("*ensureProjectForOpenFiles*", /*delay*/ 2500, () => {
if (this.pendingProjectUpdates.size !== 0) {
this.delayEnsureProjectForOpenFiles();
}
@@ -1210,7 +1210,7 @@ namespace ts.server {
private removeProject(project: Project) {
this.logger.info("`remove Project::");
project.print();
project.print(/*writeProjectFileNames*/ true);
project.close();
if (Debug.shouldAssert(AssertionLevel.Normal)) {
@@ -1719,19 +1719,17 @@ namespace ts.server {
return;
}
const writeProjectFileNames = this.logger.hasLevel(LogLevel.verbose);
this.logger.startGroup();
let counter = printProjectsWithCounter(this.externalProjects, 0);
counter = printProjectsWithCounter(arrayFrom(this.configuredProjects.values()), counter);
printProjectsWithCounter(this.inferredProjects, counter);
this.externalProjects.forEach(printProjectWithoutFileNames);
this.configuredProjects.forEach(printProjectWithoutFileNames);
this.inferredProjects.forEach(printProjectWithoutFileNames);
this.logger.info("Open files: ");
this.openFiles.forEach((projectRootPath, path) => {
const info = this.getScriptInfoForPath(path as Path)!;
this.logger.info(`\tFileName: ${info.fileName} ProjectRootPath: ${projectRootPath}`);
if (writeProjectFileNames) {
this.logger.info(`\t\tProjects: ${info.containingProjects.map(p => p.getProjectName())}`);
}
this.logger.info(`\t\tProjects: ${info.containingProjects.map(p => p.getProjectName())}`);
});
this.logger.endGroup();
@@ -2766,7 +2764,7 @@ namespace ts.server {
* After that all the inferred project graphs are updated
*/
private ensureProjectForOpenFiles() {
this.logger.info("Structure before ensureProjectForOpenFiles:");
this.logger.info("Before ensureProjectForOpenFiles:");
this.printProjects();
this.openFiles.forEach((projectRootPath, path) => {
@@ -2783,7 +2781,7 @@ namespace ts.server {
this.pendingEnsureProjectForOpenFiles = false;
this.inferredProjects.forEach(updateProjectIfDirty);
this.logger.info("Structure after ensureProjectForOpenFiles:");
this.logger.info("After ensureProjectForOpenFiles:");
this.printProjects();
}
@@ -3553,11 +3551,7 @@ namespace ts.server {
return (config as TsConfigSourceFile).kind !== undefined;
}
function printProjectsWithCounter(projects: Project[], counter: number) {
for (const project of projects) {
project.print(counter);
counter++;
}
return counter;
function printProjectWithoutFileNames(project: Project) {
project.print(/*writeProjectFileNames*/ false);
}
}

View File

@@ -1105,7 +1105,7 @@ namespace ts.server {
this.projectService.sendUpdateGraphPerformanceEvent(elapsed);
this.writeLog(`Finishing updateGraphWorker: Project: ${this.getProjectName()} Version: ${this.getProjectVersion()} structureChanged: ${hasNewProgram} Elapsed: ${elapsed}ms`);
if (this.hasAddedorRemovedFiles) {
this.print();
this.print(/*writeProjectFileNames*/ true);
}
else if (this.program !== oldProgram) {
this.writeLog(`Different program with same set of files:: oldProgram.structureIsReused:: ${oldProgram && oldProgram.structureIsReused}`);
@@ -1285,9 +1285,9 @@ namespace ts.server {
}
/*@internal*/
print(counter?: number) {
this.writeLog(`Project '${this.projectName}' (${ProjectKind[this.projectKind]}) ${counter === undefined ? "" : counter}`);
this.writeLog(this.filesToString(this.projectService.logger.hasLevel(LogLevel.verbose)));
print(writeProjectFileNames: boolean) {
this.writeLog(`Project '${this.projectName}' (${ProjectKind[this.projectKind]})`);
this.writeLog(this.filesToString(writeProjectFileNames && this.projectService.logger.hasLevel(LogLevel.verbose)));
this.writeLog("-----------------------------------------------");
}