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

Refactor environment event emitter #3120

Merged
merged 1 commit into from
Aug 30, 2022
Merged

Refactor environment event emitter #3120

merged 1 commit into from
Aug 30, 2022

Conversation

pattyshack
Copy link
Contributor

  1. move event.go & event_test.go from handler into environment
  2. renamed (h *EventHandler) to (emitter *eventEmitter)
  3. renamed (e *EventCollection) to (collection *EventCollection)
  4. removed Child & Merge from EventCollection (dead code)
  5. added EventEmitter interface and NoEventEmitter for scripts
  6. merged TransactionEnv.EmitEvent's tracing / metering logic into
    eventEmitter.EmitEvent.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 29, 2022

FVM Benchstat comparison

This branch with compared with the base branch onflow:master commit ac1c5c7

The command (for i in {1..10}; do go test ./fvm ./engine/execution/computation --bench . --tags relic -shuffle=on --benchmem --run ^$; done) was used.

Collapsed results for better readability

old.txtnew.txt
time/opdelta
pkg:github.com/onflow/flow-go/fvm goos:linux goarch:amd64
RuntimeTransaction/transfer_tokens-2203ms ± 1%206ms ± 2%+1.63%(p=0.003 n=10+10)
RuntimeNFTBatchTransfer-2112ms ± 2%113ms ± 3%~(p=0.905 n=10+9)
RuntimeTransaction/reference_tx-225.8ms ± 6%26.1ms ± 8%~(p=0.780 n=9+10)
RuntimeTransaction/convert_int_to_string-228.3ms ±12%28.0ms ± 8%~(p=0.720 n=9+10)
RuntimeTransaction/convert_int_to_string_and_concatenate_it-230.4ms ±12%30.2ms ± 9%~(p=0.739 n=10+10)
RuntimeTransaction/get_signer_address-226.9ms ± 6%27.2ms ± 9%~(p=0.853 n=10+10)
RuntimeTransaction/get_public_account-229.1ms ± 5%29.7ms ± 5%~(p=0.182 n=10+9)
RuntimeTransaction/get_account_and_get_balance-2273ms ± 2%277ms ± 4%~(p=0.050 n=9+9)
RuntimeTransaction/get_account_and_get_available_balance-2254ms ± 2%255ms ± 2%~(p=0.393 n=10+10)
RuntimeTransaction/get_account_and_get_storage_used-232.7ms ± 5%32.4ms ± 6%~(p=0.684 n=10+10)
RuntimeTransaction/get_account_and_get_storage_capacity-2229ms ± 7%229ms ± 1%~(p=0.447 n=9+10)
RuntimeTransaction/get_signer_vault-236.0ms ± 6%35.5ms ± 6%~(p=0.529 n=10+10)
RuntimeTransaction/get_signer_receiver-244.3ms ± 4%44.9ms ± 2%~(p=0.079 n=10+9)
RuntimeTransaction/load_and_save_empty_string_on_signers_address-234.2ms ± 4%34.9ms ± 8%~(p=0.353 n=10+10)
RuntimeTransaction/load_and_save_long_string_on_signers_address-277.5ms ± 3%77.5ms ± 3%~(p=0.604 n=10+9)
RuntimeTransaction/create_new_account-2844ms ± 1%848ms ± 2%~(p=0.133 n=9+10)
RuntimeTransaction/call_empty_contract_function-229.6ms ± 4%29.5ms ± 5%~(p=0.684 n=10+10)
RuntimeTransaction/emit_event-245.7ms ± 6%45.4ms ± 5%~(p=0.796 n=10+10)
RuntimeTransaction/borrow_array_from_storage-2130ms ± 4%130ms ± 3%~(p=0.631 n=10+10)
RuntimeTransaction/copy_array_from_storage-2130ms ± 3%131ms ± 2%~(p=0.633 n=10+8)
pkg:github.com/onflow/flow-go/engine/execution/computation goos:linux goarch:amd64
ComputeBlock/16/cols/128/txes-24.96s ± 2%4.92s ± 2%~(p=0.218 n=10+10)
 
