Fwd: call vs execute

Christian Humer christian.humer at gmail.com
Mon Jul 7 12:22:58 UTC 2014


Hallo Stefan,



> And the interpretation would be that Truffle inlines 18 nonterminal
> calls into one compilation unit/method/$something?
> This does not happen for the noncaching variant, because that uses an
> IndirectCallNode, correct?
>

Yes exactly. The logic when and how to cache calls to CallTargets is guest
language specific. Use DirectCallNode for cached calls and IndirectCallNode
for not-cached calls.

This is quite amazing. I didn't expect it to be so close to the
> perfect Java code that does the same thing.


Have fun experimenting!

- Christian Humer



> >
> >
> > - Christian Humer
> >
> >
> > On Tue, Jun 24, 2014 at 10:20 AM, Stefan Fehrenbach
> > <stefan.fehrenbach at gmail.com> wrote:
> >>
> >> Hello,
> >>
> >> I implemented a recursive descend grammar interpreter using Truffle.
> >> Nonterminal calls are replaced by either of three alternative
> >> implementations:
> >> 1. Unoptimized lookup of the nonterminal in a hash table
> >> 2. Look up nonterminal during replacement, cache result and call the
> >> cached node's execute method directly.
> >> 3. Look up nonterminal during replacement, cache result and use
> >> Truffle's function call support to call the execute method.
> >>
> >> Now it happens that the function call variant is a lot slower than the
> >> other two and even the cached variant is still slower than the naive
> >> implementation:
> >>
> >> Unoptimized: 3095
> >> Cached execute: 3555
> >> Cached call: 18521
> >> (Time to parse a long string with a grammar consisting of a long chain
> >> of nonterminal calls a couple of times.)
> >>
> >> My question is: why is the function call variant so much slower? The
> >> actual computation is so simple, I expected Truffle/Graal to just
> >> inline the functions.
> >> And why is the cached variant still slower than the naive
> >> implementation. In every parse, we need 150*150 hash table look ups in
> >> the naive implementation vs only 150*150 Assumption checks in variant
> >> #2.
> >>
> >> Code is here: https://github.com/fehrenbach/parsers
> >> Uninitialized node:
> >>
> >>
> https://github.com/fehrenbach/parsers/blob/master/src/org/morphling/parsers/truffle/UninitializedNonterminalCall.java
> >>
> >> I use the graalvm-jdk1.8.0-0.3 release and the following JVM
> >> parameters to call this main method:
> >> org.morphling.parsers.truffle.Tests#main
> >>
> >> -server
> >> -Xss32m
> >> -Dtruffle.TraceRewrites=true
> >> -Dtruffle.DetailedRewriteReasons=true
> >> -G:+TraceTruffleCompilationDetails
> >> -G:+TraceTruffleCompilation
> >> -G:TruffleCompilationThreshold=1
> >> -XX:+UnlockDiagnosticVMOptions
> >> -XX:-PrintCompilation
> >>
> >> Am I just using Truffle the wrong way? What could be the reason for
> >> the slow function calls and the underperforming cache, even in this
> >> contrived grammar with long nonterminal chains?
> >>
> >> Best regards,
> >> Stefan
> >
> >
>


More information about the graal-dev mailing list