mirror of
https://github.com/apple/swift-nio-extras
synced 2026-11-24 04:37:58 +00:00
Fix a copy on write issue in QuiescingHelper that led to significant performance problems when the number of channels became large, or connection churn. ### Motivation: When using QuiescingHelper, every channel holds onto a reference to ChannelCollector, which leads to copy on write behaviour for `openChannels[]`. This has performance issues when a large number of channels are open (e.g. 25k channels can be hundreds of KB), and every time a channel is opened, or closed this is copied. As accepting channels happens on a single NIO thread, this work is all done on that thread, and can lead to saturation, and no more channels being accepted. ### Modifications: Move the state into a non copyable LifecycleStateMachine, to avoid the copies. ### Result: Overhead from ChannelCollector disappears (as seen in traces from http://github.com/apple/swift-profile-recorder).