Greatly improve Checksum performance#12444
Merged
DustinCampbell merged 9 commits intodotnet:mainfrom Nov 6, 2025
Merged
Conversation
There's also some clean up in this change to the compiler benchmark to read different sets of tag helpers from resources.
These were copied from Roslyn, which copied them from the .NET runtime to avoid taking a dependency on the System.IO.Hashing package.
XxHash128 is a much faster hashing algorithm. Plus, it only needs 128 bits, allowing Checksum to become just a couple of Int64s.
chsienki
approved these changes
Nov 4, 2025
ToddGrun
reviewed
Nov 4, 2025
ToddGrun
reviewed
Nov 4, 2025
src/Shared/Microsoft.AspNetCore.Razor.Utilities.Shared/Utilities/Checksum.Builder.cs
Show resolved
Hide resolved
Contributor
|
This is awesome! Thanks! |
davidwengier
approved these changes
Nov 4, 2025
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Note
I had originally thought that this change would impact the VMR, but that turns out to not be the case. I had expected that the JSON serialization changes would need to be ported, but I had forgotten that the Razor SDK doesn't actually care about checksums. Instead, I validated that the Razor SDK builds fine with this changee.
This change brings work done in Roslyn awhile back to use XXHash128 rather than SHA256 for checksum calculation. With checksums only needing 128 bits, the
Checksumtype can be converted to a struct that contains a couple ofInt64s.As part of this change, I updated the
TagHelperChecksumBenchmarkand ran it with the current and newChecksums. The performance of creating checksums is an order of magnitude more efficient.Old Checksum benchmark
New Checksum benchmark
CI Build: https://dev.azure.com/dnceng/internal/_build/results?buildId=2832100&view=results
Test Insertion: https://dev.azure.com/devdiv/DevDiv/_git/VS/pullrequest/685921
Toolset Run: https://dev.azure.com/dnceng/internal/_build/results?buildId=2831447&view=results