Skip to content

Switch AsyncCompletion to new pooled CompletionItemList based APIs#61477

Merged
genlu merged 19 commits intodotnet:main-vs-depsfrom
genlu:NewEditor
Jun 13, 2022
Merged

Switch AsyncCompletion to new pooled CompletionItemList based APIs#61477
genlu merged 19 commits intodotnet:main-vs-depsfrom
genlu:NewEditor

Conversation

@genlu
Copy link
Copy Markdown
Member

@genlu genlu commented May 24, 2022

Address AB#1475048

LOH allocation for CompletionItem[] and CompletionItemWithHighlight[] are gone.
image

this will break our CI integration tests, so I queued DartLab integration test run with latest VS build which passed
https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=6272608&view=results

@ghost ghost added the Area-IDE label May 24, 2022
@genlu genlu requested a review from olegtk May 24, 2022 00:48
referencing what we need out of the macos SDK. -->
<PackageDownload Include="Microsoft.macOS.Ref" Version="[$(MicrosoftmacOSRefVersion)]" />
<Reference Include="$(NuGetPackageRoot)microsoft.macos.ref\$(MicrosoftmacOSRefVersion)\ref\net6.0\Xamarin.Mac.dll" />
<Reference Include="$(NuGetPackageRoot)microsoft.macos.ref\$(MicrosoftmacOSRefVersion)\ref\net6.0\Microsoft.macOS.dll" />
Copy link
Copy Markdown
Member

@davidwengier davidwengier May 24, 2022

Choose a reason for hiding this comment

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

@sandyarmstrong this is (one of) the same change as you're making in #61250

Is this a problem? Or do we need to wait for the 6.0.300 bump in VS Mac?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ping @sandyarmstrong, could you please take a look at this and let me know if it's OK? Thanks

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.

You should merge #61250 first. But then we will not be able to insert Roslyn with this change for at least a few days while we finish up the work to bump VSMac to use the 6.0.300 SDK and the newer macos workload.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

But then we will not be able to insert Roslyn with this change for at least a few days

@davidwengier Would this be a problem in case we need to merge this sooner?

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.

I merged #61250, we should be ready to consume it in VSMac in the next few days.

@genlu genlu force-pushed the NewEditor branch 2 times, most recently from d7f1e17 to 46d939c Compare May 31, 2022 21:17
@genlu genlu changed the base branch from main to main-vs-deps June 2, 2022 00:16
@genlu genlu marked this pull request as ready for review June 2, 2022 20:37
@genlu genlu requested a review from a team as a code owner June 2, 2022 20:37
@genlu genlu requested a review from a team June 2, 2022 20:37
@genlu genlu requested a review from a team as a code owner June 2, 2022 20:37
This reverts commit c44e868.
@genlu
Copy link
Copy Markdown
Member Author

genlu commented Jun 6, 2022

The referenced version of editor package in latest commit is pending insertion
https://devdiv.visualstudio.com/DefaultCollection/DevDiv/_git/VS/pullrequest/403261

}
}

private static SegmentedList<VSCompletionItem> SortCompletionitems(IAsyncCompletionSession session, AsyncCompletionSessionInitialDataSnapshot data)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. ideally move this next to the caller.

return items;
}

private sealed class VSItemComparer : IComparer<VSCompletionItem>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

would it be possible for us to jsut expose this IComparer to the caller so that they can own smart data management and sorting? we jsut own comparing?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yea, sounds good to me, I will bring this up with Editor team.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what's the result of this talk?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Done with pass :)

genlu and others added 4 commits June 9, 2022 12:09
…nSource.cs

Co-authored-by: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
…nSource.cs

Co-authored-by: CyrusNajmabadi <cyrus.najmabadi@gmail.com>
@genlu
Copy link
Copy Markdown
Member Author

genlu commented Jun 10, 2022

@CyrusNajmabadi PTAL, thanks!

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Integration tests seem to be totally broken. :(

itemsBuilder.AddRange(context1.Items);
itemsBuilder.AddRange(context2.Items);

var completionList = session.CreateCompletionList(context1.ItemList.Concat(context2.ItemList));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

which .Concat is this? is it a single alloc that just streams over both lists? or is it an O(N) alloc that copies everything into a new list?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think this is the one streams over both lists w/o copying (System.Linq.Enumerable.Concat)

itemsBuilder.AddRange(data.InitialSortedList);
itemsBuilder.AddRange(expandedContext.Items);
var combinedList = itemsBuilder.MoveToImmutable();
var combinedItemList = session.CreateCompletionList(data.InitialSortedItemList.Concat(expandedContext.ItemList));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same question about this concat. is it a single-alloc? or an O(n) copy?

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

CompletionList is now:

    public sealed class CompletionList<T> : IReadOnlyList<T>, IDisposable

Who is expected to dispose this.

Note: calling this CompletionList was very confusing as i thought that meant it was a list of completoin items. When really it's just a list of anything, it's just used in completion.

@genlu
Copy link
Copy Markdown
Member Author

genlu commented Jun 10, 2022

Who is expected to dispose this.

IT's associated to a async completion session, and Editor will free them after the session is done (dismissed/committed/etc)

@olegtk
Copy link
Copy Markdown
Contributor

olegtk commented Jun 10, 2022

I agree CompletionList<T> is somewhat confusing name. It reflects existing state of completion API where completion items are passed as ImmutableArray<CompletionItem> and also ImmutableArray<CompletionItemWithHighlight> and CompletionItem and CompletionItemWithHighlight types do not have common supertype...
The only way to create CompletionList<T> is through IAsyncCompletionSession though, so that somewhat makes it a bit clearer when used.

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

I'm pretty ok with teh code. But i would like some sort of integration test pass to validate that this isn't going to break things for some unforseen reason. Thanks!

@genlu genlu enabled auto-merge June 13, 2022 18:01
@genlu genlu merged commit e23d497 into dotnet:main-vs-deps Jun 13, 2022
@ghost ghost added this to the Next milestone Jun 13, 2022
@genlu genlu deleted the NewEditor branch June 13, 2022 19:14
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants