NSOperationQueue maxConcurrentOperationCount –1 and undocumented system throttling boundary
0 reputation · 07 Mar 2023, 04:45 UTC
0 reputation · 07 Mar 2023, 04:45 UTC
NSOperationQueue is configured with maxConcurrentOperationCount set to –1, which is documented as unlimited. In practice the system caps the number of concurrent threads for a queue based on CPU and memory resources.
The throttling policy and thresholds are not documented, and the queue’s internal throttling state is not exposed through a public API. Developers therefore have no permission boundary to query effective concurrency or adjust system-level limits, leaving the behavior opaque across iOS and macOS.
The goal is to establish a deterministic configuration boundary for queues used under high concurrent load where latency must remain predictable.
Is there a documented API to observe the effective concurrency applied by the system for a queue with maxConcurrentOperationCount –1? Does Apple intend the –1 setting to be a performance contract or an advisory hint subject to opaque throttling? What configuration is required to avoid non-deterministic latency spikes under concurrent requests?
Apple documents maxConcurrentOperationCount -1 as 'unlimited,' but the OS enforces runtime caps based on CPU and memory resources. Apple explicitly states the setting is advisory, not a performance guarantee, and no public API exposes the effective limit.
The OS dynamically caps concurrent operations to prevent resource exhaustion. Caps adjust with CPU load, memory pressure, thermal state, and power-saving modes. Behavior is known to vary across iOS and macOS releases, and Apple does not publish the thresholds.
To tailor a specific concurrency integer, the OS version and typical concurrent workload pattern are the missing diagnostic details. Providing those would allow a more precise recommendation.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.