bench: fix stateful benchmark setup and inputs#130
Closed
l0rinc wants to merge 4 commits into
Closed
Conversation
4d97ae8 to
e5befb4
Compare
e5befb4 to
228ab96
Compare
`WalletBalanceMine` duplicated `WalletBalanceClean` exactly. Remove the duplicate registration so the balance benchmark list stays distinct.
`MempoolCheckEphemeralSpends` wrote every prevout to `tx2.vin[0]` instead of `tx2.vin[i]`. That left only one child input pointing at the parent transaction, while the remaining inputs kept default prevouts. Write each prevout to `vin[i]` instead. Add an assertion that the last child input spends the last parent output.
`setup()` in nanobench runs once per epoch, not once per timed call. If an epoch executes the benchmark body multiple times, `setup()` can silently leave later iterations with different preconditions. Fail fast when `setup()` is combined with anything other than `epochIterations(1)`.
3ae3920 to
e82db0b
Compare
`CHACHA20` and `FSCHACHA20POLY1305` kept one cipher object alive across timed calls. That advanced the stream state across samples, and `FSChaCha20Poly1305` could cross a rekey boundary. Rebuild the cipher in `setup()` for each timed call so each sample starts from the same state.
e82db0b to
b333754
Compare
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.
Problem
The
CHACHA20andFSCHACHA20POLY1305benchmarks reused a single cipher object across timed calls.That advanced the stream state across samples, so later samples no longer measured work from the same starting point.
A few other benchmarks could benefit from the same iteration-stability treatment, but that is outside the scope of this PR.
While investigating this, it also became clear that
MempoolCheckEphemeralSpendsonly populatedvin[0]in its loop, and thatWalletBalanceMineduplicatedWalletBalanceClean.The same review also showed that nanobench
setup()can be misused as though it runs once per timed call.Fix
Rebuild the
ChaChaciphers insetup()and pair that setup withepochIterations(1)so each timed call starts from the same state.Add a nanobench assertion that
setup()is only used withepochIterations(1).Also fix the ephemeral spend benchmark inputs and remove the duplicate wallet balance benchmark.
Context
Found while reviewing bitcoin#35018, which led to a few additional benchmark fixes.