From 5a0a54a71565430dd8e8b628f1d1453deef42b5f Mon Sep 17 00:00:00 2001 From: hc-github-team-nomad-core <82989552+hc-github-team-nomad-core@users.noreply.github.com> Date: Mon, 18 Sep 2023 08:36:33 -0500 Subject: [PATCH] backport of commit 5bd8b89c19c71e19ad0a1abc9b35de9abb4d2cc3 (#18525) Co-authored-by: Tim Gross --- .changelog/18524.txt | 3 +++ helper/bufconndialer/bufconndialer.go | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changelog/18524.txt diff --git a/.changelog/18524.txt b/.changelog/18524.txt new file mode 100644 index 000000000..f2f3a7d6b --- /dev/null +++ b/.changelog/18524.txt @@ -0,0 +1,3 @@ +```release-note:improvement +template: reduce memory usage associated with communicating with the Nomad API +``` diff --git a/helper/bufconndialer/bufconndialer.go b/helper/bufconndialer/bufconndialer.go index ea5fe40f7..5d9b5512a 100644 --- a/helper/bufconndialer/bufconndialer.go +++ b/helper/bufconndialer/bufconndialer.go @@ -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} }