-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: Fix a performance regression caused by the refactoring work
In the original refactoring work, the verifying context data is kept in `Arc<SgData>` structure, which contains `Arc<TxData>`, which then contains `Arc<ResolvedTransaction>`. Accessing a specific field on a CKB transaction requires traversing through 3 `Arc` structures, which would be 3 levels of indirection. Benchmarks show that those nested memory indirections cost us ~3% of transaction verifying performance, our best guess is that the nested indirections result in enough cache misses to cause the differences. This commit changes the code so instead of nested `Arc`s, we now use flattened structs that then contain a series of `Arc`s. Now at most one `Arc` would get in the way to access a specific field of the CKB transaction to verify. Note that `consensus` and `tx_env` still hids in 2 nested levels of `Arc`, here we are balancing the nested levels of `Arc`, and the number of `Arc`s contained in the flattend `TxData` and `SgData` structure. Right now we work under the assumption that if consensus parameters are required indeed, a nested level of indirection won't be the bottleneck. However, this might or might not change in the future, when it becomes a problem, we will revisit the tradeoff then.
- Loading branch information
Showing
18 changed files
with
319 additions
and
290 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.