Skip to content

Commit

Permalink
Run cleanup jobs sequentially instead of in parallel
Browse files Browse the repository at this point in the history
Each cleanup job try to use all available processors.
Running them in parallel will only increase the amount
of context switching without utilizing more processors.
  • Loading branch information
burqen committed May 18, 2017
1 parent 7fa434e commit 0cc2256
Showing 1 changed file with 13 additions and 5 deletions.
Expand Up @@ -57,11 +57,7 @@ public void add( CleanupJob job )
@Override
public void start() throws Throwable
{
CleanupJob job;
while ( (job = jobs.poll()) != null )
{
jobScheduler.schedule( recoveryCleanup, job );
}
jobScheduler.schedule( recoveryCleanup, allJobs() );
}

@Override
Expand All @@ -73,4 +69,16 @@ public void stop() throws Throwable
public void shutdown() throws Throwable
{ // no-op
}

private Runnable allJobs()
{
return () ->
{
CleanupJob job;
while ( (job = jobs.poll()) != null )
{
job.run();
}
};
}
}

0 comments on commit 0cc2256

Please sign in to comment.