RFR: 8025692: Add trace to find out what methods are used at runtime.
Ioi Lam
ioi.lam at oracle.com
Sat Mar 28 04:13:14 UTC 2015
On 3/27/15, 6:56 AM, Karen Kinnear wrote:
> Yumin,
>
> Couple of questions
>
> 1) The bug says "so that infrequently used methods" ...
> So I was expecting a use count, rather than what appears to be a table of any entries that are used.
> It looks fairly straightforward to add a use count.
Hi Karen & Others,
I think some background information would be helpful. I should have
provided more details when I filed the bug.
I guess the wording of this bug (as well as the "TraceMethodUsage",
"jcmd VM.method_usage" names) are confusing. We should clean up the
terminology to be clear what information we are collecting.
There are already other mechanisms for getting method invocation count
(such as a profiler). When I filed 8025692, I didn't want to add a
duplicated feature. Rather, I wanted to have a very low overhead
mechanism to provide the kind of "use" information needed by CDS. The
implementation in this RFR has much lower overhead than a profiler,
since it doesn't count method invocation in compiled code at all.
Why are we collecting the "use" information:
When a method inside the CDS archive is ever "used" (even just one
time), the page containing the method will be mapped to memory. So,
if we can identify all the methods that are used and group them
together, it will increase the locality of the CDS pages, and allow
more CDS pages to be never mapped.
For CDS's optimization purposes, the use count is not so important.
Using a method once has the same effect of using a method multiple
time -- it's page will be loaded into memory.
What does "use" mean for CDS?
For CDS, "use of a method" does not necessarily mean "invocation" of
a method. Rather, it's any attempt to read the contents of a Method
or ConstMethod C++ object. For example, in the case of the compiler ....
> 2) You put the hook in ciMethod.cpp -- does this catch interpreter calls to a method?
... the code in ciMethod is intended to catch the case where the
compiler looks at a method during compilation, for any purpose. For
example, the compile may inline the body of a method into its caller,
even if the code in the method is never executed, and may never be executed.
This RFR does not alter the compiled methods. Hence, it doesn't know
when a piece of compiled code invokes a method M. However, this doesn't
matter:
* If M is interpreted, the "use" of M will be caught by the interpreter.
* If M is compiled code, the "use" of M would have been recorded when
M was compiled
I'll try to upload this info into the bug as well.
I am not sure if we want TraceMethodUsage to be useful for CDS only (and
hence provide only information that's interesting to CDS), or whether we
could make it more useful for other purposes (without adding more
overhead). Any suggestions?
Thanks
- Ioi
> 3) Does the compiler already track profile information of how often a method is called? If so,
> is there a way to print that information?
>
> 4) is this something we would want to be able to turn on remotely, i.e. a writeable flag? So people could
> track calls from a given point?
>
> thanks,
> Karen
>
> On Mar 26, 2015, at 10:34 PM, Yumin Qi wrote:
>
>> Please review:
>>
>> bug: https://bugs.openjdk.java.net/browse/JDK-8025692
>> webrev: http://cr.openjdk.java.net/~minqi/8025692/webrev01/
>>
>> Summary: Add two flags to help list all java methods called in runtime, this is also in product and can help CDS to rearrange methods in shared archive to avoid loading infrequent methods into memory.
>>
>> Tests: vm.runtime.quick.testlist, JPRT
>>
>>
>> Thanks
>> Yumin
>>
>>
More information about the hotspot-runtime-dev
mailing list