[M] Change in dart/sdk[main]: AD. Issue 62760. Optimize LibraryContext.remove

0 views
Skip to first unread message

Johnni Winther (Gerrit)

unread,
Mar 13, 2026, 8:11:18 AMMar 13
to Konstantin Shcheglov, Morgan :), Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Konstantin Shcheglov and Morgan :)

Johnni Winther voted and added 1 comment

Votes added by Johnni Winther

Code-Review+1

1 comment

Commit Message
Line 7, Patchset 2 (Latest):AD. Issue 62760. Optimize LibraryContext.remove
Johnni Winther . unresolved

Add description of the change accomplishes.

Open in Gerrit

Related details

Attention is currently required from:
  • Konstantin Shcheglov
  • Morgan :)
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I5055606eead4dce2f65a0fcaf52acf0d53a93c61
Gerrit-Change-Number: 487701
Gerrit-PatchSet: 2
Gerrit-Owner: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Morgan :) <david...@google.com>
Gerrit-Attention: Morgan :) <david...@google.com>
Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
Gerrit-Comment-Date: Fri, 13 Mar 2026 12:11:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Konstantin Shcheglov (Gerrit)

unread,
Mar 13, 2026, 12:02:11 PMMar 13
to Johnni Winther, Morgan :), Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Morgan :)

Konstantin Shcheglov voted Commit-Queue+2

Commit-Queue+2
Open in Gerrit

Related details

Attention is currently required from:
  • Morgan :)
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I5055606eead4dce2f65a0fcaf52acf0d53a93c61
Gerrit-Change-Number: 487701
Gerrit-PatchSet: 4
Gerrit-Owner: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Johnni Winther <johnni...@google.com>
Gerrit-Reviewer: Konstantin Shcheglov <sche...@google.com>
Gerrit-Reviewer: Morgan :) <david...@google.com>
Gerrit-Attention: Morgan :) <david...@google.com>
Gerrit-Comment-Date: Fri, 13 Mar 2026 16:02:07 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Commit Queue (Gerrit)

unread,
Mar 13, 2026, 12:50:54 PMMar 13
to Konstantin Shcheglov, Johnni Winther, Morgan :), dart-analys...@google.com, rev...@dartlang.org

Commit Queue submitted the change with unreviewed changes

Unreviewed changes

2 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:

```
The name of the file: pkg/analyzer/lib/src/dart/analysis/library_context.dart
Insertions: 2, Deletions: 1.

@@ -161,7 +161,8 @@
var removedCycles = removed
.map((file) => file.kind.library?.internal_libraryCycle)
.nonNulls
- .toFixedList();
+ .where(loadedBundles.contains)
+ .toSet();
loadedBundles.removeAll(removedCycles);
removedKeys.addAll(removedCycles.map((cycle) => cycle.linkedKey));
}
```

Change information

Commit message:
AD. Issue 62760. Optimize LibraryContext.remove

Update library invalidation so `LibraryContext.remove()` can identify
removed library cycles directly from the removed files.

Previously file eviction cleared `file._kind` before
`LibraryContext.remove()` ran. Once that happened, the library cycle for
a removed file was no longer available, so removal had to scan all
loaded bundles and check whether any cycle contained one of the removed
files.

Run bundle removal while file kinds are still intact and have
`LibraryContext.remove()` derive the affected cycles directly from the
removed files. This lets it remove those cycles from `loadedBundles` and
collect their linked keys without scanning unrelated bundles.

To support this ordering, file-state pruning now exposes a hook that
runs before disposal begins, and file change handling collects affected
files before evicting them. This keeps library invalidation targeted and
avoids extra work during cache cleanup.
Change-Id: I5055606eead4dce2f65a0fcaf52acf0d53a93c61
Reviewed-by: Johnni Winther <johnni...@google.com>
Commit-Queue: Konstantin Shcheglov <sche...@google.com>
Files:
  • M pkg/analyzer/lib/src/dart/analysis/file_state.dart
  • M pkg/analyzer/lib/src/dart/analysis/library_context.dart
  • M pkg/analyzer/lib/src/dart/micro/resolve_file.dart
Change size: M
Delta: 3 files changed, 45 insertions(+), 32 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Johnni Winther
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: I5055606eead4dce2f65a0fcaf52acf0d53a93c61
Gerrit-Change-Number: 487701
Gerrit-PatchSet: 5
Gerrit-Owner: Konstantin Shcheglov <sche...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages