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

Recursive indexing of concatenated arrays #133

Merged
merged 6 commits into from
Sep 2, 2020

Conversation

jipolanco
Copy link
Contributor

This is an attempt to fix the performance issues discussed in #132. These are type instability issues when indexing heterogeneous concatenated arrays with getindex and setindex!.

In this PR, getindex and setindex! are reimplemented for the Vcat{1}, Vcat{2} and Hcat lazy concatenation types.

Here is a small benchmark for comparison, on Julia 1.5.1:

using BenchmarkTools
using LazyArrays
using StaticArrays

A = Vcat(
    rand(1:10, 12),
    @SVector(zeros(Int, 4)),
    4:42,
)

N = length(A)

On LazyArrays master:

@btime $A[1];   # 7.356 ns (0 allocations: 0 bytes)
@btime $A[14];  # 43.875 ns (2 allocations: 112 bytes)
@btime $A[$N];  # 80.788 ns (4 allocations: 208 bytes)

With this PR:

@btime $A[1];   # 4.329 ns (0 allocations: 0 bytes)
@btime $A[14];  # 4.668 ns (0 allocations: 0 bytes)
@btime $A[$N];  # 6.105 ns (0 allocations: 0 bytes)

@codecov
Copy link

codecov bot commented Aug 30, 2020

Codecov Report

Merging #133 into master will decrease coverage by 0.10%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #133      +/-   ##
==========================================
- Coverage   87.13%   87.03%   -0.11%     
==========================================
  Files          12       12              
  Lines        1360     1357       -3     
==========================================
- Hits         1185     1181       -4     
- Misses        175      176       +1     
Impacted Files Coverage Δ
src/lazyconcat.jl 93.78% <100.00%> (-0.04%) ⬇️
src/lazyoperations.jl 77.45% <0.00%> (-0.99%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0a9340b...e2cda40. Read the comment docs.

@dlfivefifty
Copy link
Member

Looks like just one line is missing in coverage, are you able to cover this? (Sometimes its just a bug in codecov and I can merge as is in that case.)

@jipolanco
Copy link
Contributor Author

Sorry, I had left a function that in the end I didn't use. Should be good now.

@dlfivefifty
Copy link
Member

If bump the patch version (to v0.17.7) I can merge and tag right away

@dlfivefifty
Copy link
Member

Actually I'll just do the tag now

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

Successfully merging this pull request may close these issues.

2 participants