Skip to content
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

perf: Tweak slot calculation algorithm #90

merged 1 commit into from Nov 30, 2019


Copy link

xxuejie commented Nov 18, 2019

The previous slot calculation algorithm we use is optimized for large sequential programs. While this works for simpler cases, it often results in address conflicts in terms of programs with frequent branches. This PR changes the code to a new algorithm that balances between small basic blocks and large code segments. For our most common secp256k1 verification, this reduces ~15% of running time:

Benchmarking interpret secp256k1_bench via assembly: Warming up for 3.0000 s
Warning: Unable to complete 100 samples in 5.0s. You may wish to increase target time to 12.7s or reduce sample count to 40
interpret secp256k1_bench via assembly
                        time:   [2.5024 ms 2.5031 ms 2.5038 ms]
                        change: [-16.289% -16.251% -16.212%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 7 outliers among 100 measurements (7.00%)
  5 (5.00%) high mild
  2 (2.00%) high severe

For more complicated programs, such as bn256g2 where branches are more frequent, we noticed a 4x speedup.

@xxuejie xxuejie requested a review from nervosnetwork/ckb-code-review as a code owner Nov 18, 2019
@xxuejie xxuejie requested a review from nervosnetwork/ckb-dev Nov 18, 2019
@doitian doitian added this to 👀 Awaiting review in CKB Pull Requests Nov 26, 2019
CKB Pull Requests automation moved this from 👀 Awaiting review to ✅ Reviewer approved Nov 29, 2019
@xxuejie xxuejie merged commit 9f7ae6e into develop Nov 30, 2019
6 checks passed
6 checks passed
License Compliance All checks passed.
Travis CI - Branch Build Passed
Travis CI - Pull Request Build Passed
nervosnetwork.ckb-vm Build #20191118.2 succeeded
nervosnetwork.ckb-vm (UnitTest) UnitTest succeeded
nervosnetwork.ckb-vm (UnitTestAllFeatures) UnitTestAllFeatures succeeded
CKB Pull Requests automation moved this from ✅ Reviewer approved to Done Nov 30, 2019
@xxuejie xxuejie deleted the tweak-slot-calculation-algorithm branch Nov 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.