[Vm-dev] how slower is called a named primitive over a numbered
primitive?
tim Rowledge
tim at rowledge.org
Mon Jun 22 17:47:06 UTC 2015
On 22-06-2015, at 10:32 AM, Esteban Lorenzano <estebanlm at gmail.com> wrote:
> I’m just trying to understand the cost difference between prim 120 and #primitiveCalloutWithArgs so it should be easy to set up a test :)
The calling of a prim (at the lowest level) is done via a pointer to the prim code. That pointer is generally cached somewhere useful (depends on the exact vm version) and works the same whether it is a pointer found from the primitive table (‘numbered prims’) or via the initial lookup of a named prim. The basics of this was work I did nearly 12 years ago and I’d really surprised if anyone has radically broken it.
> but… judging #primitiveDoNamedPrimitiveWithArgs… I suppose something like Athens will need a numbered primitive, in order to keep it performant…
I really doubt it. Even if the named-prim call cost substantially more I really doubt that it would make any real difference to the total time for a graphics library call. A couple of instructions against thousands, even millions, to do some draw call?
>
> but well, after I have numbers I will send a proposition (if needed), to remap #primitiveCalloutWithArgs into a number… :P
Completely not needed. The cost of primitiveCallout… is in the marshalling of the arguments, not the basic call to that primitive. If you want to speed up calls to a specific library, write a plugin for that specific library and optimise your code & api. IE, don’t have calls to set or get a single variable, make a call to pass a load of info in one go.
tim
--
tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
"Bother!" said Pooh, searching for the $10m winning lottery ticket.
More information about the Vm-dev
mailing list