Skip to content

Remove any/all overloads for ArrayPartition to eliminate invalidations#549

Closed
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude:remove-redundant-any-all-specializations
Closed

Remove any/all overloads for ArrayPartition to eliminate invalidations#549
ChrisRackauckas-Claude wants to merge 1 commit intoSciML:masterfrom
ChrisRackauckas-Claude:remove-redundant-any-all-specializations

Conversation

@ChrisRackauckas-Claude
Copy link
Copy Markdown
Contributor

Summary

  • Remove Base.any(f, A::ArrayPartition), Base.any(f::Function, A::ArrayPartition), Base.all(f, A::ArrayPartition), Base.all(f::Function, A::ArrayPartition) overloads
  • Keep Base.any(A::ArrayPartition) and Base.all(A::ArrayPartition) (these are removed too since the default works)

Context

The any(f::Function, A::ArrayPartition) specialization was the single largest source of method table invalidations when loading SciMLBase — 575 invalidated children — because it directly competes with Base.any(f::Function, a::AbstractArray; dims).

Since ArrayPartition <: AbstractVector with correct element iteration, the default Base implementations produce identical results. The custom versions iterated by partition component (A.x) rather than element-by-element, which is a minor optimization not worth 575 invalidations.

Test plan

  • All RecursiveArrayTools tests pass (113 partition tests, 232 indexing tests, etc.)
  • any/all with lambda predicates produce correct results on ArrayPartition
  • SciMLBase invalidation analysis confirms elimination of the largest invalidation tree
  • CI tests pass

🤖 Generated with Claude Code

The custom `any(f::Function, A::ArrayPartition)` and
`all(f::Function, A::ArrayPartition)` methods were the single largest
source of invalidations when loading SciMLBase (575 children for `any`
alone, caused by ambiguity with `Base.any(f::Function, a::AbstractArray)`).

Since ArrayPartition is an AbstractVector with correct iteration,
the default Base implementations produce identical results. The custom
versions just short-circuited by partition component rather than
element-by-element, which is a minor optimization not worth 575
invalidations.

All RecursiveArrayTools tests pass with this change.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ChrisRackauckas-Claude
Copy link
Copy Markdown
Contributor Author

Closing — this is subsumed by #547 which removes all these overrides as part of the AbstractArray breaking change.

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