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.