Skip to content

bench(precompile): measure the blake2 portable compression path - #3848

Merged
rakita merged 1 commit into
bluealloy:mainfrom
4waan:bench/blake2-portable
Aug 14, 2026
Merged

rakita merged 1 commit into
bluealloy:mainfrom
4waan:bench/blake2-portable

Conversation

@4waan

@4waan 4waan commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

The blake2 benches call run, which reaches the compression function through compress. On x86 that detects AVX2 at runtime and returns before the portable implementation, so on the x86_64 CI runner the blake2/*_rounds benches only ever time the AVX2 code. The portable one is what no_std, zkVM and non-x86 targets actually execute, and it is currently unmeasured everywhere except on hosts with no SIMD path.

Add blake2 portable/{2,10,12,64}_rounds, calling the portable function directly so it is timed on every host (regardless of what the dispatcher would pick). The round counts cover how SIGMA's period-10 schedule tiles: 2 is a partial tile, 10 exactly one, 12 one plus a remainder (standard BLAKE2b), 64 several..

Reaching it needs compress_portable, a #[doc(hidden)] wrapper. The dispatcher is the only supported entry point, so the wrapper documents that it is not public API and exists for measurement.

Existing benchmark names are left untouched so their histories are carried.

The blake2 benches call `run`, which reaches the compression function
through `compress`. On x86 that detects AVX2 at runtime and returns
before the portable implementation, so on the x86_64 CI runner the
`blake2/*_rounds` benches only ever time the AVX2 code. The portable
one is what `no_std`, zkVM and non-x86 targets actually execute, and it
is currently unmeasured everywhere except on hosts with no SIMD path.

Add `blake2 portable/{2,10,12,64}_rounds`, calling the portable function
directly so it is timed on every host regardless of what the dispatcher
would pick. The round counts cover how SIGMA's period-10 schedule tiles:
2 is a partial tile, 10 exactly one, 12 one plus a remainder (standard
BLAKE2b), 64 several.

Reaching it needs `compress_portable`, a `#[doc(hidden)]` wrapper. The
dispatcher is the only supported entry point, so the wrapper documents
that it is not public API and exists for measurement.

Existing benchmark names are left untouched so their history carries over.
@codspeed

codspeed Bot commented Aug 7, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 4.57%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 188 untouched benchmarks
🆕 4 new benchmarks
⏩ 1 skipped benchmark1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ Simulation blake2/2_rounds 3.3 µs 3.2 µs +4.57%
🆕 Simulation blake2 portable/10_rounds N/A 2.1 µs N/A
🆕 Simulation blake2 portable/12_rounds N/A 2.2 µs N/A
🆕 Simulation blake2 portable/2_rounds N/A 1.4 µs N/A
🆕 Simulation blake2 portable/64_rounds N/A 6.4 µs N/A

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing 4waan:bench/blake2-portable (286f3d6) with main (61e0a9f)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports. ↩

@rakita

rakita commented Aug 14, 2026

Copy link
Copy Markdown
Member

ack

@rakita
rakita merged commit 71e104d into bluealloy:main Aug 14, 2026
34 checks passed
This was referenced Aug 14, 2026
@RealiCZ RealiCZ mentioned this pull request Sep 18, 2026
30 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants