[M] Change in dart/sdk[main]: Fine. Short-circuit requirement checks with hashForRequirements

0 views
Skip to first unread message

Paul Berry (Gerrit)

unread,
Sep 26, 2025, 3:23:18 PM (3 days ago) Sep 26
to Konstantin Shcheglov, Johnni Winther, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Johnni Winther and Konstantin Shcheglov

Paul Berry voted and added 1 comment

Votes added by Paul Berry

Code-Review+1

1 comment

Patchset-level comments
Open in Gerrit

Related details

Attention is currently required from:
  • Johnni Winther
  • 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: Id3a631a680d21a994d4277a2d8f98040159c094d
Gerrit-Change-Number: 451820
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: Paul Berry <paul...@google.com>
Gerrit-Attention: Konstantin Shcheglov <sche...@google.com>
Gerrit-Attention: Johnni Winther <johnni...@google.com>
Gerrit-Comment-Date: Fri, 26 Sep 2025 19:23:15 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Konstantin Shcheglov (Gerrit)

unread,
Sep 26, 2025, 3:31:17 PM (3 days ago) Sep 26
to Paul Berry, Johnni Winther, Commit Queue, dart-analys...@google.com, rev...@dartlang.org
Attention needed from Johnni Winther

Konstantin Shcheglov voted Commit-Queue+2

Commit-Queue+2
Open in Gerrit

Related details

Attention is currently required from:
  • Johnni Winther
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: Id3a631a680d21a994d4277a2d8f98040159c094d
Gerrit-Change-Number: 451820
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: Paul Berry <paul...@google.com>
Gerrit-Attention: Johnni Winther <johnni...@google.com>
Gerrit-Comment-Date: Fri, 26 Sep 2025 19:31:14 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
open
diffy

Commit Queue (Gerrit)

unread,
Sep 26, 2025, 3:38:44 PM (3 days ago) Sep 26
to Konstantin Shcheglov, Paul Berry, Johnni Winther, dart-analys...@google.com, rev...@dartlang.org

Commit Queue submitted the change

Change information

Commit message:
Fine. Short-circuit requirement checks with hashForRequirements

Introduce a fast-path in fine-grained dependency validation by comparing
a precomputed per-library hash before doing field-by-field checks. When
the recorded hash matches the current
LibraryManifest.hashForRequirements, we skip detailed validation for
that library; otherwise we fall back to the existing thorough
comparisons.

Why
---
Validating RequirementsManifest.isSatisfied() was spending time
walking multiple fields and maps even when nothing changed. The new hash
captures exactly the manifest parts that the validator reads, so
equality implies the same outcome. This keeps correctness while
dramatically reducing the common-case cost.

What changed
------------
- Add LibraryRequirements.hashForRequirements and persist it in the
binary format (read/write).
- Initialize per-library requirements from the current manifest via
LibraryRequirements.fromManifest(), capturing the hash and exportMapId.
- Extend RequirementsManifest.isSatisfied() to:
* short-circuit per-library checks when hashes match,
* record lightweight perf counters ("libHash"/"libDetails" and
"libsHash"/"libsDetails") via OperationPerformanceImpl.
- Thread the new performance parameter through callers:
* AnalysisDriver._getLibraryDiagnosticsBundle()
* LibraryContext._getLinkedBundleEntry()
- Bump AnalysisDriver.DATA_VERSION to 564 to invalidate stale caches.

Performance
-----------
- getLibraryDiagnosticsBundle elapsed time:
70.105 ms → 3.557 ms (−66.548 ms, −94.93%; ~19.71× faster) across
1,646 runs.
- Counters (after):
apiSignature=193, libDetails=8, libHash=17,916, libsDetails=7,
libsHash=1,444.

Correctness
-----------
- The hash is computed from exactly the manifest fields that validation
consults; equal hashes guarantee the same decision.
- When hashes differ, full validation runs as before.
- Export combinators, re-export flags, and opaque API handling are
unchanged and still enforced.

Impact
------
Expect faster cache hits when resolving/validating
diagnostics bundles and linked cycles, with no behavioral changes when
libraries actually differ.
Change-Id: Id3a631a680d21a994d4277a2d8f98040159c094d
Reviewed-by: Paul Berry <paul...@google.com>
Commit-Queue: Konstantin Shcheglov <sche...@google.com>
Files:
  • M pkg/analyzer/lib/src/dart/analysis/driver.dart
  • M pkg/analyzer/lib/src/dart/analysis/library_context.dart
  • M pkg/analyzer/lib/src/fine/requirements.dart
Change size: M
Delta: 3 files changed, 42 insertions(+), 8 deletions(-)
Branch: refs/heads/main
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Paul Berry
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: Id3a631a680d21a994d4277a2d8f98040159c094d
Gerrit-Change-Number: 451820
Gerrit-PatchSet: 4
Gerrit-Owner: Konstantin Shcheglov <sche...@google.com>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages