From 124bb3dadbe7740c201d1f3a65501a1ee11d2492 Mon Sep 17 00:00:00 2001 From: Dirk Lemstra Date: Fri, 13 Jan 2017 00:16:24 +0100 Subject: [PATCH] Use linear scaling for the number of threads. --- MagickCore/thread-private.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/MagickCore/thread-private.h b/MagickCore/thread-private.h index dfbc4fd5f..1b2e263c4 100644 --- a/MagickCore/thread-private.h +++ b/MagickCore/thread-private.h @@ -30,14 +30,12 @@ extern "C" { Single threaded unless workload justifies the threading overhead. */ #define magick_threads(source,destination,chunk,expression) \ - num_threads((expression) == 0 ? 1 : \ - ((chunk) > (32*GetMagickResourceLimit(ThreadResource))) && \ - ((GetImagePixelCacheType(source) == MemoryCache) || \ - (GetImagePixelCacheType(source) == MapCache)) && \ - ((GetImagePixelCacheType(destination) == MemoryCache) || \ - (GetImagePixelCacheType(destination) == MapCache)) ? \ - GetMagickResourceLimit(ThreadResource) : \ - GetMagickResourceLimit(ThreadResource) < 2 ? 1 : 2) + num_threads((expression) != 0 && \ + ((GetImagePixelCacheType(source) == MemoryCache) || \ + (GetImagePixelCacheType(source) == MapCache)) && \ + ((GetImagePixelCacheType(destination) == MemoryCache) || \ + (GetImagePixelCacheType(destination) == MapCache)) ? \ + max(1,min(GetMagickResourceLimit(ThreadResource),(chunk) / 16)) : 1) #if defined(__clang__) || (__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ > 10)) #define MagickCachePrefetch(address,mode,locality) \ -- 2.40.0