apple / swift-nio

Event-driven network application framework for high performance protocol servers & clients, non-blocking.
https://swiftpackageindex.com/apple/swift-nio/documentation
Apache License 2.0
8k stars 652 forks source link

Performance ideas/roadmap #2844

Open lmcd opened 3 months ago

lmcd commented 3 months ago

I see often in benchmarks that SwiftNIO seems to perform worst than most other things out there. I expect this will probably get better over time.

It would be very useful for me and other advocates of swift-nio to have a write-up somewhere in the repo/wiki of the current state of play, performance penalties etc, some potential strategies to overcome these challenges, future Swift features that may improve things, how things like Io_uring could change the performance picture, what impact a full transition to Swift Concurrency might have etc.

I occasionally see threads like these on the Swift forums and find them very detailed and insightful. Things like this are beyond my usual level of expertise, so I think it'd be useful for someone with this information to present it for others to see.

Just a thought! 🙂

Lukasa commented 3 months ago

This is not a bad idea.

For what it's worth, SwiftNIO's perceived performance issues are not really reflective of where it's at. Instead, they're reflective of the size of the relative communities. Producing a good benchmark result is less about the framework and much more about tuning to the benchmark. NIO's defaults are designed to make it safe, not to make it fast, and so without some work to configure it NIO doesn't necessarily perform to its best.

But even then, the reality is that NIO is faster than essentially anyone in the community needs it to be. My view is that performance is not NIO's problem: actually, we could probably burn some performance at the cost of ergonomics.

Lukasa commented 3 months ago

A very useful thing community members could do, actually, is to write implementations of particular benchmarks and propose them for review here, or inclusion as examples in swift-nio-examples. This would allow for community collaboration on those benchmarks, which can help with turning around that benchmark perception.

lmcd commented 3 months ago

But even then, the reality is that NIO is faster than essentially anyone in the community needs it to be.

We're trying to push many Gbps through it 🙂 As in large, concurrent file transfer operations. We're not hitting any walls yet, but may eventually turn our focus to throughput as we scale.

Lukasa commented 3 months ago

That should be no problem whatsoever. When you do start hitting some bottlenecks, let us know.