LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Further Details on Dynamic Dispatch

Kind of a follow-up to THIS thread.  I'm looking to use LVOOP in an tightly timed system on RT.

 

I'm looking again at LVOOP performance on RT since other options I have come accross are also relatively slow (flatten, unflatten).

 

I was looking into the effect of inheritance depth on performance and found out something which I'd like to discuss.

 

I have a Class A with method "Get data" from which I derive from for Class X, Y and Z (The method is now a true DD call).  I now Derive from Z so that I have Z2.  I derive from Z2 so that I have Z3 and so on.  Each level of the hierarchy above Z overrides the parent and also calls the parent method.

 

Hierarchy:

Z4 is a child of Z3 is a child of Z2 is a child of Z is a child of A.  All override the Get Data method from Class A.  Z2, Z3 and Z4 override the Get Data method which does nothing but call the parent implementation.

 

Windows 7, LV 2012 SP1 (32-bit)

Calling A:Get Data (Base class) costs 0.28 us

Calling Z:Get Data (No Parent calls) costs 0.28 us

Calling Z2:Get Data (Calls Parent Z:Get Data) costs 2.6 us

Calling Z3:Get Data (Calls Parent Z2:Get Data) costs 3.3 us

Calling Z4:Get Data (Calls Parent Z3:Get Data) costs 4.0 us.

 

RT System (PXIe 8115) LV 2012 SP1

Calling A:Get Data (Base class) costs 0.31 us

Calling Z:Get Data (No Parent calls) costs 0.33 us

Calling Z2:Get Data (Calls Z:Get Data also) costs 0.63 us

Calling Z3:Get Data (Calls Z2:Get Data) costs 0.97 us

Calling Z4:Get Data (Calls Z3:Get Data) costs 1.3 us.

 

It seems that on the host, something weird is going on with the first "call Parent method".  A jump of over 2us is a bit extreme.

 

On the RT, we have a full DD overhead for each and every "call Parent" method.  I would have thought this could be optimised due to the fact that there is a clear and static (once classes are loaded) link between these hierarchy levels.  As it is, the 0.3 us simply adds up over each level of Hierarchy which overrised the method in question before any work is actually being done.

0 Kudos
Message 1 of 2
(3,302 Views)

And of course when I run the exact same code today, the results are different.  Today running the code on the Host (Windows) yields the same results as last week on the RT.  In fact it's slightly faster with Z4 clocking in at 1.1 us.

 

I hate benchmarking.  Trying to fins the optimal code for a specific application when timings like these really matter seems to be a crap shoot.  I don't know that it's all dependent on, sometimes it feels like it's dependent on ambient air pressure or humidity.  It feels that disjointed at times.

 

Makeing sure all code is compiled and that all is saved and all is set to disable debugging seems to simply not be enough to guarantee anything approaching reliable benchmarks.

Message 2 of 2
(3,204 Views)