Having used wrk
quite a bit to profile Hummingbird, here is a list of things I have found over time when using a Mac to profile.
- Don't allow your server to use all your cores. Limit the number of threads the
EventLoopGroup
triggers. If your server is using every resource on your Mac, then it is more susceptible to other processes affecting its performance. Xcode might start indexing, your mail app gets more mail, one of the many electron apps you are running does something. I've generally found limiting to 4 cores on an M1 gives you fairly stable performance. - Don't test with more than 128 connections. You will get read errors. This is due to the file descriptor limit applied to each process on macOS. As @johannesweiss mentioned earlier the default for this is 256. You can change this but it involves disabling the System Integrity Protection.
- There is some upper limit of requests it doesn't seem possible to pass (about 145k per second on my laptop). I have not worked out what this is yet. I don't know if this is some limitation from Hummingbird, NIO or something else completely.
- Do your profiling on a Linux box. It is the target platform. It doesn't have the connection limit macOS has. Other process won't affect performance so much. These days it so easy to get one up and running on a cloud provider, install swiftly and then swift and connect to it over s SSH connection in VSCode.