-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Conversation
@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 |
#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); |
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.
there are several captures in this lambda. but they will go away in followup pr.
{ | ||
var results = new T[objectCount]; |
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.
this is the major alloc removed.
Nice! |
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.
@jasonmalinowski For review when you get back. |
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.