octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Eliminating Singleton Objects


From: Rik
Subject: Re: Eliminating Singleton Objects
Date: Sun, 30 Apr 2017 20:28:06 -0700

On 04/28/2017 06:17 PM, John W. Eaton wrote:
> On 04/28/2017 07:49 PM, Rik wrote:
>
>> Is there a performance issue here?  If you start passing too many
>> arguments to a function, more than can conveniently fit into the number
>> of scratch registers that your CPU has, then you have to pass arguments
>> on the stack which will slow things down.  But I can't quite tell if you
>> are suggesting another parameter, or whether you want to include the
>> pointer to the interpreter as say the first entry in the
>> octave_value_list passed as inputs to the function.  Presumably the
>> octave_value_list is already passed as a pointer/reference since it
>> could be large.  In that case it wouldn't have an impact.
>
> At first, I thought it would be easier to just add a pointer to the
> interpreter object to the octave_value_list that is passed to functions.
>  But it turned out to be difficult to chase down all the places where it
> is needed.  There are many locations where it could be needed and I
> couldn't figure out an easy way to get help from the compiler.
>
> So I started working on passing the pointer to the interpreter as an
> additional parameter to DEFUN functions.  It seems much cleaner this
> way.  It also means that these functions will now accept three arguments
> instead of two.  One is a pointer to the interpreter, one is a const
> reference to the octave_value_list containing the arguments, and one is
> an int for nargout.  I doubt that passing one additional pointer to these
> functions will make a big difference overall, but we can certainly
> measure it to be sure.

It's true.  I don't think register pressure is going to develop at 2 or 3
function parameters.  I thought we might already be at the 4-5 parameter
range in which case another could make a difference.

If the compiler is no longer doing initialization of the singleton, is this
the cause of certain data race bugs between the interpreter and the GUI
thread?  Bug #50880 and #50396 both seem to be caused by the GUI looking
for interpreter static variables that have not been initialized in time.

Also, if the pointer to the interpreter really is used all over the code
base, maybe it does make sense to have it be a global?  I know it is
generally frowned upon, but it might actually be simpler then re-working
the API to pass the pointer through to all functions.

--Rik 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]