Skip to content

Reduce spurious allocations in setindex and getindex #1301

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gustafsson
Copy link

Only store a Type{<:StaticArray} upon failed bounds checking of a
StaticArray to prevent boxing (i.e allocation).

A new @test_noalloc that captures variables to help the compiler avoid
additional spurious boxing/allocations.

@gustafsson gustafsson force-pushed the BoundsError-skip-box branch from d326ff8 to 38bbee9 Compare April 1, 2025 06:32
Only store a Type{<:StaticArray} upon failed bounds checking of a
StaticArray to prevent boxing (i.e allocation).

A new @test_noalloc that captures variables to help the compiler avoid
additional spurious boxing/allocations.
@gustafsson gustafsson force-pushed the BoundsError-skip-box branch from 38bbee9 to 201f7d2 Compare April 1, 2025 06:47
@mateuszbaran
Copy link
Collaborator

I'm not particularly familiar with this part of the library but it looks like there is a failure on Julia 1.6.

@@ -188,7 +188,7 @@ julia> setindex(@SMatrix[2 4; 6 8], 1, 2)
return quote
@_propagate_inbounds_meta
@boundscheck if (index < 1 || index > $(L))
throw(BoundsError(a, index))
Base.throw_boundserror(a, index)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is identical within a @noinline. Can we define the helper function in this package, instead of relying on Base internals?

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.

3 participants