Repository navigation
Remove forced inlining from Span<T>.ToArray - #132635
Merged
Merged
Conversation
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-runtime |
Member
|
Could you please also apply ImmutableArray simplifications that were noticed during investigation of this issue #119713 (comment) ? |
LE0-Lin
force-pushed
the
perf-span-toarray-inlining-119713
branch
from
August 22, 2026 00:51
b607656 to
10f7f4f
Compare
LE0-Lin
force-pushed
the
perf-span-toarray-inlining-119713
branch
from
August 22, 2026 00:52
10f7f4f to
c870d73
Compare
Contributor
|
@MihuBot -nuget |
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Member
|
/ba-g infrastructure timeouts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #119713.
Summary
Span<T>.ToArray()is currently marked withAggressiveInlining, whileReadOnlySpan<T>.ToArray()is not.This change removes the forced-inlining hint from
Span<T>.ToArray()andallows the JIT to make its normal profitability decision.
Rationale
Existing JIT-diff experiments discussed in #119713 evaluated both ways of
making the two implementations consistent.
Adding
AggressiveInliningtoReadOnlySpan<T>.ToArray()resulted insubstantially more code-size churn, including multiple regressions.
By comparison, removing
AggressiveInliningfromSpan<T>.ToArray()had amuch smaller code-size impact.
Given that
ToArray()allocates and does not necessarily benefit from beingforcibly inlined at every call site, removing the hint is the more conservative
way to make the implementations consistent.
The runtime behavior of
ToArray()is unchanged.Validation
The code change is limited to removing the
AggressiveInliningattribute.The JIT-diff experiments referenced in the issue discussion are:
Credit to @xtqqczze for running the JIT-diff experiments used to evaluate the
tradeoff.