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

Provide a simple ArrayBuilder api that does not drop array builders when they have a large number of elements in them #77069

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Feb 5, 2025

Allows us to still use ArrayBuilder (and the api/ergonomics we like with it) while adjusting this piece of behavior in a few places where desired.

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner February 5, 2025 20:58
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 5, 2025
document, patternName, patternContainerOpt, declaredSymbolInfoKindsSet, t => results.Add(t), cancellationToken).ConfigureAwait(false);
// In parallel, search both the document requested, and any relevant 'related documents' we find for it. For the
// original document, search the entirety of it. For related documents, only search the spans of the
// partial-types/inheriting-types that we find for the types in this starting document.
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that makes sense.

@sandyarmstrong
Copy link
Member

Awesome! I tried it out on my end and verified I can see results from partial types and base classes. Cyrus suggested to me that with this change, AIOS should now adjust sorting so that results that are literally from the current document are prioritized, so I'll make sure we take care of that on our end.

Thanks for the insanely rapid turnaround after a fun and productive brainstorming chat this morning. <3

@CyrusNajmabadi
Copy link
Member Author

@genlu ptal

instance = GetInstance();
return new PooledDisposer<ArrayBuilder<T>>(instance);
}
=> GetInstance(discardLargeInstances: true, out instance);
Copy link
Contributor

Choose a reason for hiding this comment

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

discardLargeInstances

I like the array builder change, just wondering if it might make sense to have it in it's own PR so others interested in that change wouldn't need to look at the nav search stuff.

Also, feels like this might have conflicts with Tomas's PR: #76971

Copy link
Member Author

Choose a reason for hiding this comment

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

extracted out to just this.

@CyrusNajmabadi CyrusNajmabadi changed the title Find results in related 'partial type parts' when doing a scoped nav-to search. Provide a simple ArrayBuilder api that does not drop array builders when they have a large number of elements in them Feb 6, 2025
TypeDeclarationSyntax or
EnumDeclarationSyntax;
}
=> node is BaseNamespaceDeclarationSyntax or BaseTypeDeclarationSyntax;
Copy link
Contributor

Choose a reason for hiding this comment

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

BaseNamespaceDeclarationSyntax or BaseTypeDeclarationSyntax;

Is this change intended for this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. Was touchign the 'AddMembers' codepaths to update them to use this, and it hits thsi method. so i fixed it at the same time.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little confused by this change. Is EnumDeclarationSyntax not a top level node, or not one with members?

Copy link
Member Author

Choose a reason for hiding this comment

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

EnumDecl and TypeDecl are the only subclasses of BaseTypeDeclarationSyntax. So we already have a single type that checks for both. we don't need two type checks.

@@ -14,4 +14,19 @@ public static PooledDisposer<PooledStringBuilder> GetInstance(out StringBuilder
instance = pooledInstance;
return new PooledDisposer<PooledStringBuilder>(pooledInstance);
}

void IPooled.Free(bool discardLargeInstances)
Copy link
Contributor

Choose a reason for hiding this comment

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

Trying to understand how I would use a large instance StringBuilder. I assume I would need to do what is done in ArrayBuilder, add an ObjectPool to this class and then add a GetInstance method that potentially pulls from that pool?

Copy link
Member Author

Choose a reason for hiding this comment

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

PooledStringBuilder.GetInstance(out var sb)

You can now have this new behavior with:

PooledStringBuilder.GetInstance(discardLargeInstance: false, out var sb)

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:

…hen they have a large number of elements in them

Search related type sections in other documents when doing a document-filtered nav to search

Use null for simplicity

Apply suggestions from code review

Keep around large array instances for speedometer

Use a separate pool

Make consistent

Revert

Expose similar api on string builder
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 VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants