Skip to content

Enhance Indexer performance #4444

@snjeza

Description

@snjeza

I have found two issues related to indexer performance:

  1. AddJarFileToIndex doesn't use zip cache. See
  1. SourceIndexer creates a new JavaSearchNameEnvironment for each source file
    INameEnvironment nameEnvironment = new JavaSearchNameEnvironment(javaProject, JavaModelManager.getJavaModelManager().getWorkingCopies(DefaultWorkingCopyOwner.PRIMARY, true/*add primary WCs*/));

    We would need to create one JavaSearchNameEnvironment for a project.

I have created a PR and tested it using the spring-boot project. The Rebuild Index action takes 10-20% less when using the zip and name environment cache.

I have tested the Rebuild Index action using the following patch:

diff --git a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java
index 1f28bb2fa1..f46f1b1465 100644
--- a/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java
+++ b/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/processing/JobManager.java
@@ -482,6 +482,7 @@ public abstract class JobManager {
 				}
 			}
 			this.progressJob = null;
+			long start = 0;
 			while (getProcessingThread() != null) {
 				try {
 					IJob job;
@@ -513,6 +514,7 @@ public abstract class JobManager {
 						if (cacheZipFiles) {
 							JavaModelManager.getJavaModelManager().flushZipFiles(this);
 							cacheZipFiles = false;
+							System.out.println("RebuildIndex Took: " + (System.currentTimeMillis() - start ));
 						}
 						// just woke up, delay before processing any new jobs, allow some time for the active thread to finish
 						synchronized (this.idleMonitor) {
@@ -535,10 +537,17 @@ public abstract class JobManager {
 							this.progressJob = pJob;
 						}
 						if (!cacheZipFiles) {
+							start = System.currentTimeMillis();
 							JavaModelManager.getJavaModelManager().cacheZipFiles(this);
 							cacheZipFiles = true;
 						}
+						long s1 = System.currentTimeMillis();
+						// System.out.println("Job: " + job + " Start ");
 						job.execute(null); // may enqueue a new job
+						long took = System.currentTimeMillis() - s1;
+						if (took > 2000) {
+							System.out.println("Job: " + job + " Took: " + took);
+						}
 					} finally {
 						this.executing = false;
 						if (VERBOSE) {

The related issue - #2501 @jukzi The PR reduces the number of source file reads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions