mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Indexer: Minor improvement of progress reporting.
This commit is contained in:
parent
1d087b260f
commit
ae557bd281
5 changed files with 63 additions and 59 deletions
|
@ -16,6 +16,7 @@ public class IndexerProgress {
|
||||||
public int fTotalSourcesEstimate;
|
public int fTotalSourcesEstimate;
|
||||||
public int fCompletedHeaders;
|
public int fCompletedHeaders;
|
||||||
public int fCompletedSources;
|
public int fCompletedSources;
|
||||||
|
public int fTimeEstimate;
|
||||||
public String fMonitorDetail;
|
public String fMonitorDetail;
|
||||||
|
|
||||||
public IndexerProgress() {
|
public IndexerProgress() {
|
||||||
|
@ -32,4 +33,8 @@ public class IndexerProgress {
|
||||||
public int getRemainingSources() {
|
public int getRemainingSources() {
|
||||||
return fTotalSourcesEstimate-fCompletedSources;
|
return fTotalSourcesEstimate-fCompletedSources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getTimeEstimate() {
|
||||||
|
return fTotalSourcesEstimate > 0 ? fTotalSourcesEstimate : fTimeEstimate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Platform;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.jobs.Job;
|
import org.eclipse.core.runtime.jobs.Job;
|
||||||
|
|
||||||
|
@ -26,8 +25,9 @@ import org.eclipse.core.runtime.jobs.Job;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PDOMIndexerJob extends Job {
|
public class PDOMIndexerJob extends Job {
|
||||||
|
private static final int PROGRESS_UPDATE_INTERVAL = 500;
|
||||||
private static final int TOTAL_MONITOR_WORK = 100000;
|
private static final int TOTAL_MONITOR_WORK = 1000;
|
||||||
|
|
||||||
private final PDOMManager pdomManager;
|
private final PDOMManager pdomManager;
|
||||||
private IPDOMIndexerTask currentTask;
|
private IPDOMIndexerTask currentTask;
|
||||||
private boolean cancelledByManager= false;
|
private boolean cancelledByManager= false;
|
||||||
|
@ -42,8 +42,6 @@ public class PDOMIndexerJob extends Job {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
|
|
||||||
fMonitor = monitor;
|
fMonitor = monitor;
|
||||||
String taskName = CCorePlugin.getResourceString("pdom.indexer.task"); //$NON-NLS-1$
|
String taskName = CCorePlugin.getResourceString("pdom.indexer.task"); //$NON-NLS-1$
|
||||||
monitor.beginTask(taskName, TOTAL_MONITOR_WORK);
|
monitor.beginTask(taskName, TOTAL_MONITOR_WORK);
|
||||||
|
@ -57,7 +55,6 @@ public class PDOMIndexerJob extends Job {
|
||||||
public void setCanceled(boolean cancelled) {
|
public void setCanceled(boolean cancelled) {
|
||||||
fMonitor.setCanceled(cancelled);
|
fMonitor.setCanceled(cancelled);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
synchronized(taskMutex) {
|
synchronized(taskMutex) {
|
||||||
currentTask= null;
|
currentTask= null;
|
||||||
|
@ -78,12 +75,6 @@ public class PDOMIndexerJob extends Job {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (currentTask != null);
|
while (currentTask != null);
|
||||||
|
|
||||||
String showTimings = Platform.getDebugOption(CCorePlugin.PLUGIN_ID
|
|
||||||
+ "/debug/pdomtimings"); //$NON-NLS-1$
|
|
||||||
if (showTimings != null && showTimings.equalsIgnoreCase("true")) //$NON-NLS-1$
|
|
||||||
System.out.println("PDOM Indexer Job Time: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
|
|
||||||
|
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
}
|
}
|
||||||
catch (RuntimeException e) {
|
catch (RuntimeException e) {
|
||||||
|
@ -117,7 +108,7 @@ public class PDOMIndexerJob extends Job {
|
||||||
while(!m.isCanceled() && !targetMonitor.isCanceled()) {
|
while(!m.isCanceled() && !targetMonitor.isCanceled()) {
|
||||||
currentTick= pdomManager.getMonitorMessage(targetMonitor, currentTick, TOTAL_MONITOR_WORK);
|
currentTick= pdomManager.getMonitorMessage(targetMonitor, currentTick, TOTAL_MONITOR_WORK);
|
||||||
try {
|
try {
|
||||||
Thread.sleep(350);
|
Thread.sleep(PROGRESS_UPDATE_INTERVAL);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
return Status.CANCEL_STATUS;
|
return Status.CANCEL_STATUS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -368,10 +368,8 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
else {
|
else {
|
||||||
if (fCurrentTask != null) {
|
if (fCurrentTask != null) {
|
||||||
IndexerProgress info= fCurrentTask.getProgressInformation();
|
IndexerProgress info= fCurrentTask.getProgressInformation();
|
||||||
if (info != null) {
|
fCompletedSources+= info.fCompletedSources;
|
||||||
fCompletedSources+= info.fCompletedSources;
|
fCompletedHeaders+= info.fCompletedHeaders;
|
||||||
fCompletedHeaders+= info.fCompletedHeaders;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
result= fCurrentTask= (IPDOMIndexerTask)fTaskQueue.removeFirst();
|
result= fCurrentTask= (IPDOMIndexerTask)fTaskQueue.removeFirst();
|
||||||
}
|
}
|
||||||
|
@ -601,7 +599,8 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean joinIndexer(int waitMaxMillis, IProgressMonitor monitor) {
|
public boolean joinIndexer(int waitMaxMillis, IProgressMonitor monitor) {
|
||||||
monitor.beginTask(Messages.PDOMManager_JoinIndexerTask, 1000);
|
final int totalTicks = 1000;
|
||||||
|
monitor.beginTask(Messages.PDOMManager_JoinIndexerTask, totalTicks);
|
||||||
long limit= System.currentTimeMillis()+waitMaxMillis;
|
long limit= System.currentTimeMillis()+waitMaxMillis;
|
||||||
try {
|
try {
|
||||||
int currentTicks= 0;
|
int currentTicks= 0;
|
||||||
|
@ -609,7 +608,7 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
currentTicks= getMonitorMessage(monitor, currentTicks, 1000);
|
currentTicks= getMonitorMessage(monitor, currentTicks, totalTicks);
|
||||||
synchronized(fTaskQueueMutex) {
|
synchronized(fTaskQueueMutex) {
|
||||||
if (isIndexerIdle()) {
|
if (isIndexerIdle()) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -643,33 +642,26 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
int remainingSources= 0;
|
int remainingSources= 0;
|
||||||
int completedSources= 0;
|
int completedSources= 0;
|
||||||
int completedHeaders= 0;
|
int completedHeaders= 0;
|
||||||
int unknown= 0;
|
int totalEstimate= 0;
|
||||||
String detail= null;
|
String detail= null;
|
||||||
IndexerProgress info;
|
IndexerProgress info;
|
||||||
synchronized (fTaskQueueMutex) {
|
synchronized (fTaskQueueMutex) {
|
||||||
completedHeaders= fCompletedHeaders;
|
completedHeaders= fCompletedHeaders;
|
||||||
completedSources= fCompletedSources;
|
completedSources= fCompletedSources;
|
||||||
|
totalEstimate= fCompletedHeaders+fCompletedSources;
|
||||||
for (Iterator iter = fTaskQueue.iterator(); iter.hasNext();) {
|
for (Iterator iter = fTaskQueue.iterator(); iter.hasNext();) {
|
||||||
IPDOMIndexerTask task = (IPDOMIndexerTask) iter.next();
|
IPDOMIndexerTask task = (IPDOMIndexerTask) iter.next();
|
||||||
info= task.getProgressInformation();
|
info= task.getProgressInformation();
|
||||||
if (info == null) {
|
remainingSources+= info.getRemainingSources();
|
||||||
unknown++;
|
totalEstimate+= info.getTimeEstimate();
|
||||||
}
|
|
||||||
else {
|
|
||||||
remainingSources+= info.getRemainingSources();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (fCurrentTask != null) {
|
if (fCurrentTask != null) {
|
||||||
info= fCurrentTask.getProgressInformation();
|
info= fCurrentTask.getProgressInformation();
|
||||||
if (info == null) {
|
remainingSources+= info.getRemainingSources();
|
||||||
unknown++;
|
completedHeaders+= info.fCompletedHeaders;
|
||||||
}
|
completedSources+= info.fCompletedSources;
|
||||||
else {
|
detail= info.fMonitorDetail;
|
||||||
remainingSources+= info.getRemainingSources();
|
totalEstimate+= info.getTimeEstimate();
|
||||||
completedHeaders+= info.fCompletedHeaders;
|
|
||||||
completedSources+= info.fCompletedSources;
|
|
||||||
detail= info.fMonitorDetail;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -682,9 +674,8 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
}
|
}
|
||||||
monitor.subTask(msg);
|
monitor.subTask(msg);
|
||||||
|
|
||||||
totalSources+= unknown*1000;
|
if (completedSources > 0 && totalEstimate >= completedSources) {
|
||||||
if (completedSources > 0 && totalSources >= completedSources) {
|
int newTick= completedSources*base/totalEstimate;
|
||||||
int newTick= completedSources*base/totalSources;
|
|
||||||
if (newTick > currentTicks) {
|
if (newTick > currentTicks) {
|
||||||
monitor.worked(newTick-currentTicks);
|
monitor.worked(newTick-currentTicks);
|
||||||
return newTick;
|
return newTick;
|
||||||
|
|
|
@ -25,18 +25,27 @@ import org.eclipse.cdt.internal.core.index.IWritableIndexManager;
|
||||||
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
|
import org.eclipse.cdt.internal.core.pdom.IndexerProgress;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.osgi.util.NLS;
|
||||||
|
|
||||||
public class PDOMRebuildTask implements IPDOMIndexerTask {
|
public class PDOMRebuildTask implements IPDOMIndexerTask {
|
||||||
private static final String TRUE= String.valueOf(true);
|
private static final String TRUE= String.valueOf(true);
|
||||||
private static final ITranslationUnit[] NO_TUS = new ITranslationUnit[0];
|
private static final ITranslationUnit[] NO_TUS = new ITranslationUnit[0];
|
||||||
|
|
||||||
private IPDOMIndexer fIndexer;
|
private final IPDOMIndexer fIndexer;
|
||||||
private IPDOMIndexerTask fDelegate;
|
private final IndexerProgress fProgress;
|
||||||
|
private volatile IPDOMIndexerTask fDelegate;
|
||||||
|
|
||||||
public PDOMRebuildTask(IPDOMIndexer indexer) {
|
public PDOMRebuildTask(IPDOMIndexer indexer) {
|
||||||
fIndexer= indexer;
|
fIndexer= indexer;
|
||||||
|
fProgress= createProgress(indexer.getProject().getElementName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IndexerProgress createProgress(String prjName) {
|
||||||
|
IndexerProgress progress= new IndexerProgress();
|
||||||
|
progress.fTimeEstimate= 1000;
|
||||||
|
progress.fMonitorDetail= NLS.bind(Messages.PDOMIndexerTask_collectingFilesTask, prjName);
|
||||||
|
return progress;
|
||||||
|
}
|
||||||
|
|
||||||
public IPDOMIndexer getIndexer() {
|
public IPDOMIndexer getIndexer() {
|
||||||
return fIndexer;
|
return fIndexer;
|
||||||
|
@ -73,7 +82,7 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDelegate(ICProject project, IProgressMonitor monitor) throws CoreException {
|
private synchronized void createDelegate(ICProject project, IProgressMonitor monitor) throws CoreException {
|
||||||
boolean allFiles= TRUE.equals(fIndexer.getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
boolean allFiles= TRUE.equals(fIndexer.getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
||||||
List list= new ArrayList();
|
List list= new ArrayList();
|
||||||
TranslationUnitCollector collector= new TranslationUnitCollector(list, allFiles, monitor);
|
TranslationUnitCollector collector= new TranslationUnitCollector(list, allFiles, monitor);
|
||||||
|
@ -83,8 +92,7 @@ public class PDOMRebuildTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IndexerProgress getProgressInformation() {
|
public synchronized IndexerProgress getProgressInformation() {
|
||||||
return fDelegate != null ? fDelegate.getProgressInformation() : null;
|
return fDelegate != null ? fDelegate.getProgressInformation() : fProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
import org.eclipse.cdt.core.dom.IPDOMIndexerTask;
|
||||||
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICContainer;
|
import org.eclipse.cdt.core.model.ICContainer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
@ -30,23 +31,33 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
public class PDOMResourceDeltaTask implements IPDOMIndexerTask {
|
public class PDOMResourceDeltaTask implements IPDOMIndexerTask {
|
||||||
private static final String TRUE = String.valueOf(true);
|
private static final String TRUE = String.valueOf(true);
|
||||||
|
|
||||||
private IPDOMIndexer fIndexer;
|
final private IPDOMIndexer fIndexer;
|
||||||
private boolean fAllFiles;
|
final private boolean fAllFiles;
|
||||||
private IPDOMIndexerTask fDelegate;
|
final private IPDOMIndexerTask fDelegate;
|
||||||
|
final private IndexerProgress fProgress;
|
||||||
|
|
||||||
public PDOMResourceDeltaTask(IPDOMIndexer indexer, ICElementDelta delta) throws CoreException {
|
public PDOMResourceDeltaTask(IPDOMIndexer indexer, ICElementDelta delta) throws CoreException {
|
||||||
fIndexer= indexer;
|
fIndexer= indexer;
|
||||||
|
fProgress= new IndexerProgress();
|
||||||
fAllFiles= TRUE.equals(getIndexer().getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
fAllFiles= TRUE.equals(getIndexer().getProperty(IndexerPreferences.KEY_INDEX_ALL_FILES));
|
||||||
List a= new ArrayList();
|
if (!IPDOMManager.ID_NO_INDEXER.equals(fIndexer.getID())) {
|
||||||
List c= new ArrayList();
|
List a= new ArrayList();
|
||||||
List r= new ArrayList();
|
List c= new ArrayList();
|
||||||
|
List r= new ArrayList();
|
||||||
|
|
||||||
processDelta(delta, a, c, r, new NullProgressMonitor());
|
processDelta(delta, a, c, r, new NullProgressMonitor());
|
||||||
if (!a.isEmpty() || !c.isEmpty() || !r.isEmpty()) {
|
if (!a.isEmpty() || !c.isEmpty() || !r.isEmpty()) {
|
||||||
ITranslationUnit[] aa= (ITranslationUnit[]) a.toArray(new ITranslationUnit[a.size()]);
|
ITranslationUnit[] aa= (ITranslationUnit[]) a.toArray(new ITranslationUnit[a.size()]);
|
||||||
ITranslationUnit[] ca= (ITranslationUnit[]) c.toArray(new ITranslationUnit[c.size()]);
|
ITranslationUnit[] ca= (ITranslationUnit[]) c.toArray(new ITranslationUnit[c.size()]);
|
||||||
ITranslationUnit[] ra= (ITranslationUnit[]) r.toArray(new ITranslationUnit[r.size()]);
|
ITranslationUnit[] ra= (ITranslationUnit[]) r.toArray(new ITranslationUnit[r.size()]);
|
||||||
fDelegate= indexer.createTask(aa, ca, ra);
|
fDelegate= indexer.createTask(aa, ca, ra);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fDelegate= null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fDelegate= null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +101,6 @@ public class PDOMResourceDeltaTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectSources(ICContainer container, Collection sources, IProgressMonitor pm) throws CoreException {
|
private void collectSources(ICContainer container, Collection sources, IProgressMonitor pm) throws CoreException {
|
||||||
|
@ -108,11 +118,10 @@ public class PDOMResourceDeltaTask implements IPDOMIndexerTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexerProgress getProgressInformation() {
|
public IndexerProgress getProgressInformation() {
|
||||||
return fDelegate == null ? null : fDelegate.getProgressInformation();
|
return fDelegate != null ? fDelegate.getProgressInformation() : fProgress;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return fDelegate == null;
|
return fDelegate == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue