Skip to content

Commit b9bdc40

Browse files
authored
Mark the vectorized CRC update methods noinline (#118544)
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.
1 parent d2d41a6 commit b9bdc40

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc32.Vectorized.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ private static bool CanBeVectorized(ReadOnlySpan<byte> source) =>
2929
// Computation for Generic Polynomials Using PCLMULQDQ Instruction" in December, 2009.
3030
// https://github.com/intel/isa-l/blob/33a2d9484595c2d6516c920ce39a694c144ddf69/crc/crc32_ieee_by4.asm
3131
// https://github.com/SixLabors/ImageSharp/blob/f4f689ce67ecbcc35cebddba5aacb603e6d1068a/src/ImageSharp/Formats/Png/Zlib/Crc32.cs#L80
32+
//
33+
// Marking this as noinline so the JIT doesn't try and inline this and end up not inlining some of the calls it makes.
34+
//
35+
[MethodImpl(MethodImplOptions.NoInlining)]
3236
private static uint UpdateVectorized(uint crc, ReadOnlySpan<byte> source)
3337
{
3438
Debug.Assert(CanBeVectorized(source), "source cannot be vectorized.");

src/libraries/System.IO.Hashing/src/System/IO/Hashing/Crc64.Vectorized.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ private static Vector128<ulong> LoadFromSource(ref byte source, nuint elementOff
4343
// "Fast CRC Computation for Generic Polynomials Using PCLMULQDQ Instruction" in December, 2009 and the
4444
// Intel reference implementation.
4545
// https://github.com/intel/isa-l/blob/33a2d9484595c2d6516c920ce39a694c144ddf69/crc/crc64_ecma_norm_by8.asm
46+
//
47+
// Marking this as noinline so the JIT doesn't try and inline this and end up not inlining some of the calls it makes.
48+
//
49+
[MethodImpl(MethodImplOptions.NoInlining)]
4650
private static ulong UpdateVectorized(ulong crc, ReadOnlySpan<byte> source)
4751
{
4852
Debug.Assert(CanBeVectorized(source), "source cannot be vectorized.");

0 commit comments

Comments
 (0)