Merged
Conversation
conn.encodeBuf is retained to encode outgoing request packets. conn.m is held for the entire write sequence so serialized access is guaranteed. This shaves an allocation. Before: ``` BenchmarkRoundTrip/Plain/1KB-10 329035 3706 ns/op 276.34 MB/s 1627 B/op 6 allocs/op BenchmarkRoundTrip/Plain/64KB-10 128247 9145 ns/op 7166.00 MB/s 74212 B/op 6 allocs/op BenchmarkRoundTrip/Plain/1MB-10 22280 53276 ns/op 19682.07 MB/s 1057258 B/op 6 allocs/op BenchmarkRoundTrip/Encrypted/1KB-10 241368 5028 ns/op 203.67 MB/s 3554 B/op 7 allocs/op BenchmarkRoundTrip/Encrypted/64KB-10 39223 30939 ns/op 2118.22 MB/s 164387 B/op 7 allocs/op BenchmarkRoundTrip/Encrypted/1MB-10 3859 306180 ns/op 3424.71 MB/s 2377340 B/op 7 allocs/op ``` After: ``` BenchmarkRoundTrip/Plain/1KB-10 286184 3561 ns/op 287.58 MB/s 1500 B/op 5 allocs/op BenchmarkRoundTrip/Plain/64KB-10 129012 9022 ns/op 7264.18 MB/s 74084 B/op 5 allocs/op BenchmarkRoundTrip/Plain/1MB-10 22854 52175 ns/op 20097.33 MB/s 1057221 B/op 5 allocs/op BenchmarkRoundTrip/Encrypted/1KB-10 240336 4948 ns/op 206.95 MB/s 3426 B/op 6 allocs/op BenchmarkRoundTrip/Encrypted/64KB-10 39441 30362 ns/op 2158.48 MB/s 164319 B/op 6 allocs/op BenchmarkRoundTrip/Encrypted/1MB-10 3963 307307 ns/op 3412.14 MB/s 2376662 B/op 6 allocs/op ``` Co-Authored-By: Claude Opus 4.6 <[email protected]>
This is a somewhat defensive commit but several fields in the SMB packet header rely on the implicit zeroing provided by Go's make() builtin. We zero the memory here defensively since e.g., nonce sizes may change from one packet to the next.
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.
Reuse request encoding buffer across sends
conn.encodeBuf is retained to encode outgoing request packets.
conn.m is held for the entire write sequence so serialized
access is guaranteed.
This shaves an allocation.
Before:
After: