Slow iteration because of `IxDyn`
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- rust
- Domain
- performance
Research direction
Start by reproducing the iter() and to_owned() comparisons shown for IxDyn and fixed-size ArrayView values, then trace their respective iteration paths. Compare the results with issue #1339; done means a measured improvement for dynamic-dimensional arrays while preserving the existing behavior.
Written by the indexing model from the issue text.
Description
As I described in https://github.com/rust-ndarray/ndarray/issues/1339, an array with IxDyn has 10x slower iteration performance than an equivalent array using a fixed-size index. This has wide-reaching implications, as this means that many pixel-wise operations are substantially slower.
Example:
Let n be an ndarray with the shape (4320, 8468, 4).
let n: ArrayViewD<f32>; // uses IxDyn
// iter()
// slow: takes 3sec on my machine
let _: Vec<f32> = n.iter().cloned().collect();
// fast: takes 0.4sec on my machine
let n3: ArrayView3<f32> = n.into_dimensionality().unwrap();
let _: Vec<f32> = n3.iter().cloned().collect();
// to_owned()
// slow: takes 0.95sec on my machine
let _ = n.to_owned();
// fast: takes 0.25sec on my machine
let n3: ArrayView3<f32> = n.into_dimensionality().unwrap();
let _ = n3.to_owned();
To improve the performance of arrays using IxDyn, I suggest optimizing iteration for these arrays. Since we can see that using fixed-sized indexes is substantially faster, I suggest internally "casting" the array to a fixed-size index (or similar) before iteration when possible.
- Dominant language
- Rust
- Stars
- 4.3k
- Forks
- 391
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-ndarray/ndarray
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
rust-ndarray/ndarray#1612 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
rust-ndarray/ndarray#1617 · 1 comment ·
-
bug good first issue
Difficulty 3/5 1-2 days Newbie friendliness 68/100
rust-ndarray/ndarray#1615 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
rust-ndarray/ndarray#1610 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
rust-ndarray/ndarray#1609 ·
All issues in rust-ndarray/ndarray
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100