Commit 27af864
perf(iteration): use move instead of clone for iteration (#1586)
@scho-furiosa pointed out in #1584 that there was an unnecessary `clone`
in `Baseiter::next` that was degrading performance for
dynamic-dimensional arrays. This change switches to a move, netting a
74% speedup in iteration for dynamic-dimensional arrays.
Tests (detailed in #1584) showed that there was a trade-off in
performance between dynamic- and fixed-dimensional iteration. `ArrayD`
performs best when mutating its index; `ArrayN` performs best when using
a move. This is an indication that, in the future, `Baseiter::next`
should dispatch to the "layout" / `Dimension` underlying type.
Co-authored-by: Sungkeun Cho <scho@furiosa.ai>1 parent fd67f70 commit 27af864
2 files changed
+2
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
201 | 201 | | |
202 | | - | |
203 | 202 | | |
204 | 203 | | |
205 | 204 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 75 | + | |
79 | 76 | | |
80 | 77 | | |
81 | 78 | | |
| |||
0 commit comments