Skip to content
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

perf: round encoder buffer size to nearest sizeclasses #416

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions encoder/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type Encoder struct {

mesgDef proto.MessageDefinition // Temporary message definition to reduce alloc.

// Dynamic-sized buffer for encoding, starting at 1537 bytes (the maximum size of Message Definition).
// Dynamic-sized buffer for encoding, starting at 1536 bytes (see PR #415 and #416 for details).
// It starts small but grows as needed and may only grow when using Message's MarshalAppend.
buf []byte
}
Expand Down Expand Up @@ -190,7 +190,7 @@ func New(w io.Writer, opts ...Option) *Encoder {
crc16: crc16.New(nil),
protocolValidator: new(proto.Validator),
localMesgNumLRU: new(lru),
buf: make([]byte, 0, proto.MaxBytesPerMessageDefinition),
buf: make([]byte, 0, 1536),
}
e.Reset(w, opts...)
return e
Expand Down