patchGNU Octave - Patches: patch #9276, decide between array slice...

 
 

patch #9276: decide between array slice references and copies based on size

Submitter:  Olaf Till <i7tiol>
Submitted:  Thu 02 Mar 2017 08:12:57 PM UTC
   
 
Category:  Core : other Priority:  5 - Normal
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 02 Mar 2017 08:12:57 PM UTC, original submission:  

Patched revision: default, 2bed6d6bb2e2, 2017-02-24 20:43+0100

Problem: with current array slice references, large arrays remain in memory even if only a reference to a small part of them still exists.

Demonstration (in single user mode, swapping switched off):

octave:2> a = ones (500000000, 1);
octave:3> b = a(1:10);
octave:4> clear a
octave:5> a = ones (500000000, 1);
error: out of memory or dimension too large for Octave's index type
octave:5>


However, contrary to what I initially thought, no problem if array allocated within function:

octave:1> function ret = mkarray ()
> a = ones (500000000, 1);
> ret = a(1:10);
> endfunction
octave:2> b = mkarray;
octave:3> c = mkarray;
octave:4> d = mkarray;
octave:5> ... and so on.

so if I had to decide now, I probably wouldn't apply the patch.

With patch, demonstrated problem is fixed:

octave:1> a = ones (500000000, 1);
octave:2> b = a(1:10);
octave:3> clear a
octave:4> a = ones (500000000, 1);
octave:5> c = a(1:10);
octave:6> clear a
octave:7> a = ones (500000000, 1);
octave:8> ... and so on.


Description of patch:

If slice reference leaves a certain proportion (configurable, default 50 percent) of array unreferenced, and this proportion corresponds to more than getpagesize(), a copy is made instead of a reference. The same configure option, set to 'no' or '0', disables slice references entirely. Set to '100' for behaviour of unpatched Octave.

Make check gives:

Summary:

  PASS     15008
  FAIL        20
  XFAIL       38
  SKIPPED    204

with unpatched as well as with patched version, the latter both with slice references enabled and disabled.

No test for patched behaviour can be supplied, since only feasible in single user mode and without swapping.

Olaf Till <i7tiol>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #39882:  array-slice-refs-or-copies.cset added by i7tiol (6KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by i7tiol (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.

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-03-02 i7tiol Attached File- Added array-slice-refs-or-copies.cset, #39882

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code