Skip to content

Perform progression search in two phases.#58785

Merged
CyrusNajmabadi merged 13 commits into
dotnet:mainfrom
CyrusNajmabadi:progressionSearch
Jan 14, 2022
Merged

Perform progression search in two phases.#58785
CyrusNajmabadi merged 13 commits into
dotnet:mainfrom
CyrusNajmabadi:progressionSearch

Conversation

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi commented Jan 11, 2022

Partial fix for:

AB#1431669 and

First phase searches normal documents. Second phase searches generated docs. This allows progression search to still show the full set of matches, while not forcing the full results to come once the generated results are computed.

This is a partial fix as we still need to update the tests here. Specifically, the total time to do the full search has gotten longer (As we are generating and searching generated docs). However, we should be measuring time to get the initial set of docs as that will still be as fast as nav-to is with the normal indices and caches.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner January 11, 2022 22:24
@ghost ghost added the Area-IDE label Jan 11, 2022
// that result might not contain full data
// Ensure that we actually complete all our remaining progress items so that the progress bar completes.
await ProgressItemsCompletedAsync(_remainingProgressItems, cancellationToken).ConfigureAwait(false);
Debug.Assert(_remainingProgressItems == 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.

it was becoming a PITA for all the control flow to keep track of this and set progress to the 'finished' state at teh end. So now we just keep track ourselves across all codepaths and just jump to teh end unilaterally.

[Flags]
internal enum NavigateToSearchScope
{
RegularDocuments = 0b01,
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.

where do the enum values come from?

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.

Not sure what you mean. Can you clarify?

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.

Ah - I meant why the value 0b01?

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.

Ah. It's a flags enum. So I prefer using binary to show the values and how they can be combined.

// providing this extra information will make UI to show indication to users
// that result might not contain full data
// Ensure that we actually complete all our remaining progress items so that the progress bar completes.
await ProgressItemsCompletedAsync(_remainingProgressItems, cancellationToken).ConfigureAwait(false);
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.

so is the only case where _remainingProgressItems would not be zero is when an exception is thrown and we aren't able to complete the search?

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.

not sure how possible this is, but could this race? For example we have 5 searches remaining, one document throws triggering this catch (we subtract 5 from the remaining), but then one of the previously in progress document searches also completes, subtracting another 1 and we get -1.

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.

so is the only case where _remainingProgressItems would not be zero is when an exception is thrown and we aren't able to complete the search?

No. A totally normal thing that causes this is if we also shortcircuit remaining work. i can add comment, btu this happens if we search cached documents and find results (during solution load). in that case, we skip the other searches.

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.

not sure how possible this is, but could this race?

It should not. This is async-serial. Meaning this should never run concurrently with any finding work.

Comment thread src/Features/Core/Portable/NavigateTo/NavigateToSearcher.cs Outdated
}

await SearchFullyLoadedProjectsAsync(orderedProjects, seenItems, cancellationToken).ConfigureAwait(false);
await SearchGeneratedDocumentsAsync(seenItems, cancellationToken).ConfigureAwait(false);
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.

since this is streaming, wouldn't we have reported the non source generated results first already?

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.

i'm not sure what you mean :)

// Create two queries. One to find results in normal docs, and one to find results in generated
// docs. That way if the generated docs take a long time we can still report the regular doc
// results immediately.
graphQueries.Add(new SearchGraphQuery(searchParameters.SearchQuery.SearchString, NavigateToSearchScope.RegularDocuments, threadingContext, asyncListener));
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.

similar question as above, the code was already searching non-source generated first and since we're streaming results back wouldn't they have been reported first? why do we need to explicitly separate the search?

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.

similar question as above, the code was already searching non-source generated first and since we're streaming results back wouldn't they have been reported first? why do we need to explicitly separate the search?

Ah, i see the question. Progression is not streaming. We have to grab the produced-sub-graph (what we make) and apply it at once to the full graph. So this allows us to break that into two chunks. The produced-sub-graph for teh normal docs, and the produced-sub-graph for the generated docs. we can apply each to the larger graph when each finishes.

Co-authored-by: David Barbet <dibarbet@gmail.com>
@CyrusNajmabadi CyrusNajmabadi enabled auto-merge (squash) January 13, 2022 22:49
@CyrusNajmabadi CyrusNajmabadi merged commit 9a69692 into dotnet:main Jan 14, 2022
@ghost ghost added this to the Next milestone Jan 14, 2022
@CyrusNajmabadi CyrusNajmabadi deleted the progressionSearch branch January 14, 2022 20:49
@RikkiGibson RikkiGibson modified the milestones: Next, 17.2.P1 Feb 4, 2022
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.

4 participants