Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8217315

Proper units should print more significant digits

    Details

    • Subcomponent:
    • Resolved In Build:
      b05

      Backports

        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

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  shade Aleksey Shipilev
                  Reporter:
                  shade Aleksey Shipilev
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: