Skip to content

cvm/overlay: Fix gc/g1 StringDedup tests#140

Open
duanyangjing wants to merge 2 commits into
bytedance:jdk17u-target8from
duanyangjing:aime/fix-string-dedup
Open

cvm/overlay: Fix gc/g1 StringDedup tests#140
duanyangjing wants to merge 2 commits into
bytedance:jdk17u-target8from
duanyangjing:aime/fix-string-dedup

Conversation

@duanyangjing

Copy link
Copy Markdown
Collaborator

Adapted gc/g1 StringDedup tests for JDK 17 compatibility.

Key changes:

Replaced JDK 8 style logging flags with JDK 17 Unified Logging (-Xlog:gc+stringdedup=debug).
Adapted expected error messages and output patterns to match JDK 17 behavior.
One deprecated test case (SurvivorAlignmentInBytes related) has been excluded and recorded as per the policy.

Adapt gc/g1 StringDeduplication tests for JDK17 hotspot, using the
original JDK 8 implementation as baseline.

TestStringDeduplicationTools.java:
- Replace JDK 8 legacy GC log flags (PrintGCDetails,
  PrintStringDeduplicationStatistics) with JDK 17 Unified Logging
  (-Xlog:gc*,stringdedup*)
- Update GC output assertions to match the JDK 17 Unified Logging
  format
- Update StringDeduplicationAgeThreshold error message assertion to
  match JDK17 hotspot behavior
- Adapt InternedTest: Replace the JDK 8 implementation with JDK 17
  logic which verifies that interned strings are always deduplicated
  when being interned, and never after being interned
- Update testPrintOptions: Use -Xlog:gc*,stringdedup* (info) to verify
  concurrent deduplication log presence instead of using JDK 8 specific
  flags

Keep TestStringDeduplicationTableRehash.java excluded since JDK17
hotspot removed the string deduplication table rehash mechanism.

@luchsh luchsh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

after applying this patch, the modified test will no longer be suitable for a jdk8 build, is that a decided project specification?

Comment thread cvm.mk
$(call overlay_single,jdk8u,hotspot/test/gc/arguments/TestUseCompressedOopsErgoTools.java, $(JDK8_SRCROOT))
$(call overlay_single,jdk8u,hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java, $(JDK8_SRCROOT))
$(call overlay_single,jdk8u,hotspot/test/gc/startup_warnings/TestDefaultMaxRAMFraction.java, $(JDK8_SRCROOT))
$(call overlay_single,jdk8u,hotspot/test/gc/g1/TestStringDeduplicationTools.java, $(JDK8_SRCROOT))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

there seems to be many tests to be processed, can we make a loop to do that recursively from overlay/jdk8u to $(JDK8_SRCROOT)?


private static boolean waitForDeduplication(String s1, String s2) {
boolean first = true;
int timeout = 10000; // 10sec in ms

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

put the unit in var name will make it self-explainable

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This line is ported from jdk17

System.out.println("End: InternedTest");
}

private static void checkNotDeduplicated(Object value1, Object value2) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

check what?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This function is ported from jdk17

private static void checkNotDeduplicated(Object value1, Object value2) {

// Force internedString to be inspected for deduplication.
// Because it was interned it should be queued up for
// dedup, even though it hasn't reached the age threshold.
doYoungGc(1);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the original test does not seem to have this gc call, why did you add it?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This logic is ported from jdk17

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.

3 participants