I’ve noticed some very slow performance in one of my plugins when connecting to remote resources, and traced it to
To reproduce the issue, I’ve written two minimal test apps, one in Objective-C calling into Cocoa directly, and one using JUCE. I used Apple’s Network Link Conditioner to emulate a fairly poor connection (5 Mb/s with 50ms latency), then ran 100 iterations of each “connect” operation and measured the average. The results are below.
The JUCE test:
Average “connect” time over 100 iterations: ~6 seconds
The Cocoa test:
Average “connect” time over 100 iterations: ~1 second
This correlates to comparisons with
curl from the command line, which gives similar results to the Cocoa test.
I have my deployment target set to 10.12, so JUCE is using
NSURLSession the same API as the Cocoa example.
What is the reason for this massive difference in performance?
Note: I get similar results regardless of whether I run the tests concurrently or sequentially.