Skip to content

Simplify the constructs we use to sync changes between client and OOP.#60761

Merged
CyrusNajmabadi merged 11 commits intodotnet:mainfrom
CyrusNajmabadi:syncCleanup
Apr 15, 2022
Merged

Simplify the constructs we use to sync changes between client and OOP.#60761
CyrusNajmabadi merged 11 commits intodotnet:mainfrom
CyrusNajmabadi:syncCleanup

Conversation

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi commented Apr 15, 2022

Followup to #60758. Applies suggestion by @dibarbet to remove scope-id entirely and just use checksums to identify data.

@ghost ghost added the Area-IDE label Apr 15, 2022
@CyrusNajmabadi CyrusNajmabadi requested a review from dibarbet April 15, 2022 00:21
@CyrusNajmabadi CyrusNajmabadi marked this pull request as ready for review April 15, 2022 17:30
@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner April 15, 2022 17:30
@CyrusNajmabadi CyrusNajmabadi changed the title Sync cleanup Simplify the constructs we use to sync changes between client and OOP. Apr 15, 2022

using (Logger.LogBlock(FunctionId.SolutionChecksumUpdater_SynchronizePrimaryWorkspace, cancellationToken))
{
var checksum = await solution.State.GetChecksumAsync(cancellationToken).ConfigureAwait(false);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

pointless double computation. TryInvokeAsync already has to do this to get the solution checksum passed in the PinnedSolutionInfo that is passes into the lambda.

private static async Task TestAssetAsync(object data)
{
var sessionId = 0;
var sessionId = Checksum.Create(ImmutableArray.CreateRange(Guid.NewGuid().ToByteArray()));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

any dummy value woudl do. The mocks in these code actually end up not even using this.


// verify initial setup
await workspace.ChangeSolutionAsync(solution);
solution = workspace.CurrentSolution;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

prior code didn't represent how the workspace/oop actually work. We were forking the solution, but then telling the workspace to sync it's workspace (even though we hadn't applied the solution back to the workspace). This was working in the test code before because we were synthesizing a new workspace version every time we called UpdatePrimaryWorkspace. I changed that to actually pass the real value. But this means actually needing the real value to get updated. Hence the above lines.

}

// make sure we always move remote workspace forward
private int _solutionVersion = 0;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this was an ugly test hack. I've removed it and updated the tests themselves to do the right thing.

await client.TryInvokeAsync<IRemoteAssetSynchronizationService>(
solution,
async (service, solutionInfo, cancellationToken) => await service.SynchronizePrimaryWorkspaceAsync(solutionInfo, checksum, _solutionVersion++, cancellationToken),
async (service, solutionInfo, cancellationToken) => await service.SynchronizePrimaryWorkspaceAsync(solutionInfo, cancellationToken),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

passing solutionInfo and checksum is entirely redundant (PinnedSolutionInfo has always contained the solution checksum).

/// </summary>
[DataMember(Order = 0)]
public readonly int ScopeId;
public readonly Checksum SolutionChecksum;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

note: we already had this. it just moved up as being the actual fully unique identifier.

/// Map from solution checksum to its associated <see cref="SolutionState"/>.
/// </summary>
private readonly ConcurrentDictionary<int, (SolutionState Solution, SolutionReplicationContext ReplicationContext)> _solutionStates = new(concurrencyLevel: 2, capacity: 10);
private readonly ConcurrentDictionary<Checksum, (SolutionState Solution, SolutionReplicationContext ReplicationContext)> _solutionStates = new(concurrencyLevel: 2, capacity: 10);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

note: i'm going to see about merging this dictionary with the one above.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

@dibarbet this is ready for review now.

/// </summary>
[DataMember(Order = 0)]
public readonly int ScopeId;
public readonly Checksum SolutionChecksum;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

iirc we had something like a serialization version or something - does that matter here? I don't think so since this is just OOP communication (which should always be using the same bits) but just wanted to confirm

@CyrusNajmabadi CyrusNajmabadi merged commit 7a9af1c into dotnet:main Apr 15, 2022
@ghost ghost added this to the Next milestone Apr 15, 2022
@CyrusNajmabadi CyrusNajmabadi deleted the syncCleanup branch April 15, 2022 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants