[analyzer] Add one-shot and streaming BLAKE3-256 hashing
Prepare a faster replacement for the MD5 hashes used for file contents
and API signatures. Computing these hashes remains significant work even
when cached analysis avoids parsing and resolution. A pure Dart
implementation avoids native-library packaging and loading requirements.
Add ScalarBlake3 for one-shot hashing and ScalarBlake3Sink for
incremental input, finalization, and reset. Both produce full 32-byte
digests.
Add Blake3ApiSignature with a fixed 4 KiB staging buffer. Small
signatures use one-shot hashing; larger signatures stream through the
sink without accumulating the entire message. Preserve ASCII string
specialization and split values across buffer boundaries without
padding. Reading a digest finalizes the signature.
This CL adds the implementations and tests. Switching the analyzer's
existing MD5 call sites remains a follow-up.
An integration experiment used Blake3ApiSignature for API signatures and
ScalarBlake3 for file-content hashing. On an Apple M3 Max with Dart
3.15.0-edge ARM64 AOT, analyzing a frozen pkg/analyzer corpus of 1,630
Dart files (40.1 MB) produced these median times:
All MD5 All BLAKE3-256 Time reduction
Populated disk cache:
Wall 1.604 s 1.472 s 8.2%
Total CPU 1.635 s 1.500 s 8.3%
Empty disk cache:
Wall 12.722 s 12.448 s 2.2%
Total CPU 24.845 s 23.990 s 3.4%
Use scalar compression initially, with a planned upgrade to SIMD once
the analyzer's minimum SDK moves to Dart 3.14.
Change-Id: I7a172efd591b1da5d6871104b9287bdd55868f70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/562480
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Dart is:
Approachable: Develop with a strongly typed programming language that is consistent, concise, and offers modern language features like null safety and patterns.
Portable: Compile to ARM, x64, or RISC-V machine code for mobile, desktop, and backend. Compile to JavaScript or WebAssembly for the web.
Productive: Make changes iteratively: use hot reload to see the result instantly in your running app. Diagnose app issues using DevTools.
Dart's flexible compiler technology lets you run Dart code in different ways, depending on your target platform and goals:
Dart Native: For programs targeting devices (mobile, desktop, server, and more), Dart Native includes both a Dart VM with JIT (just-in-time) compilation and an AOT (ahead-of-time) compiler for producing machine code.
Dart Web: For programs targeting the web, Dart Web includes both a development time compiler (dartdevc) and a production time compiler (dart2js).
Dart is free and open source.
See LICENSE and PATENT_GRANT.
Visit dart.dev to learn more about the language, tools, and to find codelabs.
Browse pub.dev for more packages and libraries contributed by the community and the Dart team.
Our API reference documentation is published at api.dart.dev, based on the stable release. (We also publish docs from our beta and dev channels, as well as from the primary development branch).
See the contribution guide for details.
If you want to build Dart yourself, here is a guide to getting the source, preparing your machine to build the SDK, and building.
There are more documents in our repo at docs.
Future plans for Dart are included in the combined Dart and Flutter roadmap on the Flutter wiki.