backport of commit 5bd8b89c19c71e19ad0a1abc9b35de9abb4d2cc3 (#18525)

Co-authored-by: Tim Gross <tgross@hashicorp.com>
This commit is contained in:
hc-github-team-nomad-core 2023-09-18 08:36:33 -05:00 committed by GitHub
parent 27f53350ff
commit 5a0a54a715
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

3
.changelog/18524.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
template: reduce memory usage associated with communicating with the Nomad API
```

View File

@ -24,7 +24,10 @@ type BufConnWrapper struct {
// New returns a new BufConnWrapper with a new bufconn.Listener. The wrapper
// provides a dialer for creating connections to the listener.
func New() (net.Listener, *BufConnWrapper) {
ln := bufconn.Listen(1024 * 1024)
// this buffer is sized to accept a maximum-sized Nomad Variable payload
// (64k) with plenty of room to spare for the metadata and envelope, in a
// single read
ln := bufconn.Listen(1024 * 100)
return ln, &BufConnWrapper{listener: ln}
}