Performance: Increase number of GCD read queues #235
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Increases the number of GCD serial read queues to 4 (on OSX) or 8 (Linux, when compiled with
GCD_ASYNCH
).Motivation and Context
This increases Kitura throughput by (ballpark) 5% (OSX) / 30% (Linux). The precise benefit depends on the nature of the workload (whether it is predominantly receive, send or 'think time' limited) and how many physical threads the system has.
Linux sees a universal improvement from increasing the number of queues, and in fact benefits even more from a higher number, but there are diminishing returns which are probably not worth the corresponding increase in memory footprint.
Most workloads improve on a 4-core Macbook with this change. The smaller Mac Mini shows slight regression from the change, but I would expect that 4+ cores is a more likely environment where performance is important. I do not have access to Mac hardware with >4 cores.
Linux (Ubuntu 16.04, Swift 4) - 4 cores, 8 threads
Note that the charts below show experiments with number of both GCD and Epoll queues. Only the GCD (blue) results are relevant for this PR, as I am not proposing a change for Epoll.

OSX (Sierra, Swift 4) - Mac Mini 2-core / Macbook Pro 4-core
Note that the colours mean different things to the Linux charts above: the graphs below show results on a 2-core Mac Mini (blue) and 4-core Macbook (orange).

Full data (internal link): https://ibm.ent.box.com/file/211761963959
How Has This Been Tested?
As well as the performance tests above, I have run the Kitura-net tests locally on Linux and OSX and they pass.
Checklist: