bugGNU Octave - Bugs: bug #64962, Avoid unessecary copy of dim_vector


bug #64962: Avoid unessecary copy of dim_vector

Submitter:  Petter <petter>
Submitted:  Sat 02 Dec 2023 02:19:24 PM UTC
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Performance
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  10.1.0 (current default) Planned Release:  10.1.0 (current default)
* Mandatory Fields

Add a New Comment Rich Markup

Wed 13 Dec 2023 10:03:08 PM UTC, comment #5: 

I found a few more instances and changed them here: https://hg.savannah.gnu.org/hgweb/octave/rev/60c1b3ffd859.

Rik <rik5>
Group administrator
Wed 13 Dec 2023 08:51:44 PM UTC, comment #4: 

I pushed the following changeset on default:


John W. Eaton <jwe>
Group administrator
Wed 13 Dec 2023 06:21:04 PM UTC, comment #3: 

I don't think this was a comprehensive review.  Rather, Petter found an instance which could clearly be improved and so made the change.

If there is a simple way to find these instances with grep or some other tool I think we should convert more of the code base to do this.

I've never been able to get a good profiling run on Octave to find the real hotspots.  But, I always do find that we are creating and destroying a lot of temporary objects.  Eliminating that should help.

Rik <rik5>
Group administrator
Wed 13 Dec 2023 05:59:17 PM UTC, comment #2: 

This change seems OK to me, but why change only these two instances?  There are probably hundreds more uses of local dim_vector objects that could be changed in the same way.

John W. Eaton <jwe>
Group administrator
Tue 12 Dec 2023 05:52:41 AM UTC, comment #1: 

@Petter: I made a few changes to the commit message to follow Octave guidelines and checked in your change on the default branch here: https://hg.savannah.gnu.org/hgweb/octave/rev/324c67c33dbd.

Thank you for the patch.  Marking as Fixed and closing report.

Rik <rik5>
Group administrator
Sat 02 Dec 2023 02:19:24 PM UTC, original submission:  

There is only a need of one copy in the first case and
none in the second.

* mx-inlinces.cc: Use ref to avoid copies.

A dim_vector ctor uses malloc, which slows things down quite a lot when using do_mm_binary_op() or do_mm_inplace_op(), for small matrices.

Petter <petter>


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

Attach Files:

Attached Files
file #55388:  octave_32768.patch added by petter (1KiB - text/x-patch)


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 petter (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
    2023-12-12 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
        Fixed ReleaseNone 10.1.0 (current default)
        Planned ReleaseNone 10.1.0 (current default)
    2023-12-02 petter Attached File- Added octave_32768.patch, #55388

    Back to the top

    Powered by Savane 3.12.
    Corresponding source code