diff --git a/core/org.eclipse.cdt.core/.options b/core/org.eclipse.cdt.core/.options index c5ba283ae3b..150f80e521c 100644 --- a/core/org.eclipse.cdt.core/.options +++ b/core/org.eclipse.cdt.core/.options @@ -33,6 +33,9 @@ org.eclipse.cdt.core/debug/typeresolver=false # Reports issues with locking the index org.eclipse.cdt.core/debug/index/locks=false +# Reports unusually slow IndexFileSet operations +org.eclipse.cdt.core/debug/index/indexfileset=false + # Reports events related to setting up the indexer for a project org.eclipse.cdt.core/debug/indexer/setup=false diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java index b5cf0b4e2b5..4a8a92036dd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexFileSet.java @@ -30,6 +30,8 @@ import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; public class IndexFileSet implements IIndexFileSet { + public static boolean sDEBUG_INDEX_FILE_SET; // Initialized in the PDOMManager. + private IIndexFileSet fInverse; private final HashMap fSubSets= new HashMap<>(); private final Map fDeclarationContainmentCache = new HashMap<>(); @@ -67,6 +69,7 @@ public class IndexFileSet implements IIndexFileSet { if (cachedValue != null) return cachedValue; + int iterationCount = 0; for (Map.Entry entry : fSubSets.entrySet()) { IIndexFragment fragment = entry.getKey(); IIndexFragmentFileSet fragmentFileSet = entry.getValue(); @@ -81,14 +84,35 @@ public class IndexFileSet implements IIndexFileSet { long fileRecord = PDOMName.getFileRecord(db, nameRecord); if (pdomFileSet.containsFile(fileRecord)) { fDeclarationContainmentCache.put(binding, true); + if (sDEBUG_INDEX_FILE_SET && iterationCount >= 200) { + System.out.println( + String.format("IndexFileSet: %s (%s) found after %d iterations", //$NON-NLS-1$ + String.join("::", binding.getQualifiedName()), //$NON-NLS-1$ + binding.getClass().getSimpleName(), + iterationCount)); + } return true; } + if (sDEBUG_INDEX_FILE_SET && ++iterationCount % 1000 == 0) { + System.out.println( + String.format("IndexFileSet: %s (%s) not yet found after %d iterations", //$NON-NLS-1$ + String.join("::", binding.getQualifiedName()), //$NON-NLS-1$ + binding.getClass().getSimpleName(), + iterationCount)); + } } } } catch (CoreException e) { CCorePlugin.log(e); } } + if (sDEBUG_INDEX_FILE_SET && iterationCount >= 200) { + System.out.println( + String.format("IndexFileSet: %s (%s) not found after %d iterations", //$NON-NLS-1$ + String.join("::", binding.getQualifiedName()), //$NON-NLS-1$ + binding.getClass().getSimpleName(), + iterationCount)); + } fDeclarationContainmentCache.put(binding, false); return false; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java index 3808bc5bfbc..8c59bcc439d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java @@ -110,7 +110,7 @@ public class PDOM extends PlatformObject implements IPDOM { private static final int BLOCKED_WRITE_LOCK_OUTPUT_INTERVAL = 30000; private static final int LONG_WRITE_LOCK_REPORT_THRESHOLD = 1000; private static final int LONG_READ_LOCK_WAIT_REPORT_THRESHOLD = 1000; - static boolean sDEBUG_LOCKS= false; // Initialized in the PDOMManager, because IBM needs PDOM independent of runtime plugin. + static boolean sDEBUG_LOCKS; // Initialized in the PDOMManager, because IBM needs PDOM independent of runtime plugin. /** * Identifier for PDOM format diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java index 02ac75d1194..056607eb636 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOMManager.java @@ -69,6 +69,7 @@ import org.eclipse.cdt.internal.core.index.IWritableIndex; import org.eclipse.cdt.internal.core.index.IWritableIndexManager; import org.eclipse.cdt.internal.core.index.IndexChangeEvent; import org.eclipse.cdt.internal.core.index.IndexFactory; +import org.eclipse.cdt.internal.core.index.IndexFileSet; import org.eclipse.cdt.internal.core.index.IndexerStateEvent; import org.eclipse.cdt.internal.core.index.provider.IndexProviderManager; import org.eclipse.cdt.internal.core.pdom.PDOM.IListener; @@ -198,6 +199,8 @@ public class PDOMManager implements IWritableIndexManager, IListener { public PDOMManager() { PDOM.sDEBUG_LOCKS= Boolean.parseBoolean(Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/index/locks")); //$NON-NLS-1$ + IndexFileSet.sDEBUG_INDEX_FILE_SET= + Boolean.parseBoolean(Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/index/indexfileset")); //$NON-NLS-1$ addIndexerSetupParticipant(new WaitForRefreshJobs()); fProjectDescriptionListener= new CProjectDescriptionListener(this); fJobChangeListener= new JobChangeListener(this);