[Vm-dev] primitiveDigitCompare is slow (was: Re: [squeak-dev] The Inbox: Kernel-dtl.1015.mcz)

David T. Lewis lewis at mail.msen.com
Fri Apr 15 03:27:23 UTC 2016


On Thu, Apr 14, 2016 at 08:01:41PM -0700, Eliot Miranda wrote:
> 
> Hi Dave,
> 
> > On Apr 14, 2016, at 5:09 PM, David T. Lewis <lewis at mail.msen.com> wrote:
> > 
> > I don't know if the apparent slowdown in newer VMs is significant.
> > It might be that some inefficiences have crept in to the primitive
> > calling, but it may just be differences in the compilers or compiler
> > optimization settings that were used when they were compiled.
> > 
> > Overall, I would expect that primitive calling will be faster in
> > Cog, and primitive execution time should be reasonably similar in
> > any version of the VM. The differences between Cog and classic
> > interpreter suggest that the cost of calling a primitive (especially
> > a small primitive) can be relatively high.
> > 
> > I have a feeling that we are reaching a point in which the jit
> > optimization may exceed the performance of compiled primitives. It 
> > seems quite reasonable to me that a jitted method might outperform
> > the compiled primitive version of the same method, because the jit
> > version can completely avoid the overhead of setting up the call to the
> > compiled primitive.
> > 
> > If that is so, then we may have primitives that actually slow the
> > system down when running on Cog.
> > 
> > What if we find that some primitives are useful if and only if we are
> > running without the jit? In that case, we might want to call the
> > primitives when running on Cog, and not call them when running on
> > a plain StackInterpreter.
> > 
> > This is probably a dumb idea, but I'll toss it out anyway. I wonder
> > if there might be a way to cause certain primitives to be called
> > only if they are needed for a non-jit VM? For example, in Squeak
> > we have Environments, and we have pragmas. So I wonder if there
> > might be some way to do something like this:
> > 
> >  <primitive: 'primitiveFindSubstring' module: 'MiscPrimitivePlugin' callUnless: #cog>
> 
> Actually I think it's a good idea but we don't need an additional keyword and state in primitive methods.  The JIT VM could maintain a "do not call" list, or simply not include certain primitives.  What we need is accurate measurements of with and without.   I can then update the "do-not-call" list.
> 
> One issue is that for simple invocations (eg invocations with short strings as arguments) the JIT code may indeed be faster and hence the overhead if the call makes the no primitive code win, but that longer code will be favored by the simpler indexing code in the C primitive and at a certain point overhaul the JIT.  Once Sista arrives this shouldn't be an issue and all of MiscPrimitivePlugin should hopefully be redundant.
> 

<meta>
It is really quite remarkable that we could be having this discussion
at all. An open source virtual machine for Smalltalk that is so fast that
is not even worth the trouble to call out to C primitives? Really?!? Wow.
</meta>

Dave


More information about the Vm-dev mailing list