-
Notifications
You must be signed in to change notification settings - Fork 316
Slice conn with faster write and faster read #54
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
Comments
Also see golang/go#18152 (comment) I don't think the writer allocation for every write is a big deal. |
The major issue I see with the writer is you have to close it so every data msg greater than the buffer size of 4096 bytes will be sent with three writes on the conn instead of two. |
I think the move is to remove the allocations altogether and just use a value type on the |
That definitely removes the need for the |
Definitely should benchmark this at some point with big payloads. |
So I benched this and it turns out there is no latency difference but the extra syscall adds 5000ns which is 5µs which isn't really that much at all so I don't think its a big deal. Can revisit if someone complains about performance but this isn't really going to show up if you're writing messages larger than 4096 bytes and I can always increase the buffer size to something like 32kb which would be good enough for pretty much everyone. I don't want to add a special case API unless absolutely necessary. |
Should we add a code path for fast reads and writes without allocating a reader or writer?
like:
Would actually be a wrapper around the Conn like JSONConn though.
The text was updated successfully, but these errors were encountered: