Accelerate SHA-256 hashing on aarch64 (#20805)
[uv#19662](https://github.com/astral-sh/uv/pull/19662) started hashing
every downloaded wheel and source distribution so that a cached
distribution can be reused when a later operation requires its hash. On
ARM, `sha2` computes those hashes in software.
Enable the `sha2` assembly backend on non-Windows `aarch64`, allowing
wheel and source distribution downloads to use ARM SHA-256 instructions.
This preserves the caching behavior from
[uv#19662](https://github.com/astral-sh/uv/pull/19662) and also speeds
up `uv sync`, which already verified lockfile hashes before that change.
I ran the standard cold and warm installation benchmarks on Apple
Silicon with the 41-package Trio documentation workload. Wheels were
served from a local package index to reduce network noise. Results show
median wall time / mean user CPU across 12 runs:
| Benchmark | `0.11.18` (before) | `0.11.19` (after) | `main` | This
change |
| --- | ---: | ---: | ---: | ---: |
| Cold `uv pip sync` | 601.0 / 232.6 ms | 648.8 / 300.6 ms | 599.4 /
298.1 ms | 551.7 / 242.3 ms |
| Cold `uv sync` | 632.6 / 296.1 ms | 752.9 / 334.7 ms | 682.6 / 341.4
ms | 711.6 / 304.3 ms |
| Warm `uv pip sync` | 79.9 / 13.2 ms | 86.3 / 13.0 ms | 84.5 / 13.7 ms
| 82.7 / 13.8 ms |
| Warm `uv sync` | 74.8 / 11.7 ms | 82.4 / 11.7 ms | 84.3 / 12.4 ms |
69.3 / 11.9 ms |
Cold package installation uses 18.7% less CPU than `main`, putting it
within 4.2% of the
pre-[uv#19662](https://github.com/astral-sh/uv/pull/19662) baseline.
Cold project installation uses 10.9% less CPU; its wall time varies with
extraction and system activity.
Hashing a 9.7 MiB wheel 40 times improved from 1,076.5 ms to 208.2 ms on
macOS ARM (5.2×) and from 1,234.2 ms to 204.2 ms on Linux ARM (6.0×).
Co-authored-by: Zanie Blue <contact@zanie.dev>