Fix performance warnings

Renze Torensma renzetorensma at gmail.com
Fri May 29 11:39:29 UTC 2015


Hi Chris,

I’m now trying to use a ExactClassProfile to allow inlining of a virtual call, but I’m not sure I’m using the profile the right way.. I can’t find the profiles you mention you used in Ruby for the arguments either.

I now set up the profile in the constructor and wrap the call with the profile like this:

public class RascalRootNode extends RootNode {
	private final AbstractFunction func;
	private ExactClassValueProfile funcProfile;
	
	public RascalRootNode(AbstractFunction func) {
		this.funcProfile = (ExactClassValueProfile) ValueProfile.createClassProfile();
		this.func = funcProfile.profile(func);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Object execute(VirtualFrame frame) {
		Type[] argTypes = (Type[]) frame.getArguments()[0];
		IValue[] argValues = (IValue[]) frame.getArguments()[1];
		Map<String, IValue> keyArgValues = (Map<String, IValue>) frame.getArguments()[2];
		return funcProfile.profile(func).call(argTypes, argValues, keyArgValues);
	}
}

I can’t make the profile final like it says in the com.oracle.truffle.api.utilities.ValueProfile class because then comiling failes:

compilation failed!?
[truffle] opt fail         Rootnode : fib                                              |Reason java.lang.StackOverflowError 

But when I don’t make the profile final I still get the warning about the virtual call that can’t be inlined, which is to be expected because the javadoc says a profile should be final:

[truffle] perf warn        not inlined Virtual call to HotSpotMethod<Result.call(Type[], IValue[], Map)> (42|MethodCallTarget)
[truffle] perf warn        non-leaf type checkcast: [Lorg/eclipse/imp/pdb/facts/type/Type; (7|CheckCast)
[truffle] perf warn        non-leaf type checkcast: [Lorg/eclipse/imp/pdb/facts/IValue; (11|CheckCast)
[truffle] perf warn        non-leaf type checkcast: Ljava/util/Map; (14|CheckCast)
[truffle] perf warn        non-leaf type checkcast: Lorg/rascalmpl/interpreter/result/AbstractFunction; (35|CheckCast)

Am I doing something wrong with the ExactclassProfile or is my code responsible for the stackoverflow during compilation?

Renze

> On 27 mei 2015, at 15:48, Renze Torensma <renzetorensma at gmail.com> wrote:
> 
> Thanks! I managed to remove the warnings about the interface call by replacing the List with an array. Now I’m working on the virtual call warnings, and ignoring the non-leaf type checkcast for now.
> 
> I forgot to post the code, but it’s at https://github.com/renzet/rascal <https://github.com/renzet/rascal>. I’m planning to change the implementation of function calls by using calltargets next.
> 
> Renze 
> 
>> On 23 mei 2015, at 12:14, Chris Seaton <chris.seaton at oracle.com <mailto:chris.seaton at oracle.com>> wrote:
>> 
>> To remove the non-inlined interface and virtual calls you want specifically an ExactClassValueProfile - not an IdentityValueProfile or PrimitiveValueProfile, so check you are using the right one.
>> 
>> In Ruby I put a value profile on all arguments as they are unpacked into locals in the method prelude. To me that seemed like a sensible place to put them but I haven’t looked into other options.
>> 
>> Non-leaf type checkcast means you are checking the class of an object against a class that has subclasses or more than one implementation. This isn’t as efficient as checking against a leaf class. This isn’t an error, and we get similar warnings when I run JRuby+Truffle with this flag, but may be a symptom of a class hierarchy that is too elaborate.
>> 
>> In general the fact that you are compiling methods that use things like List is unusual. It’s an interface with many implementations of course so that would likely lead to the problems you are having. For this reason we use data structures like int[] and Object[] in JRuby+Truffle, rather than the more complicated List. Where we do use List it’s usually behind a TruffleBoundary.
>> 
>> Are you able to share your code so we can see what you’re doing and advise further?
>> 
>> Chris
>> 
>>> On 21 May 2015, at 23:21, Renze Torensma <renzetorensma at gmail.com <mailto:renzetorensma at gmail.com>> wrote:
>>> 
>>> Hi,
>>> 
>>> When I run my program with the compiler flag -G:+TraceTrufflePerformanceWarnings I get several warnings:
>>> 
>>> [truffle] perf warn        not inlined Interface call to HotSpotMethod<List.size()> (36|MethodCallTarget)
>>> [truffle] perf warn        not inlined Virtual call to HotSpotMethod<Type.getArity()> (97|MethodCallTarget)
>>> [truffle] perf warn        non-leaf type checkcast: Lorg/rascalmpl/interpreter/result/AbstractFunction; (82|CheckCast)
>>> 
>>> I understand Truffle can’t inline virtual and interface calls (are interface calls also virtual calls?) but I’m not sure how to fix those issues. I tried using a ValueProfile but I’m not sure which function calls I should wrap with a profile since I don’t know which lines exactly (it only says 36|MethodCallTarget but I don’t know what that means). And I don’t know whether or not this is the right approach to fix those performance issues.
>>> 
>>> For the last one I have no clue what that means, maybe someone can expain a little and some pointers about how to fix that?
>>> 
>>> Regards,
>>> Renze
>> 
> 



More information about the graal-dev mailing list