From 3819b9d57e8e566e3622fa9dd89887aa64483066 Mon Sep 17 00:00:00 2001 From: schm1dtmac Date: Sat, 20 Dec 2025 22:13:46 +0000 Subject: [PATCH] [macOS] Force max pthread priority, fix throttling --- Utilities/Thread.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 9b6d250c19..810b8fd7c5 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -2165,10 +2165,17 @@ void thread_base::start() ensure(m_thread); ensure(::ResumeThread(reinterpret_cast(+m_thread)) != static_cast(-1)); #elif defined(__APPLE__) - pthread_attr_t stack_size_attr; - pthread_attr_init(&stack_size_attr); - pthread_attr_setstacksize(&stack_size_attr, 0x800000); - ensure(pthread_create(reinterpret_cast(&m_thread.raw()), &stack_size_attr, entry_point, this) == 0); + pthread_attr_t attrs; + struct sched_param sp; + memset(&sp, 0, sizeof(struct sched_param)); + sp.sched_priority=99; + pthread_attr_init(&attrs); + pthread_attr_setstacksize(&attrs, 0x800000); + + pthread_attr_set_qos_class_np(&attrs, QOS_CLASS_USER_INTERACTIVE, 0); + pthread_attr_setschedpolicy(&attrs, SCHED_RR); + pthread_attr_setschedparam(&attrs, &sp); + ensure(pthread_create(reinterpret_cast(&m_thread.raw()), &attrs, entry_point, this) == 0); #else ensure(pthread_create(reinterpret_cast(&m_thread.raw()), nullptr, entry_point, this) == 0); #endif