1,308c1,221 < < < < < < < < Getting Started with internal profiler < < < < <
< <

Getting Started with internal < profiler

< <

This document describes how to use internal < profiler tool (iprof) for Jitrino.OPT < code generator.

< <

It is able to instrument the code in such way that < per-method counters of _executed_ (not just compiled) instructions can be < dumped.

< <

Enable iprof

< <

* put extra options: -Djit.arg.codegen.iprof=on < �XcleanupOnExit
< * put iprof.cfg in the same dir where you are < starting DRLVM

< <

Configuration file (iprof.cfg) < format

< <

iprof.cfg consists of a list of global parameters and a list of counters.

< <

Available global parameters:

< <
Config.PrintBBStats=false #(boolean)
< <

This parameter turns on statistics dumping for all < basic block of a method

< <

Counters collect information about executed < instructions defined by filter.
< Counter attributes:

< <

1)Name. Identifies counter

< <

2)Title. Title for dumped column, < optional

< <

3)Filter. List of properties of < instructions to count

< <

Examples:

< <
###########
[begin]
Counter.CALL.Mnemonic=CALL
[end]
 
[begin]
Counter.AddCounter.Title=ADD_EAX_COUNTER
Counter.AddCounter.Mnemonic=ADD
Counter.AddCounter.Operand.0.RegName=EAX
[end]
###########
< <

Name of a counter is defined by the first line in < a [begin]/[end] section starting with 'Counter.'. < Symbols between 'Counter.' and next �.� or �=� or �\n� < are the name of the counter.

< <

You should place filter parameters after the name < of a counter. It's possible to set properties of instruction (mnemonic, number < of operands), properites of particular operand (area < of placement, etc.)or < runtime information (whether call is helper, helper name, etc.) See the list of < filter parameters below

< <

 

< <

Allof < instruction properties corresponds to names of entities of Jitrino < IA32 Code generator:

< <
Mnemonic_CALL�� =>CALL
OpndKind_Mem��� =>Mem
< <

All filter parameters can be considered as parts < of AND-expression. There is special filter attribute �IsOr� < provides OR-operation for ALL filter parameters:

< <
Counter.Name0.IsOr=true
< <

Operand attributes:

< <
Operand.OpNum���������������� Operand number (can be *)
Operand.OpNum.OpndRole������� Operand role
Operand.OpNum.OpndKind������� Operand kind
Operand.OpNum.RegName�������� Register name
Operand.OpNum.MemOpndKind���� Memory operand kind
< <

���� Instruction < attributes:

< <
Mnemonic������ Instruction mnemonic
OperandNumber��� Number of operands
< <

���� Runtime < information attributes:

< <
RuntimeInfo.Kind������ Runtime information kind
RuntimeInfo.HelperID�� VM Helper identifier
RuntimeInfo.IntHelperName���� Internal helper name
< <

