Skip to content

Conversation

@aplavin
Copy link
Member

@aplavin aplavin commented Dec 1, 2025

Accessors are known to be hard for the compiler to optimize sometimes, with compiler heuristics to stop optimizing triggering quite early.
Here, I make the compiler "try harder": things like avoiding argument splatting, and making small inner functions more optimizable.

I recently used Accessors getall/setall with a few tens of elements – up to ~50. With these optimizations, it compiles down to almost nothing, while before there was a lot of dynamic dispatch inside.
Tests pass both before and after. Maybe I'll think of a short self-contained test demonstrating the improvements and add it... But I confirm in my testing that these changes greatly improve performance in such a regime.

Comment on lines +137 to +138
@generated _concat(a::NTuple{N,Any}, b::NTuple{M,Any}) where {N,M} =
:(Base.Cartesian.@ntuple $(N + M) i -> i $N ? a[i] : b[i - $N])
Copy link
Member

Choose a reason for hiding this comment

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

There is no reliably fast way to do this in Base?

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