Skip to content

Commit

Permalink
Always use thread count equal to number of available processors in Cr…
Browse files Browse the repository at this point in the history
…ashGenerationCleaner
  • Loading branch information
burqen committed Aug 23, 2018
1 parent 1be828a commit 9b2d920
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 58 deletions.
Expand Up @@ -66,13 +66,6 @@ class CrashGenerationCleaner
this.internalMaxKeyCount = treeNode.internalMaxKeyCount(); this.internalMaxKeyCount = treeNode.internalMaxKeyCount();
} }


static int threads( long pagesToClean )
{
// Thread count at most equal to availableProcessors, at least one and each thread should have at least one batch of work
long availableProcessors = Runtime.getRuntime().availableProcessors();
return (int) min( availableProcessors, max( 1, pagesToClean / MIN_BATCH_SIZE ) );
}

static long batchSize( long pagesToClean, int threads ) static long batchSize( long pagesToClean, int threads )
{ {
// Batch size at most maxBatchSize, at least minBatchSize and trying to give each thread 100 batches each // Batch size at most maxBatchSize, at least minBatchSize and trying to give each thread 100 batches each
Expand All @@ -89,7 +82,7 @@ public void clean( ExecutorService executor ) throws IOException


long startTime = currentTimeMillis(); long startTime = currentTimeMillis();
long pagesToClean = highTreeNodeId - lowTreeNodeId; long pagesToClean = highTreeNodeId - lowTreeNodeId;
int threads = threads( pagesToClean ); int threads = Runtime.getRuntime().availableProcessors();
long batchSize = batchSize( pagesToClean, threads ); long batchSize = batchSize( pagesToClean, threads );
AtomicLong nextId = new AtomicLong( lowTreeNodeId ); AtomicLong nextId = new AtomicLong( lowTreeNodeId );
AtomicReference<Throwable> error = new AtomicReference<>(); AtomicReference<Throwable> error = new AtomicReference<>();
Expand Down

This file was deleted.

0 comments on commit 9b2d920

Please sign in to comment.