-
Notifications
You must be signed in to change notification settings - Fork 701
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
Remove some allocations under HttpFileSystemBasedFindPackageByIdResource.ConsumeFlatContainerIndexAsync #6265
base: dev
Are you sure you want to change the base?
Conversation
…rce.ConsumeFlatContainerIndexAsync
var normalizedVersionString = Identity.Version.ToNormalizedString(); | ||
string idInLowerCase = Id.ToLowerInvariant(); | ||
|
||
var builder = StringBuilderPool.Shared.Rent(256); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Roughly 50% of the string builders used in this codepath end up exceeding the 256 char limit, and thus aren't released back to the pool. I didn't address it in this PR, as delay calculating this ends up getting rid of the vast majority of the work, but it might be worth considering upping that 256 char limit used in StringBuilderPool.
/// This struct is used to read over a memory stream in parts, in order to avoid reading the entire stream into memory. | ||
/// It functions as a wrapper around <see cref="Utf8JsonStreamReader"/>, while maintaining a stream and a buffer to read from. | ||
/// </summary> | ||
internal ref struct Utf8JsonStreamReader |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test insertion based on commit 1 to get speedometer numbers: https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequest/610228 |
Bug
NuGet/Home#14095
Fixes:
Reduces allocation in this codepath
Description
Swtiched to using Utf8JsonStreamReader instead of newtonsoft for reading some json. However, this class wasn't available from what I could determine, so I took the easy route of just duplicating the code. This isn't great, and I'd love guidance on a better way to access this.
Changed PackageInfo.ContentUri to be calculated on a deferred basis as it's very expensive to calculate and is used quite infrequently (I saw about 0.1% of PackageInfo objects created actually get queried for that data)
PR Checklist