[M] Change in dart/sdk[main]: AD. Collect LibraryCycle(s) to load iteratively.

0 views
Skip to first unread message

Morgan :) (Gerrit)

unread,
Mar 13, 2026, 3:49:58 AMMar 13
to Konstantin Shcheglov, Johnni Winther, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Johnni Winther and Konstantin Shcheglov

Morgan :) added 1 comment

File pkg/analyzer/lib/src/dart/analysis/library_context.dart
Line 194, Patchset 2 (Latest): List<LibraryCycle> _collectCyclesToLoad(LibraryCycle root) {
Morgan :) . unresolved

There is a specific algorithm for doing this called Tarjan's algorithm, it's implemented in package:graph here

https://github.com/dart-lang/tools/blob/main/pkgs/graphs/lib/src/strongly_connected_components.dart

I never took the time to fully understand how it works and why it's faster, but I have been very happy with its performance in build_runner :)

Open in Gerrit

Related details

Attention is currently required from:
  • Johnni Winther
  • Konstantin Shcheglov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not 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: I2379c33f79f55157506c3fa0f7672df98064b46b
Gerrit-Change-Number: 487720
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: Konstantin Shcheglov <sche...@google.com>
Gerrit-Attention: Johnni Winther <johnni...@google.com>
Gerrit-Comment-Date: Fri, 13 Mar 2026 07:49:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Johnni Winther (Gerrit)

unread,
Mar 13, 2026, 6:17:04 AMMar 13
to Konstantin Shcheglov, Morgan :), Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Konstantin Shcheglov

Johnni Winther voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention is currently required from:
  • Konstantin Shcheglov
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: I2379c33f79f55157506c3fa0f7672df98064b46b
Gerrit-Change-Number: 487720
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: Konstantin Shcheglov <sche...@google.com>
Gerrit-Comment-Date: Fri, 13 Mar 2026 10:17:00 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Konstantin Shcheglov (Gerrit)

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

Konstantin Shcheglov voted and added 1 comment

Votes added by Konstantin Shcheglov

Commit-Queue+2

1 comment

File pkg/analyzer/lib/src/dart/analysis/library_context.dart
Line 194, Patchset 2 (Latest): List<LibraryCycle> _collectCyclesToLoad(LibraryCycle root) {
Morgan :) . unresolved

There is a specific algorithm for doing this called Tarjan's algorithm, it's implemented in package:graph here

https://github.com/dart-lang/tools/blob/main/pkgs/graphs/lib/src/strongly_connected_components.dart

I never took the time to fully understand how it works and why it's faster, but I have been very happy with its performance in build_runner :)

Konstantin Shcheglov

Yes, we already used this algorithm while building LibraryCycle(s) in `library_graph.dart`. The code here is just a simple iterative post-order traversal over already built DAG of cycles.

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: I2379c33f79f55157506c3fa0f7672df98064b46b
Gerrit-Change-Number: 487720
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-Comment-Date: Fri, 13 Mar 2026 15:39:09 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: Morgan :) <david...@google.com>
satisfied_requirement
open
diffy

Commit Queue (Gerrit)

unread,
Mar 13, 2026, 11:39:25 AMMar 13
to Konstantin Shcheglov, Johnni Winther, Morgan :), dart-analys...@google.com, rev...@dartlang.org

Commit Queue submitted the change

Change information

Commit message:
AD. Collect LibraryCycle(s) to load iteratively.

Instead of loading them recursively.
This caused stack overflows in case of long (5000, 4000, 3000) chains
of importing libraries.
Change-Id: I2379c33f79f55157506c3fa0f7672df98064b46b
Reviewed-by: Johnni Winther <johnni...@google.com>
Commit-Queue: Konstantin Shcheglov <sche...@google.com>
Files:
  • M pkg/analyzer/lib/src/dart/analysis/library_context.dart
  • M pkg/analyzer/lib/src/dart/analysis/library_graph.dart
Change size: M
Delta: 2 files changed, 51 insertions(+), 11 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: I2379c33f79f55157506c3fa0f7672df98064b46b
Gerrit-Change-Number: 487720
Gerrit-PatchSet: 3
Gerrit-Owner: Konstantin Shcheglov <sche...@google.com>
open
diffy
satisfied_requirement

Morgan :) (Gerrit)

unread,
Mar 13, 2026, 12:03:23 PMMar 13
to Konstantin Shcheglov, Commit Queue, Johnni Winther, dart-analys...@google.com, rev...@dartlang.org

Morgan :) added 2 comments

Patchset-level comments
File-level comment, Patchset 3 (Latest):
Morgan :) . resolved

Ah good, LGTM then :) thanks!

File pkg/analyzer/lib/src/dart/analysis/library_context.dart
Line 194, Patchset 2: List<LibraryCycle> _collectCyclesToLoad(LibraryCycle root) {
Morgan :) . resolved

There is a specific algorithm for doing this called Tarjan's algorithm, it's implemented in package:graph here

https://github.com/dart-lang/tools/blob/main/pkgs/graphs/lib/src/strongly_connected_components.dart

I never took the time to fully understand how it works and why it's faster, but I have been very happy with its performance in build_runner :)

Konstantin Shcheglov

Yes, we already used this algorithm while building LibraryCycle(s) in `library_graph.dart`. The code here is just a simple iterative post-order traversal over already built DAG of cycles.

Morgan :)

Acknowledged

Open in Gerrit

Related details

Attention set is empty
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: I2379c33f79f55157506c3fa0f7672df98064b46b
Gerrit-Change-Number: 487720
Gerrit-PatchSet: 3
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-Comment-Date: Fri, 13 Mar 2026 16:03:19 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Morgan :) <david...@google.com>
Comment-In-Reply-To: Konstantin Shcheglov <sche...@google.com>
satisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages