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

Use DocumentKey to avoid holding Razor project/document snapshots when the most recent will be used. #11644

Merged
merged 12 commits into from
Mar 21, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
AbstractRazorProjectInfoDriver: Use HashSet for unique items
Update AbstractRazorProjectInfoDriver to use a dedicated HashSet instance to compute the most recent unique items.
  • Loading branch information
DustinCampbell committed Mar 19, 2025
commit 63e910b6450e3968019e4fda2a6b80573b332437
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ private sealed record Remove(ProjectKey ProjectKey) : Work(ProjectKey);

private readonly CancellationTokenSource _disposeTokenSource;
private readonly AsyncBatchingWorkQueue<Work> _workQueue;
private readonly HashSet<Work> _workerSet;
private readonly Dictionary<ProjectKey, RazorProjectInfo> _latestProjectInfoMap;
private ImmutableArray<IRazorProjectInfoListener> _listeners;
private readonly TaskCompletionSource<bool> _initializationTaskSource;
@@ -37,6 +38,7 @@ protected AbstractRazorProjectInfoDriver(ILoggerFactory loggerFactory, TimeSpan?
{
Logger = loggerFactory.GetOrCreateLogger(GetType());

_workerSet = new(Comparer.Instance);
_disposeTokenSource = new();
_workQueue = new AsyncBatchingWorkQueue<Work>(delay ?? DefaultDelay, ProcessBatchAsync, _disposeTokenSource.Token);
_latestProjectInfoMap = [];
@@ -89,7 +91,9 @@ protected void StartInitialization()

private async ValueTask ProcessBatchAsync(ImmutableArray<Work> items, CancellationToken token)
{
foreach (var work in items.GetMostRecentUniqueItems(Comparer.Instance))
_workerSet.Clear();

foreach (var work in items.GetMostRecentUniqueItems(_workerSet))
{
if (token.IsCancellationRequested)
{