Skip to content

JIT: Enable tail await optimization in async versions in tier 0#130181

Merged
jakobbotsch merged 1 commit into
dotnet:mainfrom
jakobbotsch:avoid-tier0-continuation-allocs
Jul 3, 2026
Merged

JIT: Enable tail await optimization in async versions in tier 0#130181
jakobbotsch merged 1 commit into
dotnet:mainfrom
jakobbotsch:avoid-tier0-continuation-allocs

Conversation

@jakobbotsch

@jakobbotsch jakobbotsch commented Jul 3, 2026

Copy link
Copy Markdown
Member

Otherwise we will allocate continuations for paths that are going to be allocation free in tier 1. This shows up in traces when running TechEmpower benchmarks as a large amount of allocation happening until everything gets tiered up.

Diff on alloc metrics on platform-json:

-| Max Allocation Rate (B/sec)             | 110,580,952                             |
+| Max Allocation Rate (B/sec)             | 8,030,616                               |

FYI @BrennanConroy

Otherwise we will allocate continuations for paths that are going to be
allocation free in tier 1. This shows up in traces when running
TechEmpower benchmarks as a large amount of allocation happening before
everything is tiered.
Copilot AI review requested due to automatic review settings July 3, 2026 13:46
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jul 3, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR broadens the conditions under which async tail-await handling is enabled during import by switching from OptimizationEnabled() to Tier0OptimizationEnabled(), allowing the JIT to apply the same tail-await eligibility logic in Tier 0 (when Tier 0 opts are allowed) rather than waiting until Tier 1.

Changes:

  • Enable tail-await setup logic for async-version calls under Tier 0 optimization settings by using opts.Tier0OptimizationEnabled() in impSetupAsyncCall.
Comments suppressed due to low confidence (1)

src/coreclr/jit/importercalls.cpp:7301

  • This change enables additional tail-await handling in Tier0 by consulting canTailCall(...) during import. Since the PR is motivated by allocation/perf impact (TechEmpower startup / pre-tiering), it would be helpful to include concrete before/after data (e.g., allocation count/size and/or throughput) so reviewers can validate the net win and any potential Tier0 import-time overhead.
        if (opts.Tier0OptimizationEnabled() && ((prefixFlags & PREFIX_IS_ASYNC_VERSION_TAIL_AWAIT) != 0) &&
            (call->gtReturnType == info.compRetType))
        {
            CORINFO_METHOD_HANDLE exactCalleeHnd =
                ((call->AsCall()->gtCallType != CT_USER_FUNC) || call->AsCall()->IsVirtual()) ? nullptr : methHnd;

            asyncInfo.IsTailAwait =
                info.compCompHnd->canTailCall(info.compMethodHnd, methHnd, exactCalleeHnd, /* fIsTailPrefix */ false);
        }

@jakobbotsch

Copy link
Copy Markdown
Member Author

cc @dotnet/jit-contrib PTAL @EgorBo

@jakobbotsch jakobbotsch requested a review from EgorBo July 3, 2026 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants