%ld instead of %d for LogCompilation counts?

Chris Newland cnewland at chrisnewland.com
Fri Dec 12 08:31:29 UTC 2014


Hi Vladimir,

I've tested changing %g to %f in those 2 places on OpenJDK9 and it looks
good:

<parse method='824' uses='194423.000000' stamp='0.698'>

<branch target_bci='63' taken='1' not_taken='20000' cnt='20001.000000'
prob='4.99975e-05'/>

No accuracy is lost and I can parse using Double.valueOf().longValue() to
get a cardinal number for the count.

Kind regards,

Chris


On Mon, December 8, 2014 18:53, Vladimir Kozlov wrote:
> Thank you, Chris
>
>
> What do you think about using %f as John suggested? Will it solve your
> problem?
>
> Both cases may have a fractional part and with 'long' it will be lost.
>
>
> Thanks,
> Vladimir
>
>
> On 12/8/14 3:56 AM, Chris Newland wrote:
>
>> Hi Vladimir,
>>
>>
>> The believe the only other LogCompilation output where %g is used for a
>>  cardinal number is this one?
>>
>> share/vm/opto/parse1.cpp:443:
>>
>>
>> log->begin_head("parse method='%d' uses='%g'",
>> log->identify(parse_method), expected_uses);
>>
>>
>> Kind regards,
>>
>>
>> Chris
>>
>>
>> On Fri, December 5, 2014 23:34, Vladimir Kozlov wrote:
>>
>>> Hi,
>>>
>>>
>>>
>>> The output was produced by following lines:
>>>
>>>
>>>
>>> C->log()->elem("branch target_bci='%d' taken='%d' not_taken='%d'
>>> cnt='%g' prob='%s'", iter().get_dest(), taken, not_taken, cnt,
>>> prob_str);
>>>
>>> 'cnt' is declared as 'float' and defined as:
>>>
>>>
>>>
>>> cnt = (taken + not_taken) / FreqCountInvocations;
>>>
>>> I think it is artifact from long time ago when FreqCountInvocations
>>> was
>>>
>>>> 1. And to avoid integer overflow, so we want to keep variable as
>>>> float.
>>>>
>>>
>>> But I am fine to change log output to long by converting it to
>>> (jlong)cnt and using JLONG_FORMAT format.
>>>
>>>
>>>
>>> Do you know other places where we use %g for counters?
>>>
>>>
>>>
>>> Thanks,
>>> Vladimir
>>>
>>>
>>>
>>> On 12/5/14 1:09 PM, Chris Newland wrote:
>>>
>>>
>>>> Hi,
>>>>
>>>>
>>>>
>>>> I've encountered some LogCompilation counters in 8u25 that are
>>>> getting printed in exponential form in hotspot.log :
>>>>
>>>> <branch target_bci='20' taken='23867' not_taken='2386581'
>>>> cnt='2.38658e+06' prob='0.00990148'/>
>>>>
>>>> This is harder to parse and loses accuracy because %d is used as a
>>>> formatter in hotspot/src/share/vm/opto/parse2.cpp:
>>>>
>>>> if (C->log() != NULL) { C->log()->elem("branch target_bci='%d'
>>>> taken='%d' not_taken='%d'", iter().get_dest(), taken, not_taken); }
>>>>
>>>>
>>>>
>>>> Would it be possible to modify some or all of the LogCompilation
>>>> format strings to use %ld so that large integers can be printed
>>>> without exponents?
>>>>
>>>> I don't mind going through the OpenJDK motions to submit this as a
>>>> patch if it's a sensible idea.
>>>>
>>>> Thanks,
>>>>
>>>>
>>>>
>>>> Chris
>>>>
>>>>
>>>>
>>>
>>
>>
>




More information about the hotspot-compiler-dev mailing list