Skip to content

Conversation

@nsajko
Copy link
Member

@nsajko nsajko commented Aug 30, 2025

Changes:

  • Eliminate some nongeneric length methods:

    • GenericMemory

    • Slice

    • IdentityUnitRange

    • CartesianIndices

    • LogicalIndex

    • CodeUnits

    • UnsafeView (from the Random stdlib)

  • Eliminate some nongeneric two-argument size methods:

    • GenericMemory

    • Array

    • BitVector

Depends on PR #59465 to prevent abstract inference regressions.

@nsajko nsajko added the arrays [a, r, r, a, y, s] label Aug 30, 2025
@nsajko nsajko added the iteration Involves iteration or the iteration protocol label Aug 30, 2025
@nsajko nsajko force-pushed the eliminate_some_Array-specific_methods_of_size branch from 6296bd7 to b1717b7 Compare August 30, 2025 13:12
jishnub pushed a commit to JuliaLang/LinearAlgebra.jl that referenced this pull request Sep 1, 2025
…#1431)

An issue with `Base` is that some methods of `size` throw `BoundsError`
for an out-of-bounds second argument, while others throw
`ErrorException` in the same case.

Relax the tests here to allow for fixing that issue in `Base` in the
future.

PR that depends on this change:

* JuliaLang/julia#59442
nsajko added a commit to nsajko/julia that referenced this pull request Sep 2, 2025
Specifically I want this because of PR JuliaLang/LinearAlgebra.jl#1431,
which PR JuliaLang#59442 depends on.
@nsajko nsajko force-pushed the eliminate_some_Array-specific_methods_of_size branch from b898d22 to db42652 Compare September 2, 2025 15:16
nsajko added a commit to nsajko/julia that referenced this pull request Sep 2, 2025
The generic method `size(::AbstractArray, ::Any)` currently has:

* method static parameters

* an abstract type assert (`::Integer`) in the method body

PR JuliaLang#59442 aims to make this generic method be used for `Array` and
`Memory`, by deleting the more specific methods.

It is my understanding that method static parameters and abstract type
asserts can cause performance issues, when they're not optimized out,
which happens when the argument types are not concretely inferred.

So I'm putting up this PR, which eliminates the method static
parameters and the `typeassert`, to prevent any possible regressions
from PR JuliaLang#59442.

These seems like they might potentially cause regressions
nsajko added a commit to nsajko/julia that referenced this pull request Sep 2, 2025
The generic method `size(::AbstractArray, ::Any)` currently has:

* method static parameters

* an abstract type assert (`::Integer`) in the method body

PR JuliaLang#59442 aims to make this generic method be used for `Array` and
`Memory`, by deleting the more specific methods.

It is my understanding that method static parameters and abstract type
asserts can cause performance issues, when they're not optimized out,
which happens when the argument types are not concretely inferred.

So I'm putting up this PR, which eliminates the method static
parameters and the `typeassert`, to prevent any possible regressions
from PR JuliaLang#59442.
nsajko added a commit to nsajko/julia that referenced this pull request Sep 2, 2025
Specifically I want this because of PR JuliaLang/LinearAlgebra.jl#1431,
which PR JuliaLang#59442 depends on.
@nsajko nsajko force-pushed the eliminate_some_Array-specific_methods_of_size branch 2 times, most recently from cd6182e to f60ab17 Compare September 3, 2025 12:36
nsajko added a commit to nsajko/julia that referenced this pull request Sep 3, 2025
Specifically I want this because of PR JuliaLang/LinearAlgebra.jl#1431,
which PR JuliaLang#59442 depends on.

(cherry picked from commit 54f21dd3217e6c481eb37d82a9506f76c6d8c92c)
nsajko added a commit to nsajko/julia that referenced this pull request Sep 3, 2025
The generic method `size(::AbstractArray, ::Any)` currently has:

* method static parameters

* an abstract type assert (`::Integer`) in the method body

PR JuliaLang#59442 aims to make this generic method be used for `Array` and
`Memory`, by deleting the more specific methods.

