JuliaArrays / JuliaArrays/AxisArrays.jl
Unexpected allocation on views of AxisArray
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 207
- Forks
- 41
- PR merge metrics
- No merged PRs in 30d
Description
Consider the following simple example:
const A = randn(100);
aa = AxisArray(A;x=SortedVector([i for i in 1:100]));
function axisarrays_alloc(array,xs)
@view array[xs];
nothing;
end
xs = 2:10;
@benchmark axisarrays_alloc(aa,xs)
results in:
BenchmarkTools.Trial:
memory estimate: 352 bytes
allocs estimate: 7
--------------
minimum time: 393.592 ns (0.00% GC)
median time: 399.507 ns (0.00% GC)
mean time: 443.488 ns (4.64% GC)
maximum time: 15.236 μs (96.24% GC)
--------------
samples: 10000
evals/sample: 201
This occurs if x is a SortedVector or plain Vector but not if it is a range. I believe this is related to #147 since the axes are being copied even in a view. I have not yet verified whether or not it is fixed by #148.
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.
Research direction
Start with the provided axisarrays_alloc example and benchmark the view of an AxisArray using a Vector or SortedVector versus a range. Read issues #147 and #148 to understand the suspected axis-copying behavior. Done means the view avoids the unexpected allocations for Vector and SortedVector axes, confirmed by the benchmark.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100