Ensure that transaction tokens are unique in the mempool benchmarks #1095
Merged
Ensure that transaction tokens are unique in the mempool benchmarks #1095
Conversation
a3ee2d9 to
67c9c4c
Compare
67c9c4c to
01e0654
Compare
Contributor
Author
|
We might want to switch to |
jasagredo
approved these changes
May 9, 2024
Data of type `Token` is what a mempool `TestBlock` transaction (`Tx`) consumes and produces. Previously, this token was a newtype around a `Word8`. There can only be around 256 unque `Word8` tokens, which means that its likely for this value to wrap around. In the current benchmark scenario, where we add linearly dependent transactions with only one input and output to a mempool, this wrap around was occurring and therefore the list of transaction that was being generated had many duplicates. The type of tokens is therefore changed to be a newtype around an `Int`, which won't wrap around (in a realistic benchmark). Abovementioned change exposed subtle performance effects on the mempool. Most of this can be attributed to the `Tx` type doubling as a `GenTxId`. The mempool keeps track of these identifiers in a set. Since there were only around 256 unique transactions, this set was rather small. Changing tokens to be `Int`s ensured that this set could grow much larger before becoming full, and that by itself has subtle effects on the performance of the mempool. Apart from changing the type of tokens, the mempool benchmark setup is reworked: * Transactions that are used as benchmark inputs are pre-generated and fully evaluated so that the generation work is not measured in the benchmarked function itself. * Instead of opening a mempool once and removing transactions after each benchmark run, a new mempool is opened in each benchmark run. Removing transactions proved to be prohibitively costly compared to the cost of opening a new mempool. * A new benchmark is added that measures just the mempool setup time. To obtain the cost of just adding the transactions without cost of opening the mempool, the time of this new benchmark can be manually subtracted from the full benchmark time.
01e0654 to
9f7a6ef
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.
No description provided.