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

feat: inline stack/memory methods #295

Merged
merged 1 commit into from
Sep 7, 2023
Merged

feat: inline stack/memory methods #295

merged 1 commit into from
Sep 7, 2023

Conversation

enitrat
Copy link
Collaborator

@enitrat enitrat commented Sep 6, 2023

see title and PR bot comment

Pull Request type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Other (please describe):

What is the current behavior?

Resolves: #294

What is the new behavior?

  • Inlined stack and memory functions for gas optimisations

Does this introduce a breaking change?

  • Yes
  • No

@enitrat
Copy link
Collaborator Author

enitrat commented Sep 6, 2023

IMPROVEMENTS
evm::tests::test_execution_context::test_execution_context_new 210140 --> 209540 | -0.29 %
evm::tests::test_instructions::test_block_information::test_basefee 110610 --> 97920 | -11.47 %
evm::tests::test_instructions::test_block_information::test_block_number_set_to_32 127730 --> 115040 | -9.94 %
evm::tests::test_instructions::test_block_information::test_block_timestamp_set_to_1692873993 127730 --> 115040 | -9.94 %
evm::tests::test_instructions::test_block_information::test_chainid_should_push_chain_id_to_stack 109810 --> 97320 | -11.37 %
evm::tests::test_instructions::test_block_information::test_gaslimit 110610 --> 97920 | -11.47 %
evm::tests::test_instructions::test_comparison_operations::test_and_max_and_max 256678 --> 196358 | -23.50 %
evm::tests::test_instructions::test_comparison_operations::test_and_two_random_uint 256678 --> 196358 | -23.50 %
evm::tests::test_instructions::test_comparison_operations::test_and_zero_and_max 256678 --> 196358 | -23.50 %
evm::tests::test_instructions::test_comparison_operations::test_byte_offset_out_of_range 304598 --> 244088 | -19.87 %
evm::tests::test_instructions::test_comparison_operations::test_byte_random_u256 6648248 --> 6587738 | -0.91 %
evm::tests::test_instructions::test_comparison_operations::test_exec_gt_false 257540 --> 196720 | -23.62 %
evm::tests::test_instructions::test_comparison_operations::test_exec_gt_false_equal 257540 --> 196720 | -23.62 %
evm::tests::test_instructions::test_comparison_operations::test_exec_gt_true 257540 --> 196720 | -23.62 %
evm::tests::test_instructions::test_comparison_operations::test_exec_lt_false 257540 --> 196720 | -23.62 %
evm::tests::test_instructions::test_comparison_operations::test_exec_lt_false_eq 257540 --> 196720 | -23.62 %
evm::tests::test_instructions::test_comparison_operations::test_exec_lt_true 257540 --> 196720 | -23.62 %
evm::tests::test_instructions::test_comparison_operations::test_exec_sar 25580176 --> 20638366 | -19.32 %
evm::tests::test_instructions::test_comparison_operations::test_exec_sgt 20774670 --> 15807750 | -23.91 %
evm::tests::test_instructions::test_comparison_operations::test_exec_shl 428690 --> 367680 | -14.23 %
evm::tests::test_instructions::test_comparison_operations::test_exec_shl_wrapping 283240 --> 222230 | -21.54 %
evm::tests::test_instructions::test_comparison_operations::test_exec_shr 24954270 --> 19971150 | -19.97 %
evm::tests::test_instructions::test_comparison_operations::test_exec_slt 20774670 --> 15807750 | -23.91 %
evm::tests::test_instructions::test_comparison_operations::test_is_zero_false 149200 --> 117090 | -21.52 %
evm::tests::test_instructions::test_comparison_operations::test_is_zero_true 149200 --> 117090 | -21.52 %
evm::tests::test_instructions::test_comparison_operations::test_not_max_uint 155080 --> 123170 | -20.58 %
evm::tests::test_instructions::test_comparison_operations::test_not_random_uint 155080 --> 123170 | -20.58 %
evm::tests::test_instructions::test_comparison_operations::test_not_zero 155080 --> 123170 | -20.58 %
evm::tests::test_instructions::test_comparison_operations::test_xor_different_pair 256678 --> 196358 | -23.50 %
evm::tests::test_instructions::test_comparison_operations::test_xor_half_same_pair 256678 --> 196358 | -23.50 %
evm::tests::test_instructions::test_comparison_operations::test_xor_same_pair 256678 --> 196358 | -23.50 %
evm::tests::test_instructions::test_duplication_operations::test_dup1 245750 --> 194520 | -20.85 %
evm::tests::test_instructions::test_duplication_operations::test_dup10 496010 --> 355790 | -28.27 %
evm::tests::test_instructions::test_duplication_operations::test_dup11 523090 --> 372980 | -28.70 %
evm::tests::test_instructions::test_duplication_operations::test_dup12 550170 --> 390170 | -29.08 %
evm::tests::test_instructions::test_duplication_operations::test_dup13 577250 --> 407360 | -29.43 %
evm::tests::test_instructions::test_duplication_operations::test_dup14 604330 --> 424550 | -29.75 %
evm::tests::test_instructions::test_duplication_operations::test_dup15 631410 --> 441740 | -30.04 %
evm::tests::test_instructions::test_duplication_operations::test_dup16 658490 --> 458930 | -30.31 %
evm::tests::test_instructions::test_duplication_operations::test_dup2 279370 --> 218270 | -21.87 %
evm::tests::test_instructions::test_duplication_operations::test_dup3 306450 --> 235460 | -23.17 %
evm::tests::test_instructions::test_duplication_operations::test_dup4 333530 --> 252650 | -24.25 %
evm::tests::test_instructions::test_duplication_operations::test_dup5 360610 --> 269840 | -25.17 %
evm::tests::test_instructions::test_duplication_operations::test_dup6 387690 --> 287030 | -25.96 %
evm::tests::test_instructions::test_duplication_operations::test_dup7 414770 --> 304220 | -26.65 %
evm::tests::test_instructions::test_duplication_operations::test_dup8 441850 --> 321410 | -27.26 %
evm::tests::test_instructions::test_duplication_operations::test_dup9 468930 --> 338600 | -27.79 %
evm::tests::test_instructions::test_environment_information::test__exec_callvalue 115510 --> 104420 | -9.60 %
evm::tests::test_instructions::test_environment_information::test_address_basic 127090 --> 114900 | -9.59 %
evm::tests::test_instructions::test_environment_information::test_calldata_size 112410 --> 99720 | -11.29 %
evm::tests::test_instructions::test_environment_information::test_calldataload 2224116 --> 2192316 | -1.43 %
evm::tests::test_instructions::test_environment_information::test_calldataload_with_offset 1843746 --> 1811946 | -1.72 %
evm::tests::test_instructions::test_environment_information::test_calldataload_with_offset_beyond_calldata 933436 --> 901636 | -3.41 %
evm::tests::test_instructions::test_environment_information::test_calldataload_with_offset_conversion_error 916716 --> 894706 | -2.40 %
evm::tests::test_instructions::test_environment_information::test_codecopy_basic 2848226 --> 2741046 | -3.76 %
evm::tests::test_instructions::test_environment_information::test_codecopy_type_conversion_error 704960 --> 619520 | -12.12 %
evm::tests::test_instructions::test_environment_information::test_codecopy_with_offset 2735426 --> 2628246 | -3.92 %
evm::tests::test_instructions::test_environment_information::test_codecopy_with_out_of_bound_bytes 3069496 --> 2962316 | -3.49 %
evm::tests::test_instructions::test_environment_information::test_codecopy_with_out_of_bound_offset 2113736 --> 2006556 | -5.07 %
evm::tests::test_instructions::test_environment_information::test_codesize 116910 --> 104720 | -10.43 %
evm::tests::test_instructions::test_environment_information::test_gasprice 110610 --> 97920 | -11.47 %
evm::tests::test_instructions::test_environment_information::test_returndata_copy_basic 5262652 --> 5148872 | -2.16 %
evm::tests::test_instructions::test_environment_information::test_returndata_copy_overflowing_add_error 663790 --> 578840 | -12.80 %
evm::tests::test_instructions::test_environment_information::test_returndata_copy_type_conversion_error 490160 --> 414880 | -15.36 %
evm::tests::test_instructions::test_environment_information::test_returndata_copy_with_multiple_words 5119102 --> 5005322 | -2.22 %
evm::tests::test_instructions::test_environment_information::test_returndata_copy_with_offset 5166952 --> 5053172 | -2.20 %
evm::tests::test_instructions::test_environment_information::test_returndata_copy_with_out_of_bound_bytes 663790 --> 578840 | -12.80 %
evm::tests::test_instructions::test_environment_information::test_returndatasize 122910 --> 111320 | -9.43 %
evm::tests::test_instructions::test_memory_operations::test_exec_pop_should_pop_an_item_from_stack 148130 --> 116020 | -21.68 %
evm::tests::test_instructions::test_memory_operations::test_exec_pop_should_stack_underflow 100760 --> 98760 | -1.98 %
evm::tests::test_instructions::test_memory_operations::test_pc_basic 115610 --> 103420 | -10.54 %
evm::tests::test_instructions::test_memory_operations::test_pc_gets_updated_properly_1 115610 --> 103420 | -10.54 %
evm::tests::test_instructions::test_push_operations::test_push0 98730 --> 78530 | -20.46 %
evm::tests::test_instructions::test_push_operations::test_push1 191350 --> 170950 | -10.66 %
evm::tests::test_instructions::test_push_operations::test_push10 588790 --> 568390 | -3.46 %
evm::tests::test_instructions::test_push_operations::test_push11 632950 --> 612550 | -3.22 %
evm::tests::test_instructions::test_push_operations::test_push12 677110 --> 656710 | -3.01 %
evm::tests::test_instructions::test_push_operations::test_push13 721270 --> 700870 | -2.83 %
evm::tests::test_instructions::test_push_operations::test_push14 765430 --> 745030 | -2.67 %
evm::tests::test_instructions::test_push_operations::test_push15 809590 --> 789190 | -2.52 %
evm::tests::test_instructions::test_push_operations::test_push16 853750 --> 833350 | -2.39 %
evm::tests::test_instructions::test_push_operations::test_push17 897910 --> 877510 | -2.27 %
evm::tests::test_instructions::test_push_operations::test_push18 942070 --> 921670 | -2.17 %
evm::tests::test_instructions::test_push_operations::test_push19 986230 --> 965830 | -2.07 %
evm::tests::test_instructions::test_push_operations::test_push2 235510 --> 215110 | -8.66 %
evm::tests::test_instructions::test_push_operations::test_push20 1030390 --> 1009990 | -1.98 %
evm::tests::test_instructions::test_push_operations::test_push21 1074550 --> 1054150 | -1.90 %
evm::tests::test_instructions::test_push_operations::test_push22 1118710 --> 1098310 | -1.82 %
evm::tests::test_instructions::test_push_operations::test_push23 1162870 --> 1142470 | -1.75 %
evm::tests::test_instructions::test_push_operations::test_push24 1207030 --> 1186630 | -1.69 %
evm::tests::test_instructions::test_push_operations::test_push25 1251190 --> 1230790 | -1.63 %
evm::tests::test_instructions::test_push_operations::test_push26 1295350 --> 1274950 | -1.57 %
evm::tests::test_instructions::test_push_operations::test_push27 1339510 --> 1319110 | -1.52 %
evm::tests::test_instructions::test_push_operations::test_push28 1383670 --> 1363270 | -1.47 %
evm::tests::test_instructions::test_push_operations::test_push29 1427830 --> 1407430 | -1.43 %
evm::tests::test_instructions::test_push_operations::test_push3 279670 --> 259270 | -7.29 %
evm::tests::test_instructions::test_push_operations::test_push30 1471990 --> 1451590 | -1.39 %
evm::tests::test_instructions::test_push_operations::test_push31 1516150 --> 1495750 | -1.35 %
evm::tests::test_instructions::test_push_operations::test_push32 1560310 --> 1539910 | -1.31 %
evm::tests::test_instructions::test_push_operations::test_push4 323830 --> 303430 | -6.30 %
evm::tests::test_instructions::test_push_operations::test_push5 367990 --> 347590 | -5.54 %
evm::tests::test_instructions::test_push_operations::test_push6 412150 --> 391750 | -4.95 %
evm::tests::test_instructions::test_push_operations::test_push7 456310 --> 435910 | -4.47 %
evm::tests::test_instructions::test_push_operations::test_push8 500470 --> 480070 | -4.08 %
evm::tests::test_instructions::test_push_operations::test_push9 544630 --> 524230 | -3.75 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test__exec_sdiv_neg 353810 --> 292990 | -17.19 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_add 302510 --> 223590 | -26.09 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_add_overflow 257820 --> 197000 | -23.59 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_addmod 342890 --> 262870 | -23.34 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_addmod_by_zero 342890 --> 262870 | -23.34 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_addmod_overflow 342890 --> 262870 | -23.34 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_div 267260 --> 206440 | -22.76 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_div_by_zero 267260 --> 206440 | -22.76 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_exp 349050 --> 288030 | -17.48 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_exp_overflow 356000 --> 294780 | -17.20 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_mod 267260 --> 206440 | -22.76 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_mod_by_zero 347380 --> 286560 | -17.51 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_mul 272180 --> 211360 | -22.35 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_mul_overflow 278610 --> 217790 | -21.83 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_sdiv_by_0 347380 --> 286560 | -17.51 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_sdiv_pos 347380 --> 286560 | -17.51 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_signextend 595686 --> 534666 | -10.24 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_signextend_no_effect 595686 --> 534666 | -10.24 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_signextend_on_negative 870006 --> 808986 | -7.01 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_smod 347380 --> 286560 | -17.51 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_smod_neg 347380 --> 286560 | -17.51 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_smod_zero 267260 --> 206440 | -22.76 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_sub 257820 --> 197000 | -23.59 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_exec_sub_underflow 257820 --> 197000 | -23.59 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_mulmod_basic 368290 --> 288270 | -21.73 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_mulmod_overflow 368290 --> 288270 | -21.73 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_mulmod_zero 368290 --> 288270 | -21.73 %
evm::tests::test_instructions::test_stop_and_arithmetic_operations::test_mulmod_zero_modulus 368290 --> 288270 | -21.73 %
evm::tests::test_memory::test__ensure_length__should_return_expanded_memory_and_cost 2469446 --> 2439406 | -1.22 %
evm::tests::test_memory::test__ensure_length__should_return_the_same_memory_and_no_cost 2469176 --> 2439136 | -1.22 %
evm::tests::test_memory::test__expand__should_return_expanded_memory_and_cost 2464276 --> 2435536 | -1.17 %
evm::tests::test_memory::test__expand__should_return_the_same_memory_and_no_cost 2464006 --> 2435266 | -1.17 %
evm::tests::test_memory::test__expand_and_load__should_return_expanded_memory_and_element_and_cost 3329226 --> 3279266 | -1.50 %
evm::tests::test_memory::test__load__should_load_an_element_from_the_memory 5519862 --> 5472832 | -0.85 %
evm::tests::test_memory::test__load__should_load_an_element_from_the_memory_with_offset_1 5017602 --> 4988592 | -0.58 %
evm::tests::test_memory::test__load__should_load_an_element_from_the_memory_with_offset_2 5013062 --> 4984052 | -0.58 %
evm::tests::test_memory::test__load__should_load_an_element_from_the_memory_with_offset_3 5019692 --> 4990682 | -0.58 %
evm::tests::test_memory::test__load__should_load_an_element_from_the_memory_with_offset_4 4996502 --> 4967492 | -0.58 %
evm::tests::test_memory::test__load__should_load_an_element_from_the_memory_with_offset_5 5016382 --> 4987372 | -0.58 %
evm::tests::test_memory::test__load__should_load_an_element_from_the_memory_with_offset_6 4972902 --> 4943892 | -0.58 %
evm::tests::test_memory::test_init_should_return_an_empty_memory 11510 --> 10910 | -5.21 %
evm::tests::test_memory::test_len_should_return_the_length_of_the_memory 11510 --> 10910 | -5.21 %
evm::tests::test_memory::test_store_n_no_aligned_words 360190 --> 350230 | -2.77 %
evm::tests::test_memory::test_store_should_add_an_element_to_the_memory 209990 --> 207590 | -1.14 %
evm::tests::test_memory::test_store_should_add_an_element_with_offset_to_the_memory 240480 --> 238080 | -1.00 %
evm::tests::test_memory::test_store_should_add_n_elements_to_the_memory 2273996 --> 2263736 | -0.45 %
evm::tests::test_stack::peek::test_should_return_err_when_underflow 38810 --> 29420 | -24.19 %
evm::tests::test_stack::peek::test_should_return_last_item 72130 --> 42260 | -41.41 %
evm::tests::test_stack::peek::test_should_return_stack_at_given_index_when_value_is_0 98920 --> 59560 | -39.79 %
evm::tests::test_stack::peek::test_should_return_stack_at_given_index_when_value_is_1 98920 --> 59560 | -39.79 %
evm::tests::test_stack::pop::test_pop_n_should_return_err_when_stack_underflow 51020 --> 41190 | -19.27 %
evm::tests::test_stack::pop::test_pop_return_err_when_stack_underflow 38340 --> 29050 | -24.23 %
evm::tests::test_stack::pop::test_should_pop_N_elements_from_the_stack 220820 --> 153250 | -30.60 %
evm::tests::test_stack::pop::test_should_pop_an_element_from_the_stack 98370 --> 59210 | -39.81 %
evm::tests::test_stack::push::test_should_add_an_element_to_the_stack 52210 --> 33130 | -36.54 %
evm::tests::test_stack::push::test_should_fail_when_overflow 27803640 --> 17554310 | -36.86 %
evm::tests::test_stack::swap::test_should_return_err_when_index_1_is_underflow 43260 --> 41760 | -3.47 %
evm::tests::test_stack::swap::test_should_return_err_when_index_2_is_underflow 64580 --> 53190 | -17.64 %
evm::tests::test_stack::swap::test_should_swap_2_stack_items 294880 --> 177000 | -39.98 %
evm::tests::test_stack::test__empty__should_return_if_stack_is_empty 34830 --> 24940 | -28.40 %
evm::tests::test_stack::test__len__should_return_the_length_of_the_stack 33330 --> 23440 | -29.67 %

WORSENED
Overall gas change: performance improvement, gas consumption-12.73 %

@enitrat enitrat requested a review from Eikix September 6, 2023 20:43
Copy link
Member

@Eikix Eikix left a comment

Choose a reason for hiding this comment

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

nice! do we see a difference with inline without always marker?

@ClementWalter ClementWalter merged commit fe7d349 into main Sep 7, 2023
1 of 2 checks passed
@ClementWalter ClementWalter deleted the issue-294 branch September 7, 2023 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dev: figure out why pop_n is significantly more expansive than serial pop in a row
3 participants