Skip to content

Mark the vectorized CRC update methods noinline #118544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 8, 2025

Conversation

AndyAyersMS
Copy link
Member

This works around a deficiency in the jit inliner. When it tries to inline a large method with many important callees into a small method, it runs out of budget trying to inline the callees.

The budget is set based on the size of the root method, so the vectorized update methods have enough budget to inline their callees.

Fixes #114383.

This works around a deficiency in the jit inliner. When it tries to inline a large
method with many important callees into a small method, it runs out of budget trying to inline
the callees.

The budget is set based on the size of the root method, so the vectorized update methods
have enough budget to inline their callees.

Fixes dotnet#114383.
@Copilot Copilot AI review requested due to automatic review settings August 8, 2025 18:00
Copy link
Contributor

@Copilot Copilot AI left a comment

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 addresses a JIT inliner deficiency by marking vectorized CRC update methods as NoInlining. The issue occurs when the JIT inliner attempts to inline large methods with many important callees into smaller methods, causing it to run out of inlining budget. By preventing inlining of the vectorized methods themselves, the budget allocation is preserved for their internal callees.

  • Adds [MethodImpl(MethodImplOptions.NoInlining)] attribute to prevent inlining of the vectorized update methods
  • Includes explanatory comments documenting the JIT inliner workaround rationale

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc64.Vectorized.cs Adds NoInlining attribute and comment to UpdateVectorized method
src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc32.Vectorized.cs Adds NoInlining attribute and comment to UpdateVectorized method

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Aug 8, 2025
@AndyAyersMS
Copy link
Member Author

AndyAyersMS commented Aug 8, 2025

@EgorBo PTAL
FYI @jeffhandley @dotnet/jit-contrib

Locally on an avx-512 box

System.IO.Hashing.Tests.Crc64_AppendPerf.Append(BufferSize: 10240)

Method Job Toolchain BufferSize Mean Error StdDev Median Min Max Ratio Allocated Alloc Ratio
Append Job-ANGECJ main+pr 10240 836.5 ns 1.71 ns 1.60 ns 835.6 ns 835.0 ns 840.6 ns 1.00 - NA
Append Job-DHYFAN base 10240 836.5 ns 0.65 ns 0.61 ns 836.3 ns 835.5 ns 837.6 ns 1.00 - NA
Append Job-OLZPAR main 10240 3,890.1 ns 3.85 ns 3.60 ns 3,890.5 ns 3,884.8 ns 3,896.8 ns 4.65 - NA

Copy link
Member

@tannergooding tannergooding left a comment

Choose a reason for hiding this comment

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

LGTM

I wonder if there's some kind of tool, analyzer, or log function we could use to help identify and automatically make the right decision in cases like this.

Ideally we could figure out how much code is actually being generated for a given call and make better decisions, but that's of course expensive and non-trivial.

@AndyAyersMS
Copy link
Member Author

@EgorBot --arm --intel System.IO.Hashing.Tests.*.Append*

@AndyAyersMS AndyAyersMS merged commit b9bdc40 into dotnet:main Aug 8, 2025
82 checks passed
@AndyAyersMS AndyAyersMS added area-System.IO.Hashing and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Perf] Regressions from increasing inline budget
3 participants