perf: skip constant-zero SHA_TEXT writes in the hw miner inner loop#802
Open
Gheop wants to merge 2 commits into
Open
perf: skip constant-zero SHA_TEXT writes in the hw miner inner loop#802Gheop wants to merge 2 commits into
Gheop wants to merge 2 commits into
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 rewriteSHA_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 serialavg. hashrateover 75 s samples:Verified correct with the
VALIDATIONbuild (each 16-bit hardware candidate re-checked against the software double-SHA): zero mismatches across the test runs.