alloc/opdelta
pkg:github.com/onflow/flow-go/fvm goos:linux goarch:amd64
RuntimeNFTBatchTransfer-257.8MB ± 1%58.6MB ± 5%~(p=0.156 n=9+10)
RuntimeTransaction/reference_tx-238.4MB ± 5%37.6MB ± 4%~(p=0.105 n=10+10)
RuntimeTransaction/convert_int_to_string-237.8MB ± 7%37.9MB ± 6%~(p=0.971 n=10+10)
RuntimeTransaction/convert_int_to_string_and_concatenate_it-238.6MB ± 8%38.8MB ± 7%~(p=0.971 n=10+10)
RuntimeTransaction/get_signer_address-238.4MB ± 5%37.6MB ± 8%~(p=0.315 n=10+10)
RuntimeTransaction/get_public_account-238.9MB ± 7%39.0MB ± 8%~(p=0.796 n=10+10)
RuntimeTransaction/get_account_and_get_balance-2138MB ± 3%138MB ± 3%~(p=0.912 n=10+10)
RuntimeTransaction/get_account_and_get_available_balance-2121MB ± 3%122MB ± 0%~(p=0.562 n=10+6)
RuntimeTransaction/get_account_and_get_storage_used-240.2MB ± 6%39.9MB ± 8%~(p=0.579 n=10+10)
RuntimeTransaction/get_account_and_get_storage_capacity-2115MB ± 3%116MB ± 3%~(p=0.165 n=10+10)
RuntimeTransaction/get_signer_vault-240.5MB ± 6%40.0MB ± 8%~(p=0.739 n=10+10)
RuntimeTransaction/get_signer_receiver-241.3MB ± 4%41.2MB ± 4%~(p=0.842 n=10+9)
RuntimeTransaction/transfer_tokens-288.5MB ± 2%89.1MB ± 3%~(p=0.243 n=9+10)
RuntimeTransaction/load_and_save_empty_string_on_signers_address-239.7MB ± 4%39.6MB ± 9%~(p=0.739 n=10+10)
RuntimeTransaction/load_and_save_long_string_on_signers_address-258.2MB ± 4%57.3MB ± 3%~(p=0.143 n=10+10)
RuntimeTransaction/create_new_account-2206MB ± 3%205MB ± 1%~(p=0.853 n=10+10)
RuntimeTransaction/call_empty_contract_function-238.6MB ± 7%38.3MB ± 6%~(p=0.529 n=10+10)
RuntimeTransaction/emit_event-244.9MB ± 6%44.2MB ± 7%~(p=0.529 n=10+10)
RuntimeTransaction/borrow_array_from_storage-270.1MB ± 5%70.3MB ± 3%~(p=1.000 n=10+9)
RuntimeTransaction/copy_array_from_storage-284.0MB ± 4%84.7MB ± 3%~(p=0.182 n=10+9)
pkg:github.com/onflow/flow-go/engine/execution/computation goos:linux goarch:amd64
ComputeBlock/16/cols/128/txes-21.42GB ± 1%1.42GB ± 1%~(p=0.971 n=10+10)
 
