JDK-8078669 : G1 applies SurvivorAlignmentInBytes to both survivor and old gen
  • Type: Bug
  • Component: hotspot
  • Sub-Component: gc
  • Affected Version: 8u60,9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-04-27
  • Updated: 2015-09-10
  • Resolved: 2015-06-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b72Fixed
Related Reports
Relates :  
Relates :  
Description
The test test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java on Solaris x64 and Windows x64 fails with 8u60b09 and 9.

The problem is that since JDK-8060025 the survivor alignment is used independently of target generation.

Tests to reproduce:

1. Take 8u60b09 or above 
2. run jtreg -nr -va -vmoptions:' -XX:+UseG1GC ' hotspot/test/gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java 
3. Observe error: Actual memory usage should not deviate from expected for more then 682456 

E.g.
For 8u60b08 we could see: 
Verifying memory usage in space: TENURED 
Allocated objects count: 655360 
Desired object size: 16 
Actual object size: 16 
Expected object size in space: 16 
Expected memory usage: 13648120 
Actual memory usage: 13735160 
Memory usage diff: 87040 
Max allowed usage diff: 682408 

for 8u60b09 (and above): 
Verifying memory usage in space: TENURED 
Allocated objects count: 655360 
Desired object size: 16 
Actual object size: 16 
Expected object size in space: 16 
Expected memory usage: 13648984 
Actual memory usage: 24141400 
Memory usage diff: 10492416 
Max allowed usage diff: 682456 
STDERR: 
java.lang.RuntimeException: Actual memory usage should not deviate from expected for more then 682456 
        at com.oracle.java.testlibrary.Asserts.error(Asserts.java:450) 
        at com.oracle.java.testlibrary.Asserts.assertTrue(Asserts.java:377) 
        at com.oracle.java.testlibrary.Asserts.assertLessThanOrEqual(Asserts.java:124) 
        at com.oracle.java.testlibrary.Asserts.assertLTE(Asserts.java:102) 
        at SurvivorAlignmentTestMain.verifyMemoryUsage(SurvivorAlignmentTestMain.java:333) 
        at TestPromotionFromSurvivorToTenuredAfterMinorGC.main(TestPromotionFromSurvivorToTenuredAfterMinorGC.java:104) 
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
        at java.lang.reflect.Method.invoke(Method.java:497) 
        at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:92) 
        at java.lang.Thread.run(Thread.java:745) 

alternatively, in jdk9 the test passes with a "Memory usage diff is incorrect, but it seems like someone else allocated objects" which is a false positive.

Regression: yes 
Stable: yes 

Comments
ILW = Medium (wrong memory usage), Medium, High (unknown) = P4
29-04-2015

One option to get rid of the SurvivorAlignment path completely in the common case would be to templatize the ParGCAllocator based on whether survivor alignment is required or not. Otherwise, a good way to measure performance regressions is to use SPECjbb2005 with all-fixed heap sizes and look at Object Copy times.
28-04-2015

Also the test needs to reconsider whether it makes sense to have this "Memory usage diff is incorrect, but it seems like someone else allocated objects" success.
28-04-2015

Analysis indicates that this problem has been the backport of JDK-8060025, with the main bug also in 9 but there the test determines that "Memory usage diff is incorrect, but it seems like someone else allocated objects" whatever this means. The problem is that beginning with JDK-8060025 SurvivorAlignmentInBytes is also applied to tenured for G1. With a temporary fix (in G1ParGCAllocator::plab_allocate(), add "|| dest.is_old()" to the if-clause) passing the test seems to be a close call too though, the test sometimes reports "Memory usage diff: 964k, max allowed: 1104k." One option to decrease the usage difference significantly is to add -XX:-ResizePLAB to the test.
27-04-2015