Conversation
…erformance regression In gnet v2, AsyncWrite is designed to be called from outside the event loop (e.g., in separate goroutines) and has additional overhead. Using AsyncWrite inside OnTraffic (an event handler) causes significant performance degradation. Changed all AsyncWrite calls in OnTraffic to synchronous Write calls which are optimized for use within event handlers. This should restore the performance to levels similar to gnet v1.0. Performance impact: expected to restore ~76% performance loss (v0.1.0: 2,414,510 req/s -> main: 563,386 req/s) Signed-off-by: BlockCraftsman <167502426+BlockCraftsman@users.noreply.github.com>
Instead of calling Write() for each individual command response, collect all responses and use Writev() for a single batch write operation. This matches the behavior of gnet v1.0 where all responses were accumulated in the out []byte return value and written in a single operation. Expected to significantly improve performance by reducing system call overhead. Performance impact: - Reduces number of write syscalls from N to 1 per OnTraffic invocation - Where N = number of commands in the current frame Signed-off-by: BlockCraftsman <167502426+BlockCraftsman@users.noreply.github.com>
Reverted to the v0.1.0 approach where: 1. Use a single 'out' []byte variable that accumulates all command responses 2. Pass 'out' to each handler and receive the accumulated result back 3. Write all responses in a single Write() call at the end This matches the exact behavior of gnet v1.0 where the React method returned an accumulated []byte buffer that was written in one operation. The previous Writev approach allocated separate []byte for each response, causing unnecessary memory allocations and system call overhead. This change should restore performance to levels comparable to v0.1.0. Signed-off-by: BlockCraftsman <167502426+BlockCraftsman@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.