Skip to content

Commit 3f12c83

Browse files
committed
Make delays depending on available processors
Currently we use a fixed delay for a given job priority, depending on the number of jobs running and other factors this can considerably delay some actions and make eclipse feel laggy. This now makes these values dependent on the number of CPUs installed in the machine, as we can assume more CPUs can do the work better in parallel without additional sleep delays.
1 parent 77879f3 commit 3f12c83

File tree

1 file changed

+18
-6
lines changed
  • runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs

1 file changed

+18
-6
lines changed

runtime/bundles/org.eclipse.core.jobs/src/org/eclipse/core/internal/jobs/JobManager.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@
7878
*/
7979
public class JobManager implements IJobManager, DebugOptionsListener {
8080

81+
82+
private static final int CORES = Runtime.getRuntime().availableProcessors();
83+
84+
private static final long DELAY_PRIORITY_INTERACTIVE = 0;
85+
86+
private static final long DELAY_PRIORITY_DECORATE = 1000 / CORES;
87+
88+
private static final long DELAY_PRIORITY_BUILD = 500 / CORES;
89+
90+
private static final long DELAY_PRIORITY_LONG = 100 / CORES;
91+
92+
private static final long DELAY_PRIORITY_SHORT = 50 / CORES;
93+
8194
private static final int NANOS_IN_MS = 1_000_000;
8295

8396
/**
@@ -618,18 +631,17 @@ public ISchedulingRule currentRule() {
618631
* tolerate waiting.
619632
*/
620633
private long delayFor(int priority) {
621-
//these values may need to be tweaked based on machine speed
622634
switch (priority) {
623635
case Job.INTERACTIVE :
624-
return 0L;
636+
return DELAY_PRIORITY_INTERACTIVE;
625637
case Job.SHORT :
626-
return 50L;
638+
return DELAY_PRIORITY_SHORT;
627639
case Job.LONG :
628-
return 100L;
640+
return DELAY_PRIORITY_LONG;
629641
case Job.BUILD :
630-
return 500L;
642+
return DELAY_PRIORITY_BUILD;
631643
case Job.DECORATE :
632-
return 1000L;
644+
return DELAY_PRIORITY_DECORATE;
633645
default :
634646
Assert.isTrue(false, "Job has invalid priority: " + priority); //$NON-NLS-1$
635647
return 0;

0 commit comments

Comments
 (0)