From 333f0b42dce9cd745346793654adc72a8a91349b Mon Sep 17 00:00:00 2001 From: Andy Ayers Date: Fri, 8 Aug 2025 10:57:41 -0700 Subject: [PATCH] Mark the vectorized CRC update methods noinline 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. --- .../src/System/IO/Hashing/Crc32.Vectorized.cs | 4 ++++ .../src/System/IO/Hashing/Crc64.Vectorized.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc32.Vectorized.cs b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc32.Vectorized.cs index 2862e5b6b7e186..f263b6384acfc2 100644 --- a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc32.Vectorized.cs +++ b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc32.Vectorized.cs @@ -29,6 +29,10 @@ private static bool CanBeVectorized(ReadOnlySpan source) => // Computation for Generic Polynomials Using PCLMULQDQ Instruction" in December, 2009. // https://github.com/intel/isa-l/blob/33a2d9484595c2d6516c920ce39a694c144ddf69/crc/crc32_ieee_by4.asm // https://github.com/SixLabors/ImageSharp/blob/f4f689ce67ecbcc35cebddba5aacb603e6d1068a/src/ImageSharp/Formats/Png/Zlib/Crc32.cs#L80 + // + // Marking this as noinline so the JIT doesn't try and inline this and end up not inlining some of the calls it makes. + // + [MethodImpl(MethodImplOptions.NoInlining)] private static uint UpdateVectorized(uint crc, ReadOnlySpan source) { Debug.Assert(CanBeVectorized(source), "source cannot be vectorized."); diff --git a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc64.Vectorized.cs b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc64.Vectorized.cs index c2156bd473347a..98e5a6741bae59 100644 --- a/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc64.Vectorized.cs +++ b/src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc64.Vectorized.cs @@ -43,6 +43,10 @@ private static Vector128 LoadFromSource(ref byte source, nuint elementOff // "Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction" in December, 2009 and the // Intel reference implementation. // https://github.com/intel/isa-l/blob/33a2d9484595c2d6516c920ce39a694c144ddf69/crc/crc64_ecma_norm_by8.asm + // + // Marking this as noinline so the JIT doesn't try and inline this and end up not inlining some of the calls it makes. + // + [MethodImpl(MethodImplOptions.NoInlining)] private static ulong UpdateVectorized(ulong crc, ReadOnlySpan source) { Debug.Assert(CanBeVectorized(source), "source cannot be vectorized.");