Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected allocation on views of AxisArray #191

Open
bgroenks96 opened this issue Jan 24, 2021 · 0 comments
Open

Unexpected allocation on views of AxisArray #191

bgroenks96 opened this issue Jan 24, 2021 · 0 comments

Comments

@bgroenks96
Copy link

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.

@bgroenks96 bgroenks96 changed the title Unexpected allocation on views of AxisArrays Unexpected allocation on views of AxisArray Jan 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant