patchGNU Octave - Patches: patch #8134, Speed up waitbar () by caching...

 
 

patch #8134: Speed up waitbar () by caching axes and patch handles in figure's __guidata__.

Submitter:  Philipp Kutin <pkutin>
Submitted:  Sun 28 Jul 2013 07:46:21 AM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  None Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 01 Aug 2013 09:07:39 PM UTC, comment #5: 

I applied your patch here (http://hg.savannah.gnu.org/hgweb/octave/rev/13da13e1e17f).  I benchmarked it and was seeing ~36% improvement which is definitely worthwhile.  I added your name to the list of contributors in another changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/743c9745009a).  Thanks for helping out, since I saw there may have been some strong words on the Octave Maintainer's list regarding classdef stuff.

Rik <rik5>
Group administrator
Mon 29 Jul 2013 10:53:57 AM UTC, comment #4: 

By the way, my comment regarding set() is because when I profiled the test loop[1], it showed up topmost. (About 50% IIRC, which is consistent with results below.) But the situation is more complicated that this:

After

> w = waitbar(0);
> p = get(w, '__guidata__')(2)


here are two different loops:


> tic; for i=1:1000, set (p, "xdata", [0; 0.5; 0.5; 0]); end; toc
Elapsed time is 0.02628 seconds.
> tic; for i=1:1000, set (p, "xdata", [0; i/1000; i/1000; 0]); end; toc
Elapsed time is 8.736 seconds.


So maybe in the first one, there's some did-not-update optimization going on?

[1] When the profiler still worked, that is. I don't think the breakage is related to my profexplore patch, since passing it "profile('info')" makes it assertion-fail, too.

Philipp Kutin <pkutin>
Mon 29 Jul 2013 10:26:36 AM UTC, comment #3: 

Updated patch attached.

(file #28688)

Philipp Kutin <pkutin>
Sun 28 Jul 2013 10:34:33 PM UTC, comment #2: 

Minor whitespace issues in your patch. You're using tabs instead of spaces, and you're doing "get(" instead of "get (". Do you want to fix them or will you wait until I do it?

Jordi GutiƩrrez Hermoso <jordigh>
Group Member
Sun 28 Jul 2013 08:21:27 AM UTC, comment #1: 

Oops, it should read "... s per iteration". I wanted to multiply that value with 1000, but forgot it.

Philipp Kutin <pkutin>
Sun 28 Jul 2013 07:46:21 AM UTC, original submission:  

scripts/plot/waitbar.m: Instead of calling "findobj" twice, cache the handles
for the wait bar axes and patch objects in the figure's _guidata_ field.

Timing before with the attached "prof_waitbar(1000)" on FLTK:
1000 iterations * 0.01811ms per iteration = 18.110 s total
and after:
1000 iterations * 0.01668ms per iteration = 16.675 s total

(Not always reproducible to that extent?)

[I wanted to post a profile here, but it profexplore aborts with an assertion failure for me. Bug report upcoming.]

Of course, 16 ms per call is still excessive. It seems that when dealing with handle graphics, the same wisdom as for MATLAB holds: if you want it to be fast, cache everything that prevents calling get(), set(), or findobj(). Is there no way to speed up the set() builtin?

Philipp Kutin <pkutin>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #28676:  prof_waitbar.m added by pkutin (519B - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by jordigh (Posted a comment)
  • -email is unavailable- added by pkutin (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 logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-08-01 rik5 StatusNone Done
        Open/ClosedOpen Closed
    2013-07-29 pkutin Attached File- Added waitbar-speedup-mod1-pk.patch, #28688
    2013-07-28 pkutin Attached File- Added 0002-waitbar-speedup-pk.patch, #28675
        Attached File- Added prof_waitbar.m, #28676

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code