首页 > 解决方案 > Metal 如何创建工作线程?

问题描述

当我在程序中使用 Metal API 进行渲染时,我在 Time Profiler 中看到了几个工作线程:

8.00 ms   15.0% 0 s      _dispatch_worker_thread2  0xcf325
8.00 ms   15.0% 0 s       start_wqthread
8.00 ms   15.0% 0 s        _pthread_wqthread
7.00 ms   13.2% 0 s         _dispatch_workloop_worker_thread
6.00 ms   11.3% 0 s          _dispatch_lane_invoke
6.00 ms   11.3% 0 s           _dispatch_lane_serial_drain
6.00 ms   11.3% 0 s            _dispatch_source_invoke
6.00 ms   11.3% 0 s             _dispatch_continuation_pop
6.00 ms   11.3% 0 s              _dispatch_client_callout
5.00 ms    9.4% 0 s               -[_MTLCommandQueue _submitAvailableCommandBuffers]
1.00 ms    1.8% 0 s               dispatch_mig_server
1.00 ms    1.8% 0 s          _dispatch_event_loop_merge
1.00 ms    1.8% 0 s         _dispatch_kevent_worker_thread
6.00 ms   11.3% 0 s      _dispatch_workloop_worker_thread  0xcf31d
6.00 ms   11.3% 0 s       start_wqthread
6.00 ms   11.3% 0 s        _pthread_wqthread
6.00 ms   11.3% 1.00 ms         _dispatch_workloop_worker_thread
5.00 ms    9.4% 0 s          _dispatch_lane_invoke
5.00 ms    9.4% 0 s           _dispatch_lane_serial_drain
5.00 ms    9.4% 0 s            _dispatch_source_invoke
5.00 ms    9.4% 0 s             _dispatch_continuation_pop
5.00 ms    9.4% 0 s              _dispatch_client_callout
4.00 ms    7.5% 0 s               -[_MTLCommandQueue _submitAvailableCommandBuffers]
1.00 ms    1.8% 0 s               invocation function for block in CA::Context::client_port()
6.00 ms   11.3% 0 s      _dispatch_workloop_worker_thread  0xcf31c
6.00 ms   11.3% 0 s       start_wqthread
6.00 ms   11.3% 0 s        _pthread_wqthread
6.00 ms   11.3% 1.00 ms         _dispatch_workloop_worker_thread
5.00 ms    9.4% 0 s          _dispatch_lane_invoke
5.00 ms    9.4% 0 s           _dispatch_lane_serial_drain
5.00 ms    9.4% 0 s            _dispatch_source_invoke
5.00 ms    9.4% 0 s             _dispatch_continuation_pop
5.00 ms    9.4% 0 s              _dispatch_client_callout
3.00 ms    5.6% 0 s               -[_MTLCommandQueue _submitAvailableCommandBuffers]
2.00 ms    3.7% 0 s               dispatch_mig_server

是否有可能知道为什么 Metal 会创建多个工作线程?

标签: macosperformancemetal

解决方案


推荐阅读