From 885c2702045ff5c7a2c5a2b315814c507ad83cf5 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 4 Nov 2014 12:08:10 +0000 Subject: [PATCH] * try to better guess a good parallel processing thread count that's reasonable for most systems be it 2 core / 32 core / HDD / SSD / etc --- source/net/filebot/ui/sfv/ChecksumComputationService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/net/filebot/ui/sfv/ChecksumComputationService.java b/source/net/filebot/ui/sfv/ChecksumComputationService.java index 7ff1cbbd..a59808c2 100644 --- a/source/net/filebot/ui/sfv/ChecksumComputationService.java +++ b/source/net/filebot/ui/sfv/ChecksumComputationService.java @@ -83,7 +83,7 @@ class ChecksumComputationService { private class ChecksumComputationExecutor extends ThreadPoolExecutor { public ChecksumComputationExecutor() { - super(1, Runtime.getRuntime().availableProcessors(), 0L, TimeUnit.SECONDS, new LinkedBlockingQueue(), new DefaultThreadFactory("ChecksumComputationPool", Thread.MIN_PRIORITY)); + super(1, 2 * Runtime.getRuntime().availableProcessors(), 0L, TimeUnit.SECONDS, new LinkedBlockingQueue(), new DefaultThreadFactory("ChecksumComputationPool", Thread.MIN_PRIORITY)); synchronized (executors) { if (executors.add(this) && executors.size() == 1) { @@ -100,7 +100,7 @@ class ChecksumComputationService { // for a few files, use one thread // for lots of files, use multiple threads // e.g 50 files ~ 1 thread, 200 files ~ 2 threads, 1000 files ~ 3 threads, 40000 files ~ 5 threads - return max((int) log10(getQueue().size()), 1); + return max(1, (int) ((Runtime.getRuntime().availableProcessors() / 2) + log10(getQueue().size()) - 1)); } @Override