-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize Transaction Hashing #25
Labels
Comments
davecgh
added a commit
to btcsuite/btcdb
that referenced
this issue
Oct 27, 2013
This commit optimizes InsertBlock slightly by using the cached transaction hashes instead of recomputing them. Also, while here, use the ShaHash.IsEqual function to do comparisons for consistency. This is ongoing work towards btcsuite/btcd#25. ok @drahn.
davecgh
added a commit
to btcsuite/btcutil
that referenced
this issue
Oct 27, 2013
Currently, transaction hash caching is provided via Block directly, but a transaction is not always part of a block and there are several cases where only the transaction needs to be dealt with without wanting to pass the entire block and transaction index around to be able to get at the cached hash. So, this commit adds a new type named Tx which is a wrapper that provides easier and more efficient manipulation of raw wire protocol transactions. It memoizes the hash for the transaction on its first access so subsequent accesses don't have to repeat the relatively expensive hashing operations. The idea is the callers can pass around pointers to these Tx types instead of raw btcwire.MsgTx pointers. For now, the Block API has not been changed, but the plan is to change it to provide access to these wrapped transactions rather than having it do the transaction hash caching directly. This is only the first part of a series of changes working towards optimizations noted in btcsuite/btcd#25.
davecgh
added a commit
to btcsuite/btcutil
that referenced
this issue
Oct 27, 2013
This commit adds both positive and negative tests for the new Tx type to bring its coverage to 100%. This is part of the ongoing transaction hash optimization effort noted in btcsuite/btcd#25.
davecgh
added a commit
to btcsuite/btcutil
that referenced
this issue
Oct 28, 2013
This commit adds two new functions to the Block API for working with the recently added Tx type from the Block. These new functions are named Tx and Transactions. Tx returns a transactions for the specified index as a Tx and also memoizes it so subsequent calls are more efficient. Transactions returns a slice of all transactions in the Block wrapped in a Tx. This is part of the ongoing transaction hash optimization effort noted in btcsuite/btcd#25.
davecgh
added a commit
to btcsuite/btcutil
that referenced
this issue
Oct 28, 2013
This commit adds both positive and negative tests for the new Tx and Transactions Block API functions. This is part of the ongoing transaction hash optimization effort noted in btcsuite/btcd#25.
davecgh
added a commit
to btcsuite/btcchain
that referenced
this issue
Oct 28, 2013
This is part of the ongoing transaction hash optimization effort noted in btcsuite/btcd#25.
davecgh
added a commit
that referenced
this issue
Oct 28, 2013
This commit updates btcd to work with the new btcchain APIs which now accept btcutil.Tx instead of raw btcwire.MsgTx. It also modifies the transaction memory pool to store btcutil.Tx. This is part of the ongoing transaction hash optimization effort noted in #25.
This has been completed as of commit 08fc305. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Profiling has shown that transaction hashing is a reasonable candidate for optimization as it is currently takes around 6% of the block handling time. Since hashing is such a large part of block and transaction handling, this is not all that unexpected. However, there are various cases where a transaction is hashed more than once instead of using the cached version to avoid recomputing it.
The text was updated successfully, but these errors were encountered: