Commit 9052ec7
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-on: https://dart-review.googlesource.com/c/sdk/+/451820
Reviewed-by: Paul Berry <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>1 parent 4bc9a47 commit 9052ec7
File tree
3 files changed
+42
-8
lines changed- pkg/analyzer/lib/src
- dart/analysis
- fine
3 files changed
+42
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| |||
1925 | 1925 | | |
1926 | 1926 | | |
1927 | 1927 | | |
| 1928 | + | |
1928 | 1929 | | |
1929 | 1930 | | |
1930 | 1931 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
243 | | - | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
244 | 247 | | |
245 | 248 | | |
246 | 249 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
490 | 491 | | |
491 | 492 | | |
492 | 493 | | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
493 | 503 | | |
494 | 504 | | |
495 | 505 | | |
| |||
547 | 557 | | |
548 | 558 | | |
549 | 559 | | |
| 560 | + | |
550 | 561 | | |
551 | 562 | | |
552 | 563 | | |
| |||
581 | 592 | | |
582 | 593 | | |
583 | 594 | | |
584 | | - | |
| 595 | + | |
585 | 596 | | |
| 597 | + | |
586 | 598 | | |
587 | 599 | | |
588 | 600 | | |
589 | 601 | | |
590 | 602 | | |
591 | 603 | | |
592 | 604 | | |
593 | | - | |
| 605 | + | |
594 | 606 | | |
595 | 607 | | |
596 | 608 | | |
| |||
620 | 632 | | |
621 | 633 | | |
622 | 634 | | |
| 635 | + | |
623 | 636 | | |
624 | 637 | | |
625 | 638 | | |
| |||
665 | 678 | | |
666 | 679 | | |
667 | 680 | | |
| 681 | + | |
668 | 682 | | |
669 | 683 | | |
670 | 684 | | |
| |||
867 | 881 | | |
868 | 882 | | |
869 | 883 | | |
| 884 | + | |
870 | 885 | | |
871 | 886 | | |
872 | 887 | | |
873 | 888 | | |
874 | 889 | | |
| 890 | + | |
875 | 891 | | |
876 | 892 | | |
877 | 893 | | |
| |||
881 | 897 | | |
882 | 898 | | |
883 | 899 | | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
884 | 909 | | |
885 | 910 | | |
886 | 911 | | |
| |||
1525 | 1550 | | |
1526 | 1551 | | |
1527 | 1552 | | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
1528 | 1559 | | |
1529 | 1560 | | |
1530 | 1561 | | |
| |||
2524 | 2555 | | |
2525 | 2556 | | |
2526 | 2557 | | |
2527 | | - | |
2528 | | - | |
2529 | | - | |
| 2558 | + | |
| 2559 | + | |
2530 | 2560 | | |
2531 | | - | |
| 2561 | + | |
2532 | 2562 | | |
2533 | 2563 | | |
2534 | 2564 | | |
| |||
0 commit comments