Commit b05afe0
authored
`map` is a simpler operation and uses linear indexing for `Array`s. This
often improves performance (occasionally enabling vectorization) and
improves TTFX in common cases. It also automatically returns the correct
result for 0-D arrays, unlike broadcasting that returns a scalar.
Performance:
```julia
julia> A = ones(3,3);
julia> @Btime $A + $A;
44.622 ns (2 allocations: 144 bytes) # v"1.13.0-DEV.1387"
29.047 ns (2 allocations: 144 bytes) # this PR
julia> A = ones(3,3000);
julia> @Btime $A + $A;
10.095 μs (3 allocations: 70.40 KiB) # v"1.13.0-DEV.1387"
4.787 μs (3 allocations: 70.40 KiB) # this PR
julia> @Btime A + B + C + D + E + F setup=(A = rand(200,200); B = rand(200,200); C = rand(200,200); D = rand(200,200); E = rand(200,200); F = rand(200,200));
93.910 μs (3 allocations: 312.59 KiB) # v"1.13.0-DEV.1387"
64.813 μs (9 allocations: 312.77 KiB) # this PR
```
Similarly for `-`.
TTFX:
```julia
julia> A = ones(3,3);
julia> @time A + A;
0.174090 seconds (303.47 k allocations: 14.575 MiB, 99.98% compilation time) # v"1.13.0-DEV.1387"
0.072748 seconds (220.27 k allocations: 11.139 MiB, 99.95% compilation time) # this PR
```
These are measured on
```julia
julia> versioninfo()
Julia Version 1.13.0-DEV.1388
Commit c5f4927 (2025-10-27 11:44 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × Intel(R) Core(TM) i5-10310U CPU @ 1.70GHz
WORD_SIZE: 64
LLVM: libLLVM-20.1.8 (ORCJIT, skylake)
GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 8 virtual cores)
Environment:
LD_LIBRARY_PATH = /usr/local/lib:
JULIA_EDITOR = subl
```
1 parent c0d34aa commit b05afe0
1 file changed
+23
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
5 | 24 | | |
6 | 25 | | |
7 | 26 | | |
8 | | - | |
| 27 | + | |
9 | 28 | | |
10 | 29 | | |
11 | 30 | | |
12 | 31 | | |
13 | 32 | | |
14 | 33 | | |
15 | 34 | | |
16 | | - | |
| 35 | + | |
17 | 36 | | |
18 | 37 | | |
19 | 38 | | |
20 | 39 | | |
21 | | - | |
| 40 | + | |
22 | 41 | | |
23 | 42 | | |
24 | | - | |
| 43 | + | |
25 | 44 | | |
26 | 45 | | |
27 | 46 | | |
| |||
0 commit comments