-
Notifications
You must be signed in to change notification settings - Fork 236
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
refactor: ckb-script package overhaul #4803
Open
xxuejie
wants to merge
6
commits into
nervosnetwork:develop
Choose a base branch
from
xxuejie:ckb-script-overhaul
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
chenyukang
reviewed
Feb 11, 2025
chenyukang
previously approved these changes
Feb 11, 2025
eval-exec
reviewed
Feb 11, 2025
eval-exec
previously approved these changes
Feb 11, 2025
driftluo
previously approved these changes
Feb 11, 2025
zhangsoledad
previously approved these changes
Feb 11, 2025
b95c684
3595333
to
b95c684
Compare
quake
reviewed
Feb 12, 2025
eval-exec
previously approved these changes
Feb 12, 2025
quake
previously approved these changes
Feb 12, 2025
This commit revisits ckb-script package, it re-architects the whole data flow within ckb-script, to make it simpler and more maintainable
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.
416cf43
to
8b6654a
Compare
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.
This commit revisits ckb-script package, it re-architects the whole data flow within ckb-script, to make it simpler and more maintainable
What problem does this PR solve?
Issue Number: close #xxx
Problem Summary:
What is changed and how it works?
Proposal: xxx
What's Changed:
Related changes
owner/repo
:Check List
Tests
Side effects
Release note