Skip to content

feat: Set Go runtime hints for SDK sidecar#4569

Open
mnthe wants to merge 1 commit into
agones-dev:mainfrom
mnthe:feat/sdk-sidecar-runtime-limits
Open

feat: Set Go runtime hints for SDK sidecar#4569
mnthe wants to merge 1 commit into
agones-dev:mainfrom
mnthe:feat/sdk-sidecar-runtime-limits

Conversation

@mnthe
Copy link
Copy Markdown
Contributor

@mnthe mnthe commented May 15, 2026

/kind feature

What this PR does / Why we need it:

This PR sets Go runtime resource hints for the GameServer SDK
sidecar:

  • GOMAXPROCS=1
  • GOMEMLIMIT=<90% of sidecar memory request> when
    agones.image.sdk.memoryRequest is configured

The SDK sidecar is expected to be lightweight and should not need more than one vCPU. In pods without CPU limits, the Go runtime may otherwise size scheduler parallelism from host- visible CPU resources, which can be inefficient for the sidecar workload.

For memory, this derives the runtime memory hint from the configured sidecar memory request. If no sidecar memory request is configured, GOMEMLIMIT is not set.

This does not change Kubernetes CPU or memory requests or limits. It only provides runtime hints to the SDK sidecar process.

Which issue(s) this PR fixes:

Closes #4568

Special notes for your reviewer:

GOMAXPROCS is fixed at 1 because the SDK sidecar is not expected to need more than one vCPU, even when the CPU request is unset. If there are expected SDK sidecar workloads where using more than one vCPU is important, I can change this to derive GOMAXPROCS from the configured CPU request instead.

GOMEMLIMIT is set to 90% of the memory request to leave headroom for memory outside Go runtime-managed memory. The 90% ratio is a heuristic; if this does not leave enough headroom, I can adjust it to a more conservative value such as 80%.

The SDK sidecar is also expected to be lightweight in memory usage. However, in some Windows dedicated server deployments, the sidecar may be run in a Guaranteed QoS pod and can temporarily consume more memory than expected. For that case, this PR derives GOMEMLIMIT from the configured memory request so the Go runtime has a soft memory hint aligned with the scheduled sidecar resources.

Validation:

  • git diff --check
  • go test -mod=vendor ./pkg/gameservers -run TestControllerSidecarGoRuntimeResourceHints -count=1

@github-actions github-actions Bot added kind/feature New features for Agones size/M labels May 15, 2026
Limit SDK sidecar scheduler parallelism with GOMAXPROCS=1.

When a sidecar memory request is configured, derive GOMEMLIMIT from
90% of that request so Go-managed memory stays aligned with the
scheduled amount.

Signed-off-by: JungHun Kim <mnthe@pubg.com>
@markmandel
Copy link
Copy Markdown
Member

/gcbrun

Comment on lines +71 to +72
sidecarGoMaxProcs = "1"
sidecarGoMemLimitRequestPercentage = 90
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These seem like good defaults, but I wonder if this should be configurable, just in case. 🤔 WDYT/

@agones-bot
Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: b4c9e6ea-3e9c-4b44-93ce-a0be2c977c39

Status: FAILURE

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@markmandel
Copy link
Copy Markdown
Member

Is that a legit test failure? It looks like one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature New features for Agones size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Optimize SDK sidecar Go runtime defaults for unbounded Kubernetes pods

3 participants