mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 01:05:38 +02:00
Bug 509898 - IndexFileSet.containsDeclaration is slow and is causing UI
freezes Added tracing of unusually expensive bindings in IndexFileSet. Change-Id: I316257d32b4af7357644a2958177efd2df58f864
This commit is contained in:
parent
e7d8ba0ec3
commit
90ad016967
4 changed files with 31 additions and 1 deletions
|
@ -33,6 +33,9 @@ org.eclipse.cdt.core/debug/typeresolver=false
|
||||||
# Reports issues with locking the index
|
# Reports issues with locking the index
|
||||||
org.eclipse.cdt.core/debug/index/locks=false
|
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
|
# Reports events related to setting up the indexer for a project
|
||||||
org.eclipse.cdt.core/debug/indexer/setup=false
|
org.eclipse.cdt.core/debug/indexer/setup=false
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public class IndexFileSet implements IIndexFileSet {
|
public class IndexFileSet implements IIndexFileSet {
|
||||||
|
public static boolean sDEBUG_INDEX_FILE_SET; // Initialized in the PDOMManager.
|
||||||
|
|
||||||
private IIndexFileSet fInverse;
|
private IIndexFileSet fInverse;
|
||||||
private final HashMap<IIndexFragment, IIndexFragmentFileSet> fSubSets= new HashMap<>();
|
private final HashMap<IIndexFragment, IIndexFragmentFileSet> fSubSets= new HashMap<>();
|
||||||
private final Map<IBinding, Boolean> fDeclarationContainmentCache = new HashMap<>();
|
private final Map<IBinding, Boolean> fDeclarationContainmentCache = new HashMap<>();
|
||||||
|
@ -67,6 +69,7 @@ public class IndexFileSet implements IIndexFileSet {
|
||||||
if (cachedValue != null)
|
if (cachedValue != null)
|
||||||
return cachedValue;
|
return cachedValue;
|
||||||
|
|
||||||
|
int iterationCount = 0;
|
||||||
for (Map.Entry<IIndexFragment, IIndexFragmentFileSet> entry : fSubSets.entrySet()) {
|
for (Map.Entry<IIndexFragment, IIndexFragmentFileSet> entry : fSubSets.entrySet()) {
|
||||||
IIndexFragment fragment = entry.getKey();
|
IIndexFragment fragment = entry.getKey();
|
||||||
IIndexFragmentFileSet fragmentFileSet = entry.getValue();
|
IIndexFragmentFileSet fragmentFileSet = entry.getValue();
|
||||||
|
@ -81,14 +84,35 @@ public class IndexFileSet implements IIndexFileSet {
|
||||||
long fileRecord = PDOMName.getFileRecord(db, nameRecord);
|
long fileRecord = PDOMName.getFileRecord(db, nameRecord);
|
||||||
if (pdomFileSet.containsFile(fileRecord)) {
|
if (pdomFileSet.containsFile(fileRecord)) {
|
||||||
fDeclarationContainmentCache.put(binding, true);
|
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;
|
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) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(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);
|
fDeclarationContainmentCache.put(binding, false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 BLOCKED_WRITE_LOCK_OUTPUT_INTERVAL = 30000;
|
||||||
private static final int LONG_WRITE_LOCK_REPORT_THRESHOLD = 1000;
|
private static final int LONG_WRITE_LOCK_REPORT_THRESHOLD = 1000;
|
||||||
private static final int LONG_READ_LOCK_WAIT_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
|
* Identifier for PDOM format
|
||||||
|
|
|
@ -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.IWritableIndexManager;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexChangeEvent;
|
import org.eclipse.cdt.internal.core.index.IndexChangeEvent;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexFactory;
|
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.IndexerStateEvent;
|
||||||
import org.eclipse.cdt.internal.core.index.provider.IndexProviderManager;
|
import org.eclipse.cdt.internal.core.index.provider.IndexProviderManager;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM.IListener;
|
import org.eclipse.cdt.internal.core.pdom.PDOM.IListener;
|
||||||
|
@ -198,6 +199,8 @@ public class PDOMManager implements IWritableIndexManager, IListener {
|
||||||
|
|
||||||
public PDOMManager() {
|
public PDOMManager() {
|
||||||
PDOM.sDEBUG_LOCKS= Boolean.parseBoolean(Platform.getDebugOption(CCorePlugin.PLUGIN_ID + "/debug/index/locks")); //$NON-NLS-1$
|
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());
|
addIndexerSetupParticipant(new WaitForRefreshJobs());
|
||||||
fProjectDescriptionListener= new CProjectDescriptionListener(this);
|
fProjectDescriptionListener= new CProjectDescriptionListener(this);
|
||||||
fJobChangeListener= new JobChangeListener(this);
|
fJobChangeListener= new JobChangeListener(this);
|
||||||
|
|
Loading…
Add table
Reference in a new issue