Skip to content

refactor(@angular/build): use xxhash-wasm for fast non-cryptographic content hashing - #33798

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:perf/fast-hashing-xxhash
Aug 7, 2026
Merged

refactor(@angular/build): use xxhash-wasm for fast non-cryptographic content hashing#33798
alan-agius4 merged 1 commit into
angular:mainfrom
clydin:perf/fast-hashing-xxhash

Conversation

@clydin

@clydin clydin commented Aug 7, 2026

Copy link
Copy Markdown
Member

Replace OpenSSL SHA-256 with xxhash-wasm for internal non-cryptographic hashing across the build system. This includes JavaScript transformer cache keys, persistent load result disk caches, incremental TypeScript compiler source file versioning, i18n inlining cache keys, stylesheet compilation configuration hashes, and dev server asset ETags. By utilizing a 64-bit non-cryptographic hash backed by WebAssembly, hashing throughput is significantly increased while eliminating V8 OpenSSL C++ context allocations and garbage collection churn during cold and incremental builds.

@clydin clydin added the target: minor This PR is targeted for the next minor release label Aug 7, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a faster, non-cryptographic 64-bit hashing mechanism using xxhash-wasm to replace Node's createHash('sha256') across various build tools, cache keys, and ETags. While this is a great performance improvement, the review highlights critical issues with the synchronous fallback in calculateHashSync, which introduces non-determinism and can break incremental compilation. Additionally, changing calculateGlobalStylesheetConfigHash to an asynchronous function requires updating all of its callers, and ensureXxhash should cache its initialization promise to prevent redundant WebAssembly compilations under high concurrency.

Comment thread packages/angular/build/src/utils/hash.ts Outdated
Comment thread packages/angular/build/src/tools/angular/angular-host.ts Outdated
Comment thread packages/angular/build/src/builders/unit-test/test-discovery.ts Outdated
Comment thread packages/angular/build/src/tools/esbuild/stylesheets/stylesheet-cache-key.ts Outdated
Comment thread packages/angular/build/src/utils/hash.ts
@clydin
clydin force-pushed the perf/fast-hashing-xxhash branch from ccf4cdc to ecfc614 Compare August 7, 2026 00:40
…content hashing

Replace OpenSSL SHA-256 with xxhash-wasm for internal non-cryptographic hashing across the build system. This includes JavaScript transformer cache keys, persistent load result disk caches, incremental TypeScript compiler source file versioning, i18n inlining cache keys, stylesheet compilation configuration hashes, and dev server asset ETags. By utilizing a 64-bit non-cryptographic hash backed by WebAssembly, hashing throughput is significantly increased while eliminating V8 OpenSSL C++ context allocations and garbage collection churn during cold and incremental builds.
@clydin
clydin force-pushed the perf/fast-hashing-xxhash branch from ecfc614 to 9227e43 Compare August 7, 2026 00:54
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Aug 7, 2026
@alan-agius4
alan-agius4 merged commit cda8830 into angular:main Aug 7, 2026
66 of 68 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

@clydin
clydin deleted the perf/fast-hashing-xxhash branch August 7, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants