RFR(s): 8170860: Get rid of the humanReadableByteCount() method in openjdk/hotspot

Dmitry Fazunenenko dmitry.fazunenko at oracle.com
Thu Dec 8 13:41:29 UTC 2016


Hi Mikael,

On 08.12.2016 16:02, Mikael Gerdin wrote:
> Hi Dima,
>
> On 2016-12-08 13:47, Dmitry Fazunenenko wrote:
>> Hello,
>>
>> I'm looking for a couple of reviewers for a simple fix which eliminates
>> the code copied from Stack Overflow:
>>
>> http://cr.openjdk.java.net/~dfazunen/8170860/webrev.00/
>> https://bugs.openjdk.java.net/browse/JDK-8170860
>>
>> humanReadableByteCount() method was removed. A standard JDK class
>> NumberFormat is used instead. To make the output locale independent '_'
>> symbol is explicitly set as the group delimiter. New output will look 
>> like:
>>
>> [allocate #1             ] init: 33_554_432, used: 5_253_664, comm:
>> 8_388_608, freeRatio ~= 37.4%
>> [allocate #2             ] init: 33_554_432, used: 8_399_392, comm:
>> 10_485_760, freeRatio ~= 19.9%
>> [allocate #3             ] init: 33_554_432, used: 11_545_120, comm:
>> 13_631_488, freeRatio ~= 15.3%
>> [allocate #4             ] init: 33_554_432, used: 14_690_848, comm:
>> 16_777_216, freeRatio ~= 12.4%
>> [allocate #5             ] init: 33_554_432, used: 17_836_576, comm:
>> 19_922_944, freeRatio ~= 10.5%
>> [allocate #6             ] init: 33_554_432, used: 20_982_304, comm:
>> 23_068_672, freeRatio ~= 9.0%
>> [allocate #7             ] init: 33_554_432, used: 24_128_032, comm:
>> 26_214_400, freeRatio ~= 8.0%
>> [allocate #8             ] init: 33_554_432, used: 27_273_760, comm:
>> 29_360_128, freeRatio ~= 7.1%
>
> This looks good but I'm wondering if it would make sense to move 
> MemoryUsagePrinter to gc.testlibrary.Helpers, API could be something 
> like:
>
> void printMemoryUsage(String label, MemoryUsage memusage) {
> ...
> }

My original intention was moving the entire MemoryUsagePrinter class to 
Helpers :)
But I thought that change will be more than just fixing the problem with 
humanReadableByteCount() code.
And it would be rather an RFE.
But if nobody objects I will be glad to implement the bigger refactoring 
now.

I see new API as:

    public static String formatNumber(Number n);
    public static void printMemoryUsage(String label, MemoryUsage mu);

Thanks,
Dima
>
>
> If you feel that you have more urgent matters to work on then I'm fine 
> with the change you proposed as well.



>
> Thanks
> /Mikael
>
>>
>> Thanks,
>> Dima




More information about the hotspot-gc-dev mailing list