Skip to content

Commit

Permalink
Merge pull request #73295 from CyrusNajmabadi/noDispose
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi authored May 2, 2024
2 parents 32a019d + 09f7017 commit d8f3b0b
Show file tree
Hide file tree
Showing 25 changed files with 265 additions and 658 deletions.
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
4 changes: 1 addition & 3 deletions src/Tools/IdeBenchmarks/SQLitePersistentStorageBenchmark.cs
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

0 comments on commit d8f3b0b

Please sign in to comment.