%ld instead of %d for LogCompilation counts?

Vladimir Kozlov vladimir.kozlov at oracle.com
Mon Dec 8 18:53:37 UTC 2014


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