%ld instead of %d for LogCompilation counts?

Vladimir Kozlov vladimir.kozlov at oracle.com
Fri Dec 5 23:34:19 UTC 2014


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