Skip to content
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

Move to a callback-style approach to deserializing objects #72943

Merged
merged 3 commits into from
Apr 8, 2024

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Apr 8, 2024

Followup to #72929

Instead of allocating a large, temporary, array just to pass values around, only to then add those values to a cache, now we just pass a callback to the deserializer to allow it to directly add to the cache.

Note: this also has the benefit of allowing the cache to be filled as we deserialize an item, versus having to deserialize them all. This can help concurrent requests that then may find those items in teh cache, and not have to requery them.

--

Note: it's been a long standing goal of mine to make it so that we can read/write from those pipes without needing the intermediary stream. that would then allow us to populate the cache on the OOP side immediately as objects come across, without having to wait for them all to be written. I intend to make that possible this week.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner April 8, 2024 21:19
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 8, 2024
@CyrusNajmabadi
Copy link
Member Author

@ToddGrun ptal. note: there is a followup PR to thsi that takes this idea and spreads it much further, avoiding a lot of intermediary list allocs. THat PR also moves to a TArg-style model so we can do this work without allocating lambdas either. But i wanted to start here to get the ball rolling on the main idea.

@CyrusNajmabadi
Copy link
Member Author

#72944 is part 2 of this. But shoudl not be reviewed until this goes in.

var missingAsset = missingAssets[i];
Contract.ThrowIfTrue(currentIndex != index);

var missingChecksum = missingChecksums[index];

AddResult(missingChecksum, missingAsset);
Copy link
Member Author

Choose a reason for hiding this comment

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

there are several captures in this lambda. but they will go away in followup pr.

{
var results = new T[objectCount];
Copy link
Member Author

Choose a reason for hiding this comment

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

this is the major alloc removed.

@ToddGrun
Copy link
Contributor

ToddGrun commented Apr 8, 2024

Nice!

Copy link
Contributor

@ToddGrun ToddGrun left a comment

Choose a reason for hiding this comment

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

:shipit:

@CyrusNajmabadi CyrusNajmabadi enabled auto-merge April 8, 2024 23:02
@CyrusNajmabadi CyrusNajmabadi merged commit 7bf0187 into dotnet:main Apr 8, 2024
25 of 27 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 8, 2024
@CyrusNajmabadi CyrusNajmabadi deleted the avoidArray branch April 8, 2024 23:49
@CyrusNajmabadi
Copy link
Member Author

@jasonmalinowski For review when you get back.

@dibarbet dibarbet modified the milestones: Next, 17.11 P1 Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants