Skip to content

feat(jre): add opt-in memory_calculator.xms_equals_xmx (#1377) - #1579

Draft
stokpop wants to merge 1 commit into
cloudfoundry:mainfrom
stokpop:1377-xms-equals-xmx
Draft

stokpop wants to merge 1 commit into
cloudfoundry:mainfrom
stokpop:1377-xms-equals-xmx

Conversation

@stokpop

@stokpop stokpop commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Adds an opt-in xms_equals_xmx option to the memory_calculator mapping, for example JBP_CONFIG_OPEN_JDK_JRE: '{memory_calculator: {xms_equals_xmx: true}}'. It makes the memory calculator set -Xms equal to -Xmx through the new --xms-equals-xmx flag from cloudfoundry/java-buildpack-memory-calculator#55.

Disabled by default, and the flag is only passed when enabled. It works for every JRE through its own JBP_CONFIG_*_JRE variable. There is no MEMORY_CALCULATOR_* env var for it, same as class_count. Happy to add one if you prefer.

This stays a draft until a calculator release with the flag is in manifest.yml. The released 4.2.0 rejects the flag (unknown flag: --xms-equals-xmx, exit 2) and the start command stops there, so an app that enables the option would not start. Apps that do not set the option are not affected.

What I checked:

  • Unit tests for the command (default off, true, false, another JRE, combined with other settings, no unknown-field warning). Two mutants (flag never passed, flag always passed) are caught.
  • The generated start command against a real calculator built from main: -Xmx and -Xms equal; explicit -Xms is respected; -Xms larger than -Xmx fails with the calculator error.
  • Two Docker integration tests on a Spring Boot app, reading /input-arguments: with the option, -Xms equals -Xmx; by default, no -Xms. Both pass with a calculator built from main. The first fails against the released 4.2.0, and the container log shows unknown flag: --xms-equals-xmx.

Docs: new "Initial Heap" section in docs/jre-open_jdk_jre.md. In docs/IMPLEMENTING_JRES.md I added the option and removed a wrong -Xms512M from the sample output, because the calculator did not emit one before.

Refs #1377

Forward --xms-equals-xmx to the memory calculator when
JBP_CONFIG_<JRE>_JRE sets memory_calculator.xms_equals_xmx: true.
Disabled by default; the flag is only passed when enabled, because
calculator releases before the one that adds it exit with "unknown flag".

Refs cloudfoundry#1377

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The packaged memory calculator 4.2.0 rejects --xms-equals-xmx, causing startup to fail before the JVM launches when the option is enabled.

1 open issue
What changed in this PR

Adds an opt-in initial-heap setting to the shared JRE memory calculator integration, addressing the equal-heap use case from #1377 while leaving default behavior unchanged.

Changes:

  • Reads memory_calculator.xms_equals_xmx from JRE-specific configuration and forwards --xms-equals-xmx when enabled.
  • Adds unit and Spring Boot integration tests for enabled and default behavior.
  • Documents the option, explicit -Xms precedence, and memory tradeoffs; corrects the sample calculator output.
File Description
src/​java/​jres/​memory_calculator.go Loads the option, forwards the flag, and logs enablement.
src/​java/​jres/​memory_calculator_issues_test.go Tests opt-in forwarding, defaults, and configuration compatibility.
src/​integration/​spring_boot_test.go Checks JVM heap arguments with and without the option.
docs/​jre-open_jdk_jre.md Explains initial-heap configuration and operational tradeoffs.
docs/​IMPLEMENTING_JRES.md Documents the shared option and corrects sample output.

Review effort: Balanced

}

if m.xmsEqualsXmx {
args = append(args, "--xms-equals-xmx")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants