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

Switch to a callback style in the asset finding code #73017

Merged
merged 2 commits into from
Apr 14, 2024

Conversation

CyrusNajmabadi
Copy link
Member

Extracted out of #73013.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner April 14, 2024 08:26
@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 14, 2024
@CyrusNajmabadi CyrusNajmabadi requested a review from ToddGrun April 14, 2024 08:30
@@ -58,7 +58,7 @@ public void AddAllTo(HashSet<Checksum> checksums)
AssetPath assetPath,
TextDocumentStates<TState> documentStates,
HashSet<Checksum> searchingChecksumsLeft,
Dictionary<Checksum, object> result,
Action<Checksum, object> onAssetFound,
Copy link
Member Author

Choose a reason for hiding this comment

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

instead of passing in dictionaries, we pass in callbacks to invoke when the item is found. In this Pr, this will still end up populating a dictionary. However in #73013 this changes to populating a channel that then allows another task to be reading from the channle when items are found, writing the assets out to our pipe between oop and the host.

await FindAssetsAsync(assetPath, checksumsToFind, assetMap, cancellationToken).ConfigureAwait(false);
await FindAssetsAsync(
assetPath, checksumsToFind,
(checksum, asset) => assetMap[checksum] = asset,
Copy link
Contributor

Choose a reason for hiding this comment

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

(checksum, asset) => assetMap[checksum] = asset,

Containing PR gets rid of the closure allocation (or will once #73013 (comment) is addressed)

using var _ = Creator.CreateResultMap(out var resultPool);

await scope.FindAssetsAsync(AssetPath.FullLookupForTesting, checksumPool.Object, resultPool, cancellationToken).ConfigureAwait(false);
var checksums = new ReadOnlyMemory<Checksum>([checksum]);
await scope.AddAssetsAsync(AssetPath.FullLookupForTesting, checksums, resultPool, cancellationToken).ConfigureAwait(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

AddAssetsAsync

Why the switch to AddAssetsAsync here?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a test call and was cleaner. Just goes through the to level path without having to make a set and make a lambda.

@@ -97,10 +100,10 @@ public async ValueTask<object> GetAssetAsync(Checksum checksum, CancellationToke
{
Contract.ThrowIfTrue(checksum == Checksum.Null);

using var checksumPool = Creator.CreateChecksumSet(checksum);
Copy link
Contributor

Choose a reason for hiding this comment

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

CreateChecksumSet

Looks like this might have been the only caller of this, maybe remove if so.

@ToddGrun
Copy link
Contributor

Nice, I like where this is headed!

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 merged commit 91f2a8b into dotnet:main Apr 14, 2024
27 checks passed
@CyrusNajmabadi CyrusNajmabadi deleted the callbackStyle branch April 14, 2024 16:09
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Apr 14, 2024
@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