It is my understanding that method static parameters and abstract type
asserts can cause performance issues, when they're not optimized out,
which happens when the argument types are not concretely inferred.

So I'm putting up this PR, which eliminates the method static
parameters and the `typeassert`, to prevent any possible regressions
from PR JuliaLang#59442.

(cherry picked from commit 16d504108c6d69abf7fb8e175e61132314e3a49a)
nsajko added a commit to nsajko/julia that referenced this pull request Sep 3, 2025
The generic method `size(::AbstractArray, ::Any)` currently has:

* method static parameters

* an abstract type assert (`::Integer`) in the method body

PR JuliaLang#59442 aims to make this generic method be used for `Array` and
`Memory`, by deleting the more specific methods.

It is my understanding that method static parameters and abstract type
asserts can cause performance issues, when they're not optimized out,
which happens when the argument types are not concretely inferred.

So I'm putting up this PR, which eliminates the method static
parameters and the `typeassert`, to prevent any possible regressions
from PR JuliaLang#59442.

Another thing that is necessary for preserving good abstract inference
is to convert the index to `Int` before using it. This is correct
it there can't be more than `typemax(Int)` dimensions anyway.
nsajko added a commit to nsajko/julia that referenced this pull request Sep 3, 2025
Specifically I want this because of PR JuliaLang/LinearAlgebra.jl#1431,
which PR JuliaLang#59442 depends on.

