bugGNU Octave - Bugs: bug #40613, exist(..., 'var') slow when...

 
 

bug #40613: exist(..., 'var') slow when variable does not exist

Submitter:  None
Submitted:  Sun 17 Nov 2013 11:10:48 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Performance
Status:  Fixed Assigned to:  jwe
Originator Name:  Christian Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.2.4
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 20 Nov 2013 06:02:54 PM UTC, comment #5: 

Tested and fixed.  Closing report.

Rik <rik5>
Group administrator
Wed 20 Nov 2013 04:30:39 PM UTC, comment #4: 

I checked in the following change:

http://hg.savannah.gnu.org/hgweb/octave/rev/2ca3a2f46d93

It seems to fix the problem for me.  If someone else confirms that it is fixed, please close this report.

Sorry about forgetting to put the bug ID in the commit message.  It would be great to be able to edit those...

John W. Eaton <jwe>
Group administrator
Mon 18 Nov 2013 01:55:47 AM UTC, comment #3: 

I'll take a look at fixing this one.

John W. Eaton <jwe>
Group administrator
Mon 18 Nov 2013 01:41:17 AM UTC, comment #2: 

I think this is down to the implementation. When looking at the code, it appears octave is looking for the symbol named NAME, then check that the symbol found is of type TYPE. In that regard, supplying the type argument does not offer any speedup.

Because a symbol can be many different things, when a symbol does not exist as a variable, octave will try hard to find the matching symbol: functions, methods... and if nothing is found, it'll refresh path and start again.

Michael Goffioul <goffioul>
Sun 17 Nov 2013 11:59:19 PM UTC, comment #1: 

Surprisingly this slowdown is still present on the development branch.  One doesn't even need the for loop to see that the slowdown is ~75X.


octave:15> clear all
octave:16> x = 1
x =  1
octave:17> tic; exist ("x", "var"); toc
Elapsed time is 0.000249863 seconds.
octave:18> tic; exist ("y", "var"); toc
Elapsed time is 0.019058 seconds.
octave:19> .019058 / .000249863
ans =  76.274


Marking bug as confirmed.

Rik <rik5>
Group administrator
Sun 17 Nov 2013 11:10:48 PM UTC, original submission:  

Hi,
Don't know if this is already known and fixed, but using 'exist()' to check existance of a non-existing variable takes a very long time. See code below:


octave> who f aa*
Variables in the current scope:

f

octave> tic, for ii=1:1000, exist('f','var'); end, toc
Elapsed time is 0.0318 seconds.

octave> tic, for ii=1:1000, exist('aaa','var'); end, toc
Elapsed time is 3.579 seconds.


/Christian

PS. Corresponding code on MATLAB 2012b is pretty much instantaneous in both cases.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-11-20 rik5 Open/ClosedOpen Closed
    2013-11-20 rik5 StatusReady For Test Fixed
    2013-11-20 jwe StatusConfirmed Ready For Test
    2013-11-18 jwe Assigned toNone jwe
    2013-11-17 rik5 StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code