Skip to content

8334617: -XX:+UseSerialGC sent to newly built JDK even if serialgc is disabled#31049

Open
tschatzl wants to merge 1 commit intoopenjdk:masterfrom
tschatzl:submit/8334617-allow-building-without-serialgc
Open

8334617: -XX:+UseSerialGC sent to newly built JDK even if serialgc is disabled#31049
tschatzl wants to merge 1 commit intoopenjdk:masterfrom
tschatzl:submit/8334617-allow-building-without-serialgc

Conversation

@tschatzl
Copy link
Copy Markdown
Contributor

@tschatzl tschatzl commented May 6, 2026

Hi all,

please review this change that allows building of the JDK without Serial GC enabled.

There were some hardcoded entries for -XX:+UseSerialGC in the makefiles, and one of the gtests is serial gc specific and needed to be moved. Noticed during tests with JEP 523: Make G1 the Default Garbage Collector in All Environments.

I opted to a different fix than suggested in the CR, instead of wholesale ignoring unrecognized options, only add serial gc to the relevant options if the feature is enabled in the build. The change seems small enough.

Tested manually with and without --with-jvm-features=-serialgc, both image building and running the test works in both cases (being skipped/not found if serial gc has not been enabled).

Other testing: gha

Thanks,
Thomas



Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issue

  • JDK-8334617: -XX:+UseSerialGC sent to newly built JDK even if serialgc is disabled (Bug - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/31049/head:pull/31049
$ git checkout pull/31049

Update a local copy of the PR:
$ git checkout pull/31049
$ git pull https://git.openjdk.org/jdk.git pull/31049/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 31049

View PR using the GUI difftool:
$ git pr show -t 31049

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/31049.diff

Using Webrev

Link to Webrev Comment

Hi all,

  please review this change that allows building of the JDK without Serial GC enabled.

There were some hardcoded entries for -XX:+UseSerialGC in the makefiles, and one of the gtests is serial gc specific and needed to be moved.

I opted to a different fix than suggested in the CR, instead of wholesale ignoring unrecognized options, only add serial gc to the options if the feature has been enabled.

Tested manually with and without `--with-jvm-features=-serialgc`, both image building and running the test works in both cases (being skipped/not found if serial gc has not been enabled).

Other testing: gha

Thanks,
  Thomas
@bridgekeeper
Copy link
Copy Markdown

bridgekeeper Bot commented May 6, 2026

👋 Welcome back tschatzl! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link
Copy Markdown

openjdk Bot commented May 6, 2026

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk Bot changed the title 8334617 8334617: -XX:+UseSerialGC sent to newly built JDK even if serialgc is disabled May 6, 2026
@openjdk openjdk Bot added build build-dev@openjdk.org hotspot-gc hotspot-gc-dev@openjdk.org labels May 6, 2026
@openjdk
Copy link
Copy Markdown

openjdk Bot commented May 6, 2026

@tschatzl The following labels will be automatically applied to this pull request:

  • build
  • hotspot-gc

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk
Copy link
Copy Markdown

openjdk Bot commented May 6, 2026

The total number of required reviews for this PR has been set to 2 based on the presence of this label: hotspot-gc. This can be overridden with the /reviewers command.

Comment thread make/autoconf/boot-jdk.m4

# Use serial gc for small short lived tools if possible
UTIL_ADD_JVM_ARG_IF_OK([-XX:+UseSerialGC],boot_jdk_jvmargs_small,[$JAVA])
UTIL_ADD_JVM_GC_ARG_IF_OK([-XX:+UseSerialGC],boot_jdk_jvmargs_small,[$JAVA],[serialgc])
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.

Something is off here. This builds up boot_jdk_jvmargs, which has no relationship to the JVM feature flags enabled currently in the build. That is, if you have a boot JDK that does not carry Serial, it would still fail.

There is a block below, saying:

  # Don't presuppose SerialGC is present in the buildjdk. Also, we cannot test
  # the buildjdk, but on the other hand we know what it will support.

Which seems to say that we just "know" Serial would be there. But that is a flimsy precondition. So maybe we should "just" stop opting into Serial GC everywhere, and rely on default collector choice.

Copy link
Copy Markdown
Member

@shipilev shipilev May 6, 2026

Choose a reason for hiding this comment

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

Actually, I believe not using Serial for small tools is completely in line with the intent of JEP 523, so it would be a proverbial dog-fooding to rely on G1 for small tools. If G1 is significantly slower in scenario where Serial used to be a better choice, OpenJDK developers should be the first to suffer :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In my somewhat limited local tests (for jep 523), the difference of using g1 for everything is <1% non-significant for a full slowdebug rebuild (in all metrics, i.e. user/sys/cpu/total time, 5 runs, alpha=0.05), i.e. a make images.

I am fine with just removing the -XX:+SerialGC optimization. I did notice that comment, and agree with you, but did not want to do extensive build perf testing.

See also https://bugs.openjdk.org/browse/JDK-8359802?focusedId=14802646&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14802646 on a different machine.

If nobody objects I'll remove this optimization after some more testing.

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.

If default GC choice and sizing is good enough, I'm all for dropping the explicit flags. Back when we set serialgc, I believe the difference was quite significant. If you can show that the difference is negligible, then please remove it.

If the difference is still relevant, then the correct fix is to only modify the BUILD_JAVA flags, and then only if we are using the just built JDK as BUILD_JDK. Looking at the code, as Alexey pointed out, we aren't even setting serialgc in the BUILD_JAVA_FLAGS_SMALL. We are however setting JAVA_TOOL_FLAGS_SMALL based on JAVA_FLAGS_SMALL, and we then use JAVA_TOOL_FLAGS_SMALL with JMOD, which is run from the BUILD_JDK. That is a bug. We need a separate BUILD_JAVA_TOOL_FLAGS_SMALL. Is it the jmod command that failed when you disabled serialgc, or something else?

@openjdk openjdk Bot added the rfr Pull request is ready for review label May 6, 2026
@mlbridge
Copy link
Copy Markdown

mlbridge Bot commented May 6, 2026

Webrevs

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

Labels

build build-dev@openjdk.org hotspot-gc hotspot-gc-dev@openjdk.org rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

3 participants