From: Dirk Lemstra Date: Thu, 12 Jan 2017 23:16:24 +0000 (+0100) Subject: Use linear scaling for the number of threads. X-Git-Tag: 7.0.4-4~5 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=124bb3dadbe7740c201d1f3a65501a1ee11d2492;p=imagemagick Use linear scaling for the number of threads. --- 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) \