feat(container): auto-tune JVM GC algorithm in setenv.sh based on available vCPUs#36259
feat(container): auto-tune JVM GC algorithm in setenv.sh based on available vCPUs#36259wezell wants to merge 1 commit into
Conversation
…36258) Select GC at container startup based on nproc output: - 1-3 vCPUs: G1GC + G1PeriodicGCInterval=10000 (returns memory to OS on idle) - 4+ vCPUs: -XX:+UseZGC (Java 25 defaults to GenerationalZGC; sub-ms pauses) SerialGC excluded — not appropriate for a long-running multi-threaded server. Base memory flags (MaxRAMPercentage, heap ratios, NIO buffer cap) unchanged. Set JAVA_OPTS_MEMORY before startup to bypass auto-selection entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
🤖 Bedrock Review —
|
|
Claude finished @wezell's task in 1m 22s —— View job Rollback Safety Analysis
Result: ✅ Safe to Roll Back The single changed file (
Notes:
|
|
|
||
| # Max Connection Lifetime 30m | ||
| export DB_MAX_WAIT=${DB_MAX_WAIT:-"1800000"} | ||
| export DB_MAX_CONNECTION_LIFETIME=${DB_MAX_CONNECTION_LIFETIME:-"1800000"} |
There was a problem hiding this comment.
I don't see any consumers of the new name
Summary
JAVA_OPTS_MEMORYGC config with CPU-aware auto-selection at container startupG1PeriodicGCInterval=10000to return memory to OS on idle-XX:+UseZGC(Java 25 GenerationalZGC by default; sub-millisecond pauses, scales with cores)Details
CPU detection uses
nprocwith/proc/cpuinfofallback; defaults to 2 if neither is available. Base memory flags (MaxRAMPercentage=72.0, heap free ratios, NIO buffer cap) are unchanged. SetJAVA_OPTS_MEMORYbefore startup to bypass auto-selection entirely.Follows the same cgroup-aware pattern already used by
JAVA_OPTS_DIRECT.Test plan
setenv: auto-GC: ...with detected vCPU countnprocreturning 1–3), confirmG1PeriodicGCIntervalappears in JVM flags (-XX:+PrintFlagsFinalorjcmd <pid> VM.flags)-XX:+UseZGC/ GenerationalZGC is activeJAVA_OPTS_MEMORY="-XX:MaxRAMPercentage=60.0"and confirm auto-tune block is skippedCloses #36258
🤖 Generated with Claude Code