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

Pull reading of last storage subsystem out of lock (part2) #73295

Merged
merged 19 commits into from
May 2, 2024
Merged
2 changes: 1 addition & 1 deletion src/EditorFeatures/Test/Preview/PreviewWorkspaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public async Task TestPreviewServices()
using var previewWorkspace = new PreviewWorkspace(EditorTestCompositions.EditorFeatures.GetHostServices());
var persistentService = previewWorkspace.Services.SolutionServices.GetPersistentStorageService();

await using var storage = await persistentService.GetStorageAsync(SolutionKey.ToSolutionKey(previewWorkspace.CurrentSolution), CancellationToken.None);
var storage = await persistentService.GetStorageAsync(SolutionKey.ToSolutionKey(previewWorkspace.CurrentSolution), CancellationToken.None);
Assert.IsType<NoOpPersistentStorage>(storage);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tools/AnalyzerRunner/IncrementalAnalyzerRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task RunAsync(CancellationToken cancellationToken)
if (usePersistentStorage)
{
var persistentStorageService = _workspace.Services.SolutionServices.GetPersistentStorageService();
await using var persistentStorage = await persistentStorageService.GetStorageAsync(SolutionKey.ToSolutionKey(_workspace.CurrentSolution), cancellationToken).ConfigureAwait(false);
var persistentStorage = await persistentStorageService.GetStorageAsync(SolutionKey.ToSolutionKey(_workspace.CurrentSolution), cancellationToken).ConfigureAwait(false);
if (persistentStorage is NoOpPersistentStorage)
{
throw new InvalidOperationException("Benchmark is not configured to use persistent storage.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ public void GlobalSetup()
</Project>
</Workspace>");

var connectionPoolService = _workspace.ExportProvider.GetExportedValue<SQLiteConnectionPoolService>();
var asyncListener = _workspace.ExportProvider.GetExportedValue<IAsynchronousOperationListenerProvider>().GetListener(FeatureAttribute.PersistentStorage);

_storageService = new SQLitePersistentStorageService(connectionPoolService, new StorageConfiguration(), asyncListener);
_storageService = new SQLitePersistentStorageService(new StorageConfiguration(), asyncListener);

var solution = _workspace.CurrentSolution;
_storage = _storageService.GetStorageAsync(SolutionKey.ToSolutionKey(solution), CancellationToken.None).AsTask().GetAwaiter().GetResult();
Expand All @@ -83,7 +82,6 @@ public void GlobalCleanup()
}

_document = null!;
_storage.Dispose();
_storage = null!;
_storageService = null!;
_workspace.Dispose();
Expand Down
6 changes: 2 additions & 4 deletions src/Tools/IdeCoreBenchmarks/FindReferencesBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@ private async Task LoadSolutionAsync()
if (storageService == null)
throw new ArgumentException("Couldn't get storage service");

using (var storage = await storageService.GetStorageAsync(SolutionKey.ToSolutionKey(_workspace.CurrentSolution), CancellationToken.None))
{
Console.WriteLine("Sucessfully got persistent storage instance");
}
var storage = await storageService.GetStorageAsync(SolutionKey.ToSolutionKey(_workspace.CurrentSolution), CancellationToken.None);
Console.WriteLine("Successfully got persistent storage instance");

// There might be multiple projects with this name. That's ok. FAR goes and finds all the linked-projects
// anyways to perform the search on all the equivalent symbols from them. So the end perf cost is the
Expand Down
36 changes: 18 additions & 18 deletions src/Tools/IdeCoreBenchmarks/NavigateToBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,24 +183,24 @@ public async Task RunFullParallelIndexing()
Console.WriteLine("Starting indexing");

var storageService = _workspace.Services.SolutionServices.GetPersistentStorageService();
using (var storage = await storageService.GetStorageAsync(SolutionKey.ToSolutionKey(_workspace.CurrentSolution), CancellationToken.None))
{
Console.WriteLine("Successfully got persistent storage instance");
var start = DateTime.Now;
var indexTime = TimeSpan.Zero;
var tasks = _workspace.CurrentSolution.Projects.SelectMany(p => p.Documents).Select(d => Task.Run(
async () =>
{
var tree = await d.GetSyntaxRootAsync();
var stopwatch = SharedStopwatch.StartNew();
await TopLevelSyntaxTreeIndex.GetIndexAsync(d, default);
await SyntaxTreeIndex.GetIndexAsync(d, default);
indexTime += stopwatch.Elapsed;
})).ToList();
await Task.WhenAll(tasks);
Console.WriteLine("Indexing time : " + indexTime);
Console.WriteLine("Solution parallel: " + (DateTime.Now - start));
}
var storage = await storageService.GetStorageAsync(SolutionKey.ToSolutionKey(_workspace.CurrentSolution), CancellationToken.None);

Console.WriteLine("Successfully got persistent storage instance");
var start = DateTime.Now;
var indexTime = TimeSpan.Zero;
var tasks = _workspace.CurrentSolution.Projects.SelectMany(p => p.Documents).Select(d => Task.Run(
async () =>
{
var tree = await d.GetSyntaxRootAsync();
var stopwatch = SharedStopwatch.StartNew();
await TopLevelSyntaxTreeIndex.GetIndexAsync(d, default);
await SyntaxTreeIndex.GetIndexAsync(d, default);
indexTime += stopwatch.Elapsed;
})).ToList();
await Task.WhenAll(tasks);
Console.WriteLine("Indexing time : " + indexTime);
Console.WriteLine("Solution parallel: " + (DateTime.Now - start));

Console.WriteLine("DB flushed");
Console.ReadLine();
}
Expand Down
Loading