-
Notifications
You must be signed in to change notification settings - Fork 697
Add NIOAsyncChannel benchmark
#2536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| @@ -0,0 +1,3 @@ | |||
| { | |||
| "mallocCountTotal" : 5636901 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty bad since we are allocating for every single enqueue now. I will raise one or more follow up PRs to reduce this significantly. I was able to remove all allocations except one in the runtime.
# Motivation We want to benchmark our `NIOAsyncChannel` to see how it compares to the synchronous implementation with `ChannelHandler`s # Modification This PR adds a new `TCPEchoAsyncChannel` benchmark that mimics the `TCPEcho` benchmark but uses our new async bridges. Since Swift Concurrency, is normally using a global executor this benchmark would have quite high variation. To reduce this variant I introduced code to hook the global executor and set an `EventLoop` as the executor. In the future, if we get task executors we can change the code to us them instead. # Result New baseline benchmarks for the `NIOAsyncChannel`.
8edf20d to
0cb17ae
Compare
| @@ -13,6 +13,9 @@ | |||
| //===----------------------------------------------------------------------===// | |||
|
|
|||
| import Benchmark | |||
| import NIOPosix | |||
|
|
|||
| private let eventLoop = MultiThreadedEventLoopGroup(numberOfThreads: 1).next() | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just grab the next() from the shared singleton?
| } | ||
| } | ||
|
|
||
| let bufferSize = 10000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: naming threw me for a sec as I expected a buffer, not a ByteBuffer. something like messageSize is a more obvious
|
Thanks for the review. Going to address them in my next PR that I am going to open in a few minutes. |
Motivation
We want to benchmark our
NIOAsyncChannelto see how it compares to the synchronous implementation withChannelHandlersModification
This PR adds a new
TCPEchoAsyncChannelbenchmark that mimics theTCPEchobenchmark but uses our new async bridges. Since Swift Concurrency, is normally using a global executor this benchmark would have quite high variation. To reduce this variant I introduced code to hook the global executor and set anEventLoopas the executor. In the future, if we get task executors we can change the code to us them instead.Result
New baseline benchmarks for the
NIOAsyncChannel.