diff options
| author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2024-08-22 22:41:12 +0200 |
|---|---|---|
| committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2024-08-25 11:10:48 +0200 |
| commit | 80f210db3e43c50e252504f41ed3fbd8b2992028 (patch) | |
| tree | d81e61768a062d1924ee0f0b3a2fd159c62049ef /src/corelib/thread/qthreadpool.cpp | |
| parent | d380b7fb18a07691a1b0e6250e442ca9133b5747 (diff) | |
Limit gui thread pool to 8 threads
Avoid having too many threads, since iOS punishes us if we overstep 64,
and we don't really need more than 8 on any platform.
Fixes: QTBUG-128290
Pick-to: 6.8 6.7 6.5
Change-Id: I59a233d422e9b1b2097a777e0b1b626e144594d9
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/thread/qthreadpool.cpp')
| -rw-r--r-- | src/corelib/thread/qthreadpool.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/thread/qthreadpool.cpp b/src/corelib/thread/qthreadpool.cpp index c7531111da7..f4dc940cc4b 100644 --- a/src/corelib/thread/qthreadpool.cpp +++ b/src/corelib/thread/qthreadpool.cpp @@ -481,8 +481,13 @@ QThreadPool *QThreadPoolPrivate::qtGuiInstance() Q_CONSTINIT static QBasicMutex theMutex; const QMutexLocker locker(&theMutex); - if (guiInstance.isNull() && !QCoreApplication::closingDown()) + if (guiInstance.isNull() && !QCoreApplication::closingDown()) { guiInstance = new QThreadPool(); + // Limit max thread to avoid too many parallel threads. + // We are not optimized for much more than 4 or 8 threads. + if (guiInstance && guiInstance->maxThreadCount() > 4) + guiInstance->setMaxThreadCount(qBound(4, guiInstance->maxThreadCount() / 2, 8)); + } return guiInstance; } |
