This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -1112,6 +1112,12 @@ extern bool _dispatch_kevent_workqueue_enabled;
1112
1112
#include " inline_internal.h"
1113
1113
#include " firehose/firehose_internal.h"
1114
1114
1115
- __END_DECLS
1115
+ #if !HAVE_PTHREAD_WORKQUEUE_KEVENT
1116
+ // copied from https://opensource.apple.com/source/libpthread/libpthread-301.50.1/kern/workqueue_internal.h.auto.html
1117
+ #define WORKQUEUE_MAXTHREADS 512
1118
+ #define WORKQUEUE_CONSTRAINED_MAXTHREADS (WORKQUEUE_MAXTHREADS >> 3 )
1119
+ #define WORKQUEUE_CONSTRAINED_FACTOR 5
1120
+ #endif
1116
1121
1122
+ __END_DECLS
1117
1123
#endif /* __DISPATCH_INTERNAL__ */
Original file line number Diff line number Diff line change @@ -6168,10 +6168,19 @@ _dispatch_root_queue_init_pthread_pool(dispatch_queue_global_t dq,
6168
6168
int pool_size , dispatch_priority_t pri )
6169
6169
{
6170
6170
dispatch_pthread_root_queue_context_t pqc = dq -> do_ctxt ;
6171
+ int32_t default_pool_size = 0 ;
6172
+ char * default_pool_size_env = getenv ("LIBDISPATCH_DEFAULT_THREAD_POOL_SIZE" );
6173
+ if (default_pool_size_env ) {
6174
+ default_pool_size = (int32_t ) atoi (default_pool_size_env );
6175
+ }
6176
+ if (!default_pool_size ) {
6177
+ default_pool_size = (int32_t ) MAX (dispatch_hw_config (active_cpus ) * 5 , WORKQUEUE_CONSTRAINED_MAXTHREADS );
6178
+ }
6171
6179
int thread_pool_size = DISPATCH_WORKQ_MAX_PTHREAD_COUNT ;
6172
6180
if (!(pri & DISPATCH_PRIORITY_FLAG_OVERCOMMIT )) {
6173
- thread_pool_size = ( int32_t ) dispatch_hw_config ( active_cpus ) ;
6181
+ thread_pool_size = default_pool_size ;
6174
6182
}
6183
+
6175
6184
if (pool_size && pool_size < thread_pool_size ) thread_pool_size = pool_size ;
6176
6185
dq -> dgq_thread_pool_size = thread_pool_size ;
6177
6186
qos_class_t cls = _dispatch_qos_to_qos_class (_dispatch_priority_qos (pri ) ?:
You can’t perform that action at this time.
0 commit comments