microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.53k stars 1.56k forks source link

Calls to `provideConfigurations` should batch multiple URI's when possible #10468

Open Colengms opened 1 year ago

Colengms commented 1 year ago

Currently, in provideCustomConfiguration, we're enumerating a list of URI's to provide configurations for, and requesting those configurations one at a time with separate calls to provider.provideConfigurations. Coalescing those URIs into an array and making a single call to provider.provideConfigurations with all of those URIs would allow configuration providers to better optimize how configurations are gathered.

Colengms commented 1 year ago

Reopening. https://github.com/microsoft/vscode-cpptools/issues/9003 did not fully address the issue. Rather, it ensures that multiple results from QueryTranslationUnitSource (i.e. to find a source for a header file), were requested in a single query.

The rest of this fix would involve updating provideCustomConfiguration to accept an array of URI's, updating provideCustomConfiguration to batch up the results from QueryTranslationUnitSource to request everything at once, and passing in an array in updateCustomConfigurations.

Unfortunately, we don't need configs for all of the results of QueryTranslationUnitSource. We had been trying one at a time, since we don't know which, if any, associated source files might provide configurations, and we only need one. So, requesting them all at once may actually create a lot of unnecessary work for the configuration provider, if all of those configurations are not easily available. This might get addressed by Unification with https://github.com/microsoft/vscode-cpptools/issues/7526 , as Unification work requires that all configurations are available up-front.