JDK-8217315 : Proper units should print more significant digits
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 8,11,12,13
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-01-17
  • Updated: 2019-10-10
  • Resolved: 2019-01-18
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 11 JDK 12 JDK 13 Other
11.0.3Fixed 12.0.2Fixed 13 b05Fixed openjdk8u222Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Description
Right now proper_unit_for_byte_size() and byte_size_in_proper_unit() are switching to higher prefix, once we have two significant digits, like this:

 inline const char* proper_unit_for_byte_size(size_t s) {
 #ifdef _LP64
   if (s >= 10*G) {
     return "G";
   }
 #endif

This is inconvenient for logs, because it abruptly makes values too coarse. For example, this is the usual thing to see in GC logs:

[25.186s][info][gc] Heap: 100G reserved, 15G (15.09%) committed, 15G (15.00%) used

This rounding basically masks the difference within the gigabyte, which makes the rounding error close to 10% in worst case, on 10G threshold It would be preferable instead to print more significant digits, e.g. at least three. With three significant digits, the rounding error would reach 1% at max, and checking against e.g. 100*G would yield five significant digits in worst case. 

Prototype webrev:
 http://cr.openjdk.java.net/~shade/8217315/webrev.01/

This is the example GC log after the patch:

[23.315s][info][gc] Heap: 100G reserved, 15449M (15.09%) committed, 15361M (15.00%) used

Comments
Fix Request (8u) Same reason as above for 11u and 12u. Patch does not apply cleanly, because there is no gtest in 8u. 8u RFR: https://mail.openjdk.java.net/pipermail/jdk8u-dev/2019-May/009271.html
03-05-2019

Fix Request Backporting this patch would help accuracy in GC logs and other logs that print out large quantities, and this would improve performance debugging experience. The patch applies cleanly to both 11u and 12u and passes the new regression testcase.
13-02-2019

RFR: http://mail.openjdk.java.net/pipermail/hotspot-dev/2019-January/036290.html
17-01-2019