Call instruction attributes (counter doesn't work < for other instructions):

< <
isNative
isStatic
isSynchronized
isNoInlining
isInstance
isFinal
isVirtual
isAbstract
isClassInitializer
isInstanceInitializer
isStrict
isRequireSecObject
isInitLocals
isOverridden
< <

 

< <

Reusing of filter

< <

Filter parameters of any counter can be reused and < extended by other counter:

< <
[begin]
Counter.CALL_Inst.Mnemonic=CALL
[end]
[begin]
Counter.I_HELPER_CALL=CALL_Inst
Counter.I_HELPER_CALL.RuntimeInfo.Kind=InternalHelperAddress
[end]
< <

 

< <

WARNING

< <

"space" < characters should not be used outside comments

< <

Dumping of counters

< <

"iprof" < creates the file "iprof.stat" (on exit of < DRLVM session) in the same dir where you are starting DRLVM with "tabbed text" format editable < by spreadsheets.

< <

Example of iprof.cfg:

< <

 

< <
Config.PrintBBStats=true
[begin]
#for counting of all instructions you can specify any word as Mnemonic
Counter.Insts.Mnemonic=Any
[end]
 
#hardcoded counters with only parameter "title"
###############################################
[begin]
#Size of java bytecode of a method
Counter.ByteCodeSize
[end]
#
[begin]
#Number of execution times of the hottest basic block of a method
Counter.MaxBBExec
[end]
[begin]
##ID nuber of the hottest basic block
Counter.HottestBBNum
[end]
#
[begin]
##Number of exception handlers of a method
Counter.ExcHandlersNum
[end]
#
[begin]
#Number of calls of a method
Counter.MethodExec
Counter.MethodExec.Title=Number of calls of a method
[end]
#
[begin]
#Basic block execution count 
Counter.BBExec
[end]
################################################
[begin]
Counter.OpNum.OpndNumber=3
[end]
[begin]
#count instructions with memory access in first five operands
Counter.MemOpnd.IsOR=true
Counter.MemOpnd.Operand.*.OpndKind=Mem
#Counter.MemOpnd.Operand.1.OpndKind=Mem
[end]
[begin]
Counter.UseOpnd.Operand.0.OpndRole=Use
[end]
[begin]
Counter.EAXOpnd.Operand.0.RegName=EAX
[end]
[begin]
Counter.HeapOpnd.Operand.0.MemOpndKind=Heap
[end]
[begin]
Counter.Method.isNative=true
Counter.Method.isStatic=true
Counter.Method.isSynchronized=true
Counter.Method.isNoInlining=true
Counter.Method.isInstance=true
Counter.Method.isFinal=true
Counter.Method.isVirtual=true
Counter.Method.isAbstract=true
Counter.Method.isClassInitializer=true
Counter.Method.isInstanceInitializer=true
Counter.Method.isStrict=true
Counter.Method.isRequireSecObject=true
Counter.Method.isInitLocals=true
Counter.Method.isOverridden=true
[end]
 
[begin]
Counter.CALL.Mnemonic=CALL
[end]
[begin]
Counter.I_HELPER_CALL=CALL
Counter.I_HELPER_CALL.RuntimeInfo.Kind=InternalHelperAddress
[end]
[begin]
Counter.HELPER_CALL=CALL
Counter.HELPER_CALL.RuntimeInfo.Kind=HelperAddress
Counter.HELPER_CALL.RuntimeInfo.HelperID=LdString
[end]
< <
--- > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > > > content="text/html; charset=windows-1251" /> > > > DRLVM Jitrino Just-in-time Compiler > > > >

Jitrino.OPT Internal > Profiler Tool

>

This document defines the internal > profiler tool (iprof) for Jitrino.OPT > code generator and describes how to use it. The internal profiler can instrument > code so that per-method counters of executed (not just compiled) > instructions can be dumped. Operation of iprof is configured in the iprof.cfg > file, as described in this document.

>

To enable iprof, do the following:

>
    >
  1. Put extra options: -Djit.arg.codegen.iprof=on > XcleanupOnExit TODO: where to put these options? do you mean, 'specify on vm startup', just 'specify on the command line' > or something?
  2. >
  3. Place the configuration file iprof.cfg in the same directory > where you are starting DRLVM.
  4. >
>

Configuring the Profiler

>

The configuration file iprof.cfg consists of a list of global parameters > and a list of counters, as defined in this section.

>

Available global parameters

>
Config.PrintBBStats=false #(boolean)
>

This parameter turns on statistics dumping for all > basic blocks of a method.

>

Counters

>

Counters collect information about executed > instructions defined by the filter. > Counters have the following attributes:

> >

Example

>
###########
> [begin]
> Counter.CALL.Mnemonic=CALL
> [end]
>  
> [begin]
> Counter.AddCounter.Title=ADD_EAX_COUNTER
> Counter.AddCounter.Mnemonic=ADD
> Counter.AddCounter.Operand.0.RegName=EAX
> [end]
> ###########
>

All properties of an instruction correspond to names of entities of the Jitrino > IA-32 code generator, for example:

>
Mnemonic_CALL => CALL
> OpndKind_Mem => Mem
>
>
Operand attributes
>
> Operand.OpNum Operand number (can be *)
> Operand.OpNum.OpndRole Operand role
> Operand.OpNum.OpndKind Operand kind
> Operand.OpNum.RegName Register name
> Operand.OpNum.MemOpndKind Memory operand kind
>
> >
Instruction attributes
>
> Mnemonic Instruction mnemonic
> OperandNumber Number of operands
>
> >
Run-time information attributes
>
> RuntimeInfo.Kind Runtime information kind
> RuntimeInfo.HelperID VM Helper identifier
> RuntimeInfo.IntHelperName Internal helper name
>
> >
Call instruction attributes
>
> isNative
> isStatic
> isSynchronized
> isNoInlining
> isInstance
> isFinal
> isVirtual
> isAbstract
> isClassInitializer
> isInstanceInitializer
> isStrict
> isRequireSecObject
> isInitLocals
> isOverridden
>

The counter does not work for other instructions.

>
>
>

Re-using Filter Parameters between Counters

>

Filter parameters of a counter can be re-used and > extended by another counter, for example:

>
[begin]
> Counter.CALL_Inst.Mnemonic=CALL
> [end]
> [begin]
> Counter.I_HELPER_CALL=CALL_Inst
> Counter.I_HELPER_CALL.RuntimeInfo.Kind=InternalHelperAddress
> [end]
> >

Warning

>

Space > characters should not be used outside comments.

>

Dumping of Counters

>

The iprof tool > creates the file iprof.stat on exit of > a DRLVM session in the directory where DRLVM was started. Tabbed text format can > be edited by spreadsheets.

>

Example of iprof Configuration File

> >
Config.PrintBBStats=true
> [begin]
> #for counting of all instructions you can specify any word as Mnemonic
> Counter.Insts.Mnemonic=Any
> [end]
>  
> #hardcoded counters with only parameter "title"
> ###############################################
> [begin]
> #Size of java bytecode of a method
> Counter.ByteCodeSize
> [end]
> #
> [begin]
> #Number of execution times of the hottest basic block of a method
> Counter.MaxBBExec
> [end]
> [begin]
> ##ID nuber of the hottest basic block
> Counter.HottestBBNum
> [end]
> #
> [begin]
> ##Number of exception handlers of a method
> Counter.ExcHandlersNum
> [end]
> #
> [begin]
> #Number of calls of a method
> Counter.MethodExec
> Counter.MethodExec.Title=Number of calls of a method
> [end]
> #
> [begin]
> #Basic block execution count
> Counter.BBExec
> [end]
> ################################################
> [begin]
> Counter.OpNum.OpndNumber=3
> [end]
> [begin]
> #count instructions with memory access in first five operands
> Counter.MemOpnd.IsOR=true
> Counter.MemOpnd.Operand.*.OpndKind=Mem
> #Counter.MemOpnd.Operand.1.OpndKind=Mem
> [end]
> [begin]
> Counter.UseOpnd.Operand.0.OpndRole=Use
> [end]
> [begin]
> Counter.EAXOpnd.Operand.0.RegName=EAX
> [end]
> [begin]
> Counter.HeapOpnd.Operand.0.MemOpndKind=Heap
> [end]
> [begin]
> Counter.Method.isNative=true
> Counter.Method.isStatic=true
> Counter.Method.isSynchronized=true
> Counter.Method.isNoInlining=true
> Counter.Method.isInstance=true
> Counter.Method.isFinal=true
> Counter.Method.isVirtual=true
> Counter.Method.isAbstract=true
> Counter.Method.isClassInitializer=true
> Counter.Method.isInstanceInitializer=true
> Counter.Method.isStrict=true
> Counter.Method.isRequireSecObject=true
> Counter.Method.isInitLocals=true
> Counter.Method.isOverridden=true
> [end]
>  
> [begin]
> Counter.CALL.Mnemonic=CALL
> [end]
> [begin]
> Counter.I_HELPER_CALL=CALL
> Counter.I_HELPER_CALL.RuntimeInfo.Kind=InternalHelperAddress
> [end]
> [begin]
> Counter.HELPER_CALL=CALL
> Counter.HELPER_CALL.RuntimeInfo.Kind=HelperAddress
> Counter.HELPER_CALL.RuntimeInfo.HelperID=LdString
> [end]