From 39564261b213b22a7e170baf4528d125260b5436 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 17 Jan 2025 09:40:17 -0800 Subject: [PATCH] QThread/Linux: disable the filling in of the trivial cpuset variable We don't need it and it just makes the code slower with a large array. Change-Id: I06dfa436309bfd249c06fffddb4cec658cf356a9 Reviewed-by: Ahmad Samir Reviewed-by: Marc Mutz --- src/corelib/thread/qthread_unix.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index f8bf4ba63c9..0a907511d80 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -489,6 +489,11 @@ Qt::HANDLE QThread::currentThreadIdImpl() noexcept int QThreadPrivate::idealThreadCount = 1; #endif +#if QT_CONFIG(trivial_auto_var_init_pattern) && defined(Q_CC_GNU_ONLY) +// Don't pre-fill the automatic-storage arrays used in this function +// (important for the FreeBSD & Linux code using a VLA). +__attribute__((optimize("trivial-auto-var-init=uninitialized"))) +#endif int QThread::idealThreadCount() noexcept { int cores = 1;