[Scilab-users] Large variables and execution speeds

Tim Wescott tim at wescottdesign.com
Wed Feb 25 20:20:37 CET 2015


I'm specifically hoping to avoid just exchanging pieces of the top-level
object, because it's pretty abstract -- I need to count on it doing
something generally similar, but possibly entirely different in the
details.

I realized, however, that I'm storing some pretty big arrays (several
arrays of 1,000,000 words each is big, yes?) in there where I only need
to store buffers -- I'm going to rearrange my code, which I think and
hope should dramatically speed things up.

On Wed, 2015-02-25 at 09:16 +0100, Clément David wrote:
> Hello Tim,
> 
> Yes, the copies are there as Scilab does not allow to pass data by
> reference but only by copy.
> 
> To avoid extra copy when using tlist, you have to avoid data resize
> which is really costly. When writing :
> 
> local_tlist.some_field = stuff;
> 
> There is no performance penalty if 'some_field' and 'stuff' have the
> same datatype and size. Scilab will be able to simply reuse the
> allocated space.
> 
> However using a tlist rhs/lhs force a copy which is not needed, using
> named arguments let the interpreter avoid some copies.
> 
> For a complete bench, see the attached file.
> 
> Le mardi 24 février 2015 à 13:38 -0800, Tim Wescott a écrit :
> > I have an algorithm that I'm working on that involves having large data
> > sets, which I'm currently representing as tlists.  Due to the
> > constraints of the algorithm, I'm doing many calls that are more or less
> > of the form:
> > 
> > my_tlist = some_function(my_tlist);
> > 
> > The intent is to get the same effect that I would get if I were in C or
> > C++, and wrote:
> > 
> > some_function(& my_structure);
> > 
> > or
> > 
> > my_class.some_function();
> > 
> > It appears, from the significant loss of execution speed when I do this,
> > that Scilab is copying the results of the function into the "my_tlist"
> > variable byte by byte.
> > 
> > At this writing, the only way that I can see to fix this is to invoke
> > the function as:
> > 
> > some_function("my_tlist");
> > 
> > and then wherever I modify data have use an exec function, i.e., replace
> > 
> > local_tlist.some_field = stuff;
> > 
> > with
> > 
> > exec(msprintf("%s = stuff", local_tlist_name));
> > 
> > This seems clunky in the extreme.
> > 
> > Is there another way to do something like this that doesn't force Scilab
> > to copy large chunks of data needlessly, but allows me to operate on
> > multiple copies of similar tlists?
> > 
> > Thanks.
> > 
> 
> --
> Clément

-- 

Tim Wescott
www.wescottdesign.com
Control & Communications systems, circuit & software design.
Phone: 503.631.7815
Cell:  503.349.8432




More information about the users mailing list