Resolve aliasing problems in getindex #60
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Life is hard. I am not sure how to write a fully generic code that would work on all supported versions of Julia and be fast.
Therefore I propose half-measure that resolves the following problem:
Timing on 1.2.0 release
and this is timing with this PR:
What is the problem - we cannot use
view
forDataAPI.refarray
in general if we want to be fast as if indices are a generalAbstractVector
thenview
must do unaliasing and this is extremely slow.Therefore what I propose is that we use fast path for
PooledArray
or its view only if the first index ingetindex
isAbstractVector
(it should cover 99.99% of use-cases I can think of - especially given thatPooledArray
did not work correctly for more than 1 dimension anyway in the past an no-one reported it before). In other cases we fall-back to mechanics of Julia Base that avoid allocations (and rewriting them in PooledArrays.jl would be an overkill especially that internals changed since Julia 1.0).