reduce _jobLock contention

This commit is contained in:
zzz
2012-09-10 17:27:18 +00:00
parent 835ed6d9bb
commit e0fc642fc3
2 changed files with 9 additions and 2 deletions

View File

@@ -55,6 +55,7 @@ public class JobQueue {
private boolean _alive;
private final Object _jobLock;
private volatile long _nextPumperRun;
/** how many when we go parallel */
private static final int RUNNERS;
@@ -187,7 +188,9 @@ public class JobQueue {
} else {
_timedJobs.add(job);
// only notify for _timedJobs, as _readyJobs does not use that lock
_jobLock.notifyAll();
// only notify if sooner, to reduce contention
if (job.getTiming().getStartAfter() < _nextPumperRun)
_jobLock.notifyAll();
}
}
}
@@ -225,6 +228,9 @@ public class JobQueue {
return false;
}
/**
* @deprecated contention - see JobTiming.setStartAfter() comments
*/
public void timingUpdated() {
synchronized (_jobLock) {
_jobLock.notifyAll();
@@ -518,6 +524,7 @@ public class JobQueue {
timeToWait = 10*1000;
//if (_log.shouldLog(Log.DEBUG))
// _log.debug("Waiting " + timeToWait + " before rechecking the timed queue");
_nextPumperRun = _context.clock().now() + timeToWait;
_jobLock.wait(timeToWait);
} // synchronize (_jobLock)
} catch (InterruptedException ie) {}

View File

@@ -43,7 +43,7 @@ public class JobTiming implements Clock.ClockUpdateListener {
// but...
// ...
// who cares? this helps in the case where it is on the queue
_context.jobQueue().timingUpdated();
//_context.jobQueue().timingUpdated();
}
/**