octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #58105] isfield needs time proportional to num


From: anonymous
Subject: [Octave-bug-tracker] [bug #58105] isfield needs time proportional to number of fields
Date: Sun, 9 May 2021 06:19:27 -0400 (EDT)
User-agent: Mozilla/5.0 (Linux; Android 7.0; BG2-U01) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.91 Mobile Safari/537.36

Follow-up Comment #4, bug #58105 (project octave):

@pot What I mentioned as workaround is just a workaround and I think it
probably will not be accepted as a fix to this bug because: 
* isfield is a builtin function that is implemented in c++ and it is less
probable to be replaced by a user defined function. 
* Usually bugs that are related to performance have lower preference over
other type of bugs like correctness or implememtation of new features.
Specially for struct that I think has less uses over for example array data
type. 
* Consider lack of resources and active volunteer developers to implement such
features. 
* Technical reasons: Octave data structures usually follow copy on write COW
semantics and the proposed c++ fix, i.e. exposing internal structures by
reference, may lead to some mis-uses 
by developers and further bugs may be produced. Because of that most of the
Octave API functions return value instead of reference. And since Octave
values are cheep COW objects there is usuall no consdiderable performance
penalty in returning value. 
The main problem here is that Octave currently lacks a performant COW dynamic
array data structure. Current Octave Array class is a COW array but appending
an element to the end of array always leads to reallocation. Because of that
In the implementation of Octave struct a performant dynamic array(std::vector)
is used. But the problem is that std::vector isn't a COW data type and every
time octave_map is returned by value the internal vector is also copied. So
std containers in Octave structures should be used with caution. 

I sometimes think that we can implement such COW dynamic array based on
implementations like fbstring (a thread safe COW string implementation) but it
may require much of work. 
It seems that returning octave map by const reference can be a reasonable
option. 
Note that in the mentioned workaround b.iscell() should be changed to
iscell(b). Sorry for typo. 

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58105>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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