allocs/opdelta
pkg:github.com/onflow/flow-go/fvm goos:linux goarch:amd64
RuntimeNFTBatchTransfer-2303k ± 0%303k ± 0%~(p=0.329 n=9+9)
RuntimeTransaction/reference_tx-288.5k ± 0%88.5k ± 0%~(p=0.208 n=10+10)
RuntimeTransaction/convert_int_to_string-2103k ± 0%103k ± 0%~(p=0.825 n=9+10)
RuntimeTransaction/convert_int_to_string_and_concatenate_it-2117k ± 0%117k ± 0%~(p=0.424 n=10+10)
RuntimeTransaction/get_signer_address-293.7k ± 0%93.7k ± 0%~(p=0.642 n=10+10)
RuntimeTransaction/get_public_account-2117k ± 0%117k ± 0%~(p=0.423 n=10+10)
RuntimeTransaction/get_account_and_get_balance-21.69M ± 0%1.69M ± 0%~(p=0.183 n=10+10)
RuntimeTransaction/get_account_and_get_available_balance-21.56M ± 0%1.56M ± 0%~(p=0.278 n=10+9)
RuntimeTransaction/get_account_and_get_storage_used-2138k ± 0%138k ± 0%~(p=0.516 n=10+10)
RuntimeTransaction/get_account_and_get_storage_capacity-21.41M ± 0%1.41M ± 0%~(p=0.066 n=10+10)
RuntimeTransaction/get_signer_vault-2140k ± 0%140k ± 0%~(p=0.097 n=10+9)
RuntimeTransaction/get_signer_receiver-2221k ± 0%221k ± 0%~(p=0.254 n=10+10)
RuntimeTransaction/transfer_tokens-2970k ± 0%970k ± 0%~(p=0.059 n=7+9)
RuntimeTransaction/load_and_save_empty_string_on_signers_address-2139k ± 0%139k ± 0%~(p=0.445 n=10+10)
RuntimeTransaction/load_and_save_long_string_on_signers_address-2241k ± 0%241k ± 0%~(p=0.090 n=10+9)
RuntimeTransaction/create_new_account-22.79M ± 0%2.79M ± 0%~(p=0.481 n=10+10)
RuntimeTransaction/call_empty_contract_function-2105k ± 0%105k ± 0%~(p=0.239 n=10+10)
RuntimeTransaction/emit_event-2150k ± 0%150k ± 0%~(p=0.591 n=10+10)
RuntimeTransaction/borrow_array_from_storage-2378k ± 0%378k ± 0%~(p=0.868 n=10+10)
RuntimeTransaction/copy_array_from_storage-2334k ± 0%334k ± 0%~(p=0.234 n=10+9)
pkg:github.com/onflow/flow-go/engine/execution/computation goos:linux goarch:amd64
ComputeBlock/16/cols/128/txes-222.6M ± 0%22.6M ± 0%~(p=0.481 n=10+10)
 
computationdelta
pkg:github.com/onflow/flow-go/fvm goos:linux goarch:amd64
RuntimeTransaction/reference_tx-2202 ± 0%202 ± 0%~(all equal)
RuntimeTransaction/convert_int_to_string-2402 ± 0%402 ± 0%~(all equal)
RuntimeTransaction/convert_int_to_string_and_concatenate_it-2502 ± 0%502 ± 0%~(all equal)
RuntimeTransaction/get_signer_address-2302 ± 0%302 ± 0%~(all equal)
RuntimeTransaction/get_public_account-2402 ± 0%402 ± 0%~(all equal)
RuntimeTransaction/get_account_and_get_balance-21.00k ± 0%1.00k ± 0%~(all equal)
RuntimeTransaction/get_account_and_get_available_balance-22.60k ± 0%2.60k ± 0%~(all equal)
RuntimeTransaction/get_account_and_get_storage_used-2402 ± 0%402 ± 0%~(all equal)
RuntimeTransaction/get_account_and_get_storage_capacity-21.30k ± 0%1.30k ± 0%~(all equal)
RuntimeTransaction/get_signer_vault-2402 ± 0%402 ± 0%~(all equal)
RuntimeTransaction/get_signer_receiver-2602 ± 0%602 ± 0%~(all equal)
RuntimeTransaction/transfer_tokens-23.50k ± 0%3.50k ± 0%~(all equal)
RuntimeTransaction/load_and_save_empty_string_on_signers_address-2602 ± 0%602 ± 0%~(all equal)
RuntimeTransaction/load_and_save_long_string_on_signers_address-2602 ± 0%602 ± 0%~(all equal)
RuntimeTransaction/create_new_account-2202 ± 0%202 ± 0%~(all equal)
RuntimeTransaction/call_empty_contract_function-2402 ± 0%402 ± 0%~(all equal)
RuntimeTransaction/emit_event-2602 ± 0%602 ± 0%~(all equal)
RuntimeTransaction/borrow_array_from_storage-22.60k ± 0%2.60k ± 0%~(all equal)
RuntimeTransaction/copy_array_from_storage-22.60k ± 0%2.60k ± 0%~(all equal)
 
