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

dev: update vm initialization benchmark #1505

Conversation

bvrooman
Copy link
Contributor

@bvrooman bvrooman commented Nov 21, 2023

Updates #1502 to use dependent gas price for vm_initialization.

This PR:

  • Adapts the vm_initialization gas cost to a dependent cost
  • Modifies the VM initialization benchmark to use a variable size transaction
  • Updates fuel-vm to the newly created v0.42.2

This adds the following benchmarks to the suite:

vm_initialization/vm_initialization_with_tx_size_2191080                                                                            
                        time:   [385.44 µs 387.54 µs 389.67 µs]
                        thrpt:  [5.2368 GiB/s 5.2655 GiB/s 5.2942 GiB/s]
vm_initialization/vm_initialization_with_tx_size_2322152                                                                            
                        time:   [407.82 µs 409.68 µs 411.57 µs]
                        thrpt:  [5.2547 GiB/s 5.2790 GiB/s 5.3030 GiB/s]
vm_initialization/vm_initialization_with_tx_size_2453224                                                                            
                        time:   [424.74 µs 426.49 µs 428.23 µs]
                        thrpt:  [5.3354 GiB/s 5.3570 GiB/s 5.3791 GiB/s]
vm_initialization/vm_initialization_with_tx_size_2584296                                                                            
                        time:   [445.98 µs 450.28 µs 456.29 µs]
                        thrpt:  [5.2748 GiB/s 5.3452 GiB/s 5.3966 GiB/s]
vm_initialization/vm_initialization_with_tx_size_2715368                                                                            
                        time:   [468.75 µs 473.45 µs 479.25 µs]
                        thrpt:  [5.2767 GiB/s 5.3414 GiB/s 5.3949 GiB/s]
vm_initialization/vm_initialization_with_tx_size_2846440                                                                            
                        time:   [490.47 µs 494.15 µs 498.82 µs]
                        thrpt:  [5.3145 GiB/s 5.3647 GiB/s 5.4049 GiB/s]
vm_initialization/vm_initialization_with_tx_size_2977512                                                                            
                        time:   [505.35 µs 509.33 µs 513.98 µs]
                        thrpt:  [5.3952 GiB/s 5.4445 GiB/s 5.4873 GiB/s]
vm_initialization/vm_initialization_with_tx_size_3108584                                                                            
                        time:   [526.05 µs 529.11 µs 532.63 µs]
                        thrpt:  [5.4355 GiB/s 5.4717 GiB/s 5.5035 GiB/s]
vm_initialization/vm_initialization_with_tx_size_3239656                                                                            
                        time:   [547.18 µs 550.45 µs 553.83 µs]
                        thrpt:  [5.4478 GiB/s 5.4813 GiB/s 5.5140 GiB/s]
vm_initialization/vm_initialization_with_tx_size_3370728                                                                            
                        time:   [565.98 µs 568.75 µs 571.58 µs]
                        thrpt:  [5.4923 GiB/s 5.5195 GiB/s 5.5465 GiB/s]
vm_initialization/vm_initialization_with_tx_size_3501800                                                                            
                        time:   [585.76 µs 588.62 µs 591.47 µs]
                        thrpt:  [5.5139 GiB/s 5.5406 GiB/s 5.5677 GiB/s]
vm_initialization/vm_initialization_with_tx_size_3632872                                                                            
                        time:   [607.51 µs 610.83 µs 614.26 µs]
                        thrpt:  [5.5080 GiB/s 5.5390 GiB/s 5.5693 GiB/s]
vm_initialization/vm_initialization_with_tx_size_3763944                                                                            
                        time:   [630.00 µs 635.47 µs 642.49 µs]
                        thrpt:  [5.4560 GiB/s 5.5163 GiB/s 5.5642 GiB/s]
vm_initialization/vm_initialization_with_tx_size_3895016                                                                            
                        time:   [652.06 µs 656.04 µs 660.74 µs]
                        thrpt:  [5.4901 GiB/s 5.5294 GiB/s 5.5632 GiB/s]
vm_initialization/vm_initialization_with_tx_size_4026088                                                                            
                        time:   [664.38 µs 667.29 µs 670.21 µs]
                        thrpt:  [5.5946 GiB/s 5.6191 GiB/s 5.6438 GiB/s]
vm_initialization/vm_initialization_with_tx_size_4157160                                                                            
                        time:   [712.86 µs 718.35 µs 724.60 µs]
                        thrpt:  [5.3431 GiB/s 5.3896 GiB/s 5.4311 GiB/s]

Locally, this produces the following dependent cost for VM initialization:

        vm_initialization: DependentCost::LightOperation {
             base: 55476,
             units_per_gas: 39,
         },

@bvrooman bvrooman changed the base branch from master to feature/vm-initialisation-benchmark November 21, 2023 20:31
@bvrooman bvrooman added the no changelog Skip the CI check of the changelog modification label Nov 21, 2023
Comment on lines 100 to 103
const N: usize = 16;
for i in 0..N {
let increment = 1024 / N;
let script_size = 1024 * increment * i;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const N: usize = 16;
for i in 0..N {
let increment = 1024 / N;
let script_size = 1024 * increment * i;
const N: usize = 20;
for i in 0..N {
let size = 1 << i;

@bvrooman
Copy link
Contributor Author

Somewhat surprisingly, based on local benchmarking, it seems that vm_initialization is a LightOperation. I assumed it would be heavy. We will update the default_gas_costs when the updated benchmarks are merged and we get the results from the dedicated benchmark hardware.

@bvrooman bvrooman marked this pull request as ready for review November 22, 2023 03:35
@bvrooman bvrooman self-assigned this Nov 22, 2023
@bvrooman
Copy link
Contributor Author

There's currently a problem with the way the TX is created for the benchmark:

let size = 1 << i;
let script = vec![op::ret(1); size / Instruction::SIZE] 

When size is less than Instruction::SIZE, we create a 0 sized script due to the integer dvision. This is true for i = 0 and i = 1. The bench id is then the same in both cases, and the benchmarks fail. I will look into this further tomorrow.

Copy link
Collaborator

@xgreenx xgreenx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for help!

@xgreenx xgreenx merged commit 7956f19 into feature/vm-initialisation-benchmark Nov 22, 2023
8 checks passed
@xgreenx xgreenx deleted the bvrooman/dev/update-vm-initialization-benchmark branch November 22, 2023 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog Skip the CI check of the changelog modification
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants