Skip to content

perf: skip constant-zero SHA_TEXT writes in the hw miner inner loop#802

Open
Gheop wants to merge 2 commits into
BitMaker-hub:mainfrom
Gheop:perf/hw-sha-fast-fill
Open

perf: skip constant-zero SHA_TEXT writes in the hw miner inner loop#802
Gheop wants to merge 2 commits into
BitMaker-hub:mainfrom
Gheop:perf/hw-sha-fast-fill

Conversation

@Gheop

@Gheop Gheop commented Jul 14, 2026

Copy link
Copy Markdown

What

The ESP32-S3/S2/C3 hardware miner (minerWorkerHw) fills the SHA engine text block for every nonce. Both the first-hash fill and the intermediate (second-hash) fill rewrite SHA_TEXT[9..14] with zero on every iteration — but those registers stay zero for the whole job: the fills never put anything else there and the engine does not clobber them.

Change

Zero SHA_TEXT[9..14] once per job, then skip them in the per-nonce fills (16 → 10 register writes per fill, in both the first and the second SHA block).

Result

Measured on a LilyGo T-Display-S3 (env:NerdminerV2), averaging the serial avg. hashrate over 75 s samples:

  • before: ~250 KH/s
  • after: ~300 KH/s (+18.8 %)

Verified correct with the VALIDATION build (each 16-bit hardware candidate re-checked against the software double-SHA): zero mismatches across the test runs.

Gheop added 2 commits July 14, 2026 20:08
The per-nonce text block fill rewrote SHA_TEXT[9..14] with zero on every
nonce, but the intermediate block already leaves those registers at zero
and the ESP32-S3 engine does not clobber them. Zero them once per job and
skip them in the hot loop (16 -> 10 register writes per fill).

Measured on LilyGo T-Display-S3: 250.5 -> 272.7 KH/s (+8.9%), validated
against software double-SHA (VALIDATION build, zero mismatches).
Same trick as the first-hash fill: SHA_TEXT[9..14] stay zero for the
whole job, so the intermediate (second sha256) block only needs to
rewrite the two registers that alternate between fills (16 -> 10 writes).

Measured on LilyGo T-Display-S3: 272.7 -> 292.2 KH/s (+7.2%), validated
against software double-SHA (VALIDATION build, zero mismatches).
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.

1 participant