interactionsdelta
pkg:github.com/onflow/flow-go/fvm goos:linux goarch:amd64
RuntimeTransaction/reference_tx-244.4k ± 0%44.4k ± 0%~(all equal)
RuntimeTransaction/convert_int_to_string-244.4k ± 0%44.4k ± 0%~(all equal)
RuntimeTransaction/convert_int_to_string_and_concatenate_it-244.4k ± 0%44.4k ± 0%~(all equal)
RuntimeTransaction/get_signer_address-244.4k ± 0%44.4k ± 0%~(all equal)
RuntimeTransaction/get_public_account-244.4k ± 0%44.4k ± 0%~(all equal)
RuntimeTransaction/get_account_and_get_balance-216.8M ± 0%16.8M ± 0%~(all equal)
RuntimeTransaction/get_account_and_get_available_balance-25.28M ± 0%5.28M ± 0%~(all equal)
RuntimeTransaction/get_account_and_get_storage_used-248.0k ± 0%48.0k ± 0%~(all equal)
RuntimeTransaction/get_account_and_get_storage_capacity-25.27M ± 0%5.27M ± 0%~(all equal)
RuntimeTransaction/get_signer_vault-244.7k ± 0%44.7k ± 0%~(all equal)
RuntimeTransaction/get_signer_receiver-245.0k ± 0%45.0k ± 0%~(all equal)
RuntimeTransaction/transfer_tokens-245.8k ± 0%45.8k ± 0%~(all equal)
RuntimeTransaction/load_and_save_empty_string_on_signers_address-244.8k ± 0%44.8k ± 0%~(all equal)
RuntimeTransaction/load_and_save_long_string_on_signers_address-249.7k ± 0%49.7k ± 0%~(all equal)
RuntimeTransaction/create_new_account-28.53M ± 0%8.53M ± 0%~(all equal)
RuntimeTransaction/call_empty_contract_function-244.6k ± 0%44.6k ± 0%~(all equal)
RuntimeTransaction/emit_event-244.6k ± 0%44.6k ± 0%~(all equal)
RuntimeTransaction/borrow_array_from_storage-249.8k ± 0%49.8k ± 0%~(all equal)
RuntimeTransaction/copy_array_from_storage-249.8k ± 0%49.8k ± 0%~(all equal)
 
us/txdelta
pkg:github.com/onflow/flow-go/engine/execution/computation goos:linux goarch:amd64
ComputeBlock/16/cols/128/txes-22.42k ± 2%2.40k ± 2%~(p=0.210 n=10+10)
 

Copy link
Contributor

@Tonix517 Tonix517 left a comment

Choose a reason for hiding this comment

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

LGTM. just a question out of curiosity

Copy link
Member

@zhangchiqing zhangchiqing left a comment

Choose a reason for hiding this comment

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

Looks good. Just had some minor suggestion

fvm/environment/event_emitter.go Show resolved Hide resolved
fvm/environment/event_emitter.go Show resolved Hide resolved
1. move event.go & event_test.go from handler into environment
2. renamed (h *EventHandler) to (emitter *eventEmitter)
3. renamed (e *EventCollection) to (collection *EventCollection)
4. removed Child & Merge from EventCollection (dead code)
5. added EventEmitter interface and NoEventEmitter for scripts
6. merged TransactionEnv.EmitEvent's tracing / metering logic into
   eventEmitter.EmitEvent.
@pattyshack
Copy link
Contributor Author

bors merge

@bors bors bot merged commit 28f8f49 into master Aug 30, 2022
@bors bors bot deleted the patrick/event-emitter branch August 30, 2022 18:04
@pattyshack
Copy link
Contributor Author

pattyshack commented Aug 30, 2022 via email

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.

4 participants