[x265] [PATCH] Performance: Prevent small thread-pools if NUMA disabled and # CPUs > MAX_POOL_THREADS

pradeep at multicorewareinc.com pradeep at multicorewareinc.com
Wed Aug 26 12:41:45 CEST 2015


# HG changeset patch
# User Pradeep Ramachandran <pradeep at multicorewareinc.com>
# Date 1440585642 -19800
#      Wed Aug 26 16:10:42 2015 +0530
# Node ID dd7ef2bd657f8e8369c2b8c10e0452b9ff6e37f5
# Parent  d8091487bc9749e702c468786b0cd9e663478a91
Performance: Prevent small thread-pools if NUMA disabled and # CPUs > MAX_POOL_THREADS

When NUMA is disabled and if # CPUs is > MAX_POOL_THREADS (64 or 32 depending on 64-bit
or 32-bit builds), the last pool may have few threads. This patch allows the last pool to
exist only if it has > MAX_POOL_THREADS/2 threads; the 50% number is a heurstic.

Feature gains performance of 5% on Intel Xeon E5-2699v3 measured in slower preset with 4K video.

diff -r d8091487bc97 -r dd7ef2bd657f source/common/threadpool.cpp
--- a/source/common/threadpool.cpp	Tue Aug 25 16:39:12 2015 -0700
+++ b/source/common/threadpool.cpp	Wed Aug 26 16:10:42 2015 +0530
@@ -289,6 +289,14 @@
         }
     }
 
+    // In the case that numa is disabled and we have more CPUs than 64,
+    // spawn the last pool only if the # threads in that pool is > 1/2 max (heuristic)
+    if ((numNumaNodes == 1) && (cpusPerNode[0] % MAX_POOL_THREADS < (MAX_POOL_THREADS / 2)))
+    {
+        cpusPerNode[0] -= (cpusPerNode[0] % MAX_POOL_THREADS);
+        x265_log(p, X265_LOG_DEBUG, "Creating only %d worker threads to prevent asymmetry in pools; may not use all HW contexts\n", cpusPerNode[0]);
+    }
+
     numPools = 0;
     for (int i = 0; i < numNumaNodes; i++)
     {


More information about the x265-devel mailing list