You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR removes a major send-path bottleneck by ensuring we don’t hold the hot sendMu while doing network writes. Flush() now quickly snapshots and clears the queued batch, then performs the expensive enc.Encode(...) write outside the queue lock. This dramatically reduces mutex contention under load (especially when the write path stalls/backpressures), improving throughput and reducing latency spikes.
Benchmarks show ~32%–99% throughput improvements, depending on workload: ~32% for WritePacket() under simulated slow writes, and up to ~99% for raw Write() when the write path stalls/backpressures.
Also fixes a bug in WritePacket which would appear when ConvertFromLatest returns multiple packets, it was reusing the same buffer across all packets.
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! The changes, although not pretty, seem reasonable. I do wonder what sort of difference we would see in real-world applications since Flush() isn't called very often normally. If you do have any data on that, please feel free to post.
Thanks for the PR! The changes, although not pretty, seem reasonable. I do wonder what sort of difference we would see in real-world applications since Flush() isn't called very often normally. If you do have any data on that, please feel free to post.
Thanks for the PR! The changes, although not pretty, seem reasonable. I do wonder what sort of difference we would see in real-world applications since Flush() isn't called very often normally. If you do have any data on that, please feel free to post.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This PR removes a major send-path bottleneck by ensuring we don’t hold the hot sendMu while doing network writes. Flush() now quickly snapshots and clears the queued batch, then performs the expensive enc.Encode(...) write outside the queue lock. This dramatically reduces mutex contention under load (especially when the write path stalls/backpressures), improving throughput and reducing latency spikes.
Benchmarks show ~32%–99% throughput improvements, depending on workload: ~32% for WritePacket() under simulated slow writes, and up to ~99% for raw Write() when the write path stalls/backpressures.
Also fixes a bug in WritePacket which would appear when ConvertFromLatest returns multiple packets, it was reusing the same buffer across all packets.
Benchmarks
Results
Code