(cherry picked from PR JuliaLang#59464)
nsajko added a commit to nsajko/julia that referenced this pull request Sep 3, 2025
The generic method `size(::AbstractArray, ::Any)` currently has:

* method static parameters

* an abstract type assert (`::Integer`) in the method body

PR JuliaLang#59442 aims to make this generic method be used for `Array` and
`Memory`, by deleting the more specific methods.

It is my understanding that method static parameters and abstract type
asserts can cause performance issues, when they're not optimized out,
which happens when the argument types are not concretely inferred.

So I'm putting up this PR, which eliminates the method static
parameters and the `typeassert`, to prevent any possible regressions
from PR JuliaLang#59442.

Another thing that is necessary for preserving good abstract inference
is to convert the index to `Int` before using it. This is correct
it there can't be more than `typemax(Int)` dimensions anyway.

(cherry picked from PR JuliaLang#59465)
@nsajko nsajko force-pushed the eliminate_some_Array-specific_methods_of_size branch from f60ab17 to 7555dd4 Compare September 3, 2025 14:09
ViralBShah pushed a commit that referenced this pull request Sep 3, 2025
Specifically I want this because of PR JuliaLang/LinearAlgebra.jl#1431,
which PR #59442 depends on.
nsajko added a commit to nsajko/julia that referenced this pull request Sep 3, 2025
The generic method `size(::AbstractArray, ::Any)` currently has:

* method static parameters

* an abstract type assert (`::Integer`) in the method body

PR JuliaLang#59442 aims to make this generic method be used for `Array` and
`Memory`, by deleting the more specific methods.

It is my understanding that method static parameters and abstract type
asserts can cause performance issues, when they're not optimized out,
which happens when the argument types are not concretely inferred.

So I'm putting up this PR, which eliminates the method static
parameters and the `typeassert`, to prevent any possible regressions
from PR JuliaLang#59442.

Another thing that is necessary for preserving good abstract inference
is to convert the index to `Int` before using it. This is correct
it there can't be more than `typemax(Int)` dimensions anyway.

(cherry picked from PR JuliaLang#59465)
@nsajko nsajko force-pushed the eliminate_some_Array-specific_methods_of_size branch from 7555dd4 to d3ab3f1 Compare September 3, 2025 14:28
nsajko added a commit to nsajko/julia that referenced this pull request Sep 3, 2025
The generic method `size(::AbstractArray, ::Any)` currently has:

* method static parameters

* an abstract type assert (`::Integer`) in the method body

PR JuliaLang#59442 aims to make this generic method be used for `Array` and
`Memory`, by deleting the more specific methods.

It is my understanding that method static parameters and abstract type
asserts can cause performance issues, when they're not optimized out,
which happens when the argument types are not concretely inferred.

So I'm putting up this PR, which eliminates the method static
parameters and the `typeassert`, to prevent any possible regressions
from PR JuliaLang#59442.

Another thing that is necessary for preserving good abstract inference
is to convert the index to `Int` before using it. This is correct
it there can't be more than `typemax(Int)` dimensions anyway.

(cherry picked from PR JuliaLang#59465)
@nsajko nsajko force-pushed the eliminate_some_Array-specific_methods_of_size branch from e5ff23c to 6ea17fb Compare September 3, 2025 15:10
nsajko added a commit to nsajko/julia that referenced this pull request Sep 3, 2025
The generic method `size(::AbstractArray, ::Any)` currently has:

* method static parameters

* an abstract type assert (`::Integer`) in the method body

PR JuliaLang#59442 aims to make this generic method be used for `Array` and
`Memory`, by deleting the more specific methods.

It is my understanding that method static parameters and abstract type
asserts can cause performance issues, when they're not optimized out,
which happens when the argument types are not concretely inferred.

So I'm putting up this PR, which eliminates the method static
parameters and the `typeassert`, to prevent any possible regressions
from PR JuliaLang#59442.

Another thing that is necessary for preserving good abstract inference
is to convert the index to `Int` before using it. This is correct
it there can't be more than `typemax(Int)` dimensions anyway.
nsajko added a commit to nsajko/julia that referenced this pull request Sep 3, 2025
The generic method `size(::AbstractArray, ::Any)` currently has:

* method static parameters

* an abstract type assert (`::Integer`) in the method body

PR JuliaLang#59442 aims to make this generic method be used for `Array` and
`Memory`, by deleting the more specific methods.

It is my understanding that method static parameters and abstract type
asserts can cause performance issues, when they're not optimized out,
which happens when the argument types are not concretely inferred.

So I'm putting up this PR, which eliminates the method static
parameters and the `typeassert`, to prevent any possible regressions
from PR JuliaLang#59442.

Another thing that is necessary for preserving good abstract inference
is to convert the index to `Int` before using it. This is correct
it there can't be more than `typemax(Int)` dimensions anyway.

(cherry picked from PR JuliaLang#59465)
@nsajko nsajko force-pushed the eliminate_some_Array-specific_methods_of_size branch from 6ea17fb to cea09b4 Compare September 3, 2025 15:29
nsajko added a commit to nsajko/julia that referenced this pull request Sep 3, 2025
The generic method `size(::AbstractArray, ::Any)` currently has:

* method static parameters

* an abstract type assert (`::Integer`) in the method body

PR JuliaLang#59442 aims to make this generic method be used for `Array` and
`Memory`, by deleting the more specific methods.

It is my understanding that method static parameters and abstract type
asserts can cause performance issues, when they're not optimized out,
which happens when the argument types are not concretely inferred.

So I'm putting up this PR, which eliminates the method static
parameters and the `typeassert`, to prevent any possible regressions
from PR JuliaLang#59442.

Another thing that is necessary for preserving good abstract inference
is to convert the index to `Int` before using it. This is correct
it there can't be more than `typemax(Int)` dimensions anyway.

(cherry picked from PR JuliaLang#59465)
@nsajko nsajko force-pushed the eliminate_some_Array-specific_methods_of_size branch from cea09b4 to 2565bed Compare September 3, 2025 15:42
nsajko added a commit to nsajko/julia that referenced this pull request Sep 9, 2025
The generic method `size(::AbstractArray, ::Any)` currently has:

* method static parameters

* an abstract type assert (`::Integer`) in the method body

PR JuliaLang#59442 aims to make this generic method be used for `Array` and
`Memory`, by deleting the more specific methods.

It is my understanding that method static parameters and abstract type
asserts can cause performance issues, when they're not optimized out,
which happens when the argument types are not concretely inferred.

So I'm putting up this PR, which eliminates the method static
parameters and the `typeassert`, to prevent any possible regressions
from PR JuliaLang#59442.

Another thing that is necessary for preserving good abstract inference
is to convert the index to `Int` before using it. This is correct
it there can't be more than `typemax(Int)` dimensions anyway.
oscardssmith pushed a commit to nsajko/julia that referenced this pull request Sep 23, 2025
The generic method `size(::AbstractArray, ::Any)` currently has:

* method static parameters

* an abstract type assert (`::Integer`) in the method body

PR JuliaLang#59442 aims to make this generic method be used for `Array` and
`Memory`, by deleting the more specific methods.

It is my understanding that method static parameters and abstract type
asserts can cause performance issues, when they're not optimized out,
which happens when the argument types are not concretely inferred.

So I'm putting up this PR, which eliminates the method static
parameters and the `typeassert`, to prevent any possible regressions
from PR JuliaLang#59442.

Another thing that is necessary for preserving good abstract inference
is to convert the index to `Int` before using it. This is correct
it there can't be more than `typemax(Int)` dimensions anyway.
vtjnash pushed a commit that referenced this pull request Sep 26, 2025
…rt (#59465)

The generic method `size(::AbstractArray, ::Any)` currently has:

* method static parameters
* an abstract type assert (`::Integer`) in the method body

PR #59442 aims to make this generic method be used for `Array` and
`Memory`, by deleting the more specific methods.

It is my understanding that method static parameters and abstract type
asserts can cause performance issues, when they're not optimized out,
which happens when the argument types are not concretely inferred.

So I'm putting up this PR, which eliminates the method static parameters
and the `typeassert`, to prevent any possible regressions from PR
#59442.

Another thing that is necessary for preserving good abstract inference
is to convert the index argument to `Int` before using it. This is
correct as there can't be more than `typemax(Int)` dimensions anyway
(the `N` type parameter to `AbstractArray` is an `Int` value).
@nsajko nsajko force-pushed the eliminate_some_Array-specific_methods_of_size branch from 2565bed to 66fe55a Compare September 26, 2025 19:27
@nsajko nsajko marked this pull request as ready for review September 26, 2025 20:57
@oscardssmith oscardssmith merged commit 59bc99d into JuliaLang:master Sep 27, 2025
8 checks passed
@nsajko nsajko deleted the eliminate_some_Array-specific_methods_of_size branch September 27, 2025 03:59
xal-0 pushed a commit to xal-0/julia that referenced this pull request Sep 30, 2025
…rt (JuliaLang#59465)

The generic method `size(::AbstractArray, ::Any)` currently has:

* method static parameters
* an abstract type assert (`::Integer`) in the method body

PR JuliaLang#59442 aims to make this generic method be used for `Array` and
`Memory`, by deleting the more specific methods.

It is my understanding that method static parameters and abstract type
asserts can cause performance issues, when they're not optimized out,
which happens when the argument types are not concretely inferred.

So I'm putting up this PR, which eliminates the method static parameters
and the `typeassert`, to prevent any possible regressions from PR
JuliaLang#59442.

Another thing that is necessary for preserving good abstract inference
is to convert the index argument to `Int` before using it. This is
correct as there can't be more than `typemax(Int)` dimensions anyway
(the `N` type parameter to `AbstractArray` is an `Int` value).
xal-0 pushed a commit to xal-0/julia that referenced this pull request Sep 30, 2025
…9442)

Changes:

* Eliminate some nongeneric `length` methods:

    * `GenericMemory`

    * `Slice`

    * `IdentityUnitRange`

    * `CartesianIndices`

    * `LogicalIndex`

    * `CodeUnits`

    * `UnsafeView` (from the `Random` stdlib)

* Eliminate some nongeneric two-argument `size` methods:

    *  `GenericMemory`

    * `Array`

    * `BitVector`

Depends on PR JuliaLang#59465 to prevent abstract inference regressions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrays [a, r, r, a, y, s] iteration Involves iteration or the iteration protocol

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants