-
Notifications
You must be signed in to change notification settings - Fork 624
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
fix: Fix param estimator to account for base costs #3279
Conversation
…-base-param-estimator
…-base-param-estimator
…-base-param-estimator
…-base-param-estimator
Note that the function call base still includes compilation cost. |
Codecov Report
@@ Coverage Diff @@
## master #3279 +/- ##
=======================================
Coverage 87.31% 87.31%
=======================================
Files 219 219
Lines 43704 43704
=======================================
Hits 38158 38158
Misses 5546 5546 Continue to review full report at Codecov.
|
Added subtraction for the compilation cost for the function call base. This brings initial Re-run param estimator on gCloud instances to compare master branch vs this PR. This PRRuntimeConfig {
storage_amount_per_byte: 90900000000000000000,
transaction_costs: RuntimeFeesConfig {
action_receipt_creation_config: Fee {
send_sir: 148319187500,
send_not_sir: 148319187500,
execution: 148319187500,
},
data_receipt_creation_config: DataReceiptCreationConfig {
base_cost: Fee {
send_sir: 39667027250,
send_not_sir: 39667027250,
execution: 39667027250,
},
cost_per_byte: Fee {
send_sir: 13554355,
send_not_sir: 13554355,
execution: 13554355,
},
},
action_creation_config: ActionCreationConfig {
create_account_cost: Fee {
send_sir: 15592062500,
send_not_sir: 15592062500,
execution: 15592062500,
},
deploy_contract_cost: Fee {
send_sir: 31954250000,
send_not_sir: 31954250000,
execution: 31954250000,
},
deploy_contract_cost_per_byte: Fee {
send_sir: 6725921,
send_not_sir: 6725921,
execution: 6725921,
},
function_call_cost: Fee {
send_sir: 49788325000,
send_not_sir: 49788325000,
execution: 49788325000,
},
function_call_cost_per_byte: Fee {
send_sir: 29907,
send_not_sir: 29907,
execution: 29907,
},
transfer_cost: Fee {
send_sir: 14936625000,
send_not_sir: 14936625000,
execution: 14936625000,
},
stake_cost: Fee {
send_sir: 53951687500,
send_not_sir: 53951687500,
execution: 53951687500,
},
add_key_cost: AccessKeyCreationConfig {
full_access_cost: Fee {
send_sir: 21495312500,
send_not_sir: 21495312500,
execution: 21495312500,
},
function_call_cost: Fee {
send_sir: 20158937500,
send_not_sir: 20158937500,
execution: 20158937500,
},
function_call_cost_per_byte: Fee {
send_sir: 8814731,
send_not_sir: 8814731,
execution: 8814731,
},
},
delete_key_cost: Fee {
send_sir: 6212687500,
send_not_sir: 6212687500,
execution: 6212687500,
},
delete_account_cost: Fee {
send_sir: 94164750000,
send_not_sir: 94164750000,
execution: 94164750000,
},
},
storage_usage_config: StorageUsageConfig {
num_bytes_account: 100,
num_extra_bytes_record: 40,
},
burnt_gas_reward: Ratio {
numer: 3,
denom: 10,
},
pessimistic_gas_price_inflation_ratio: Ratio {
numer: 103,
denom: 100,
},
},
wasm_config: VMConfig {
ext_costs: ExtCostsConfig {
base: 82950416,
contract_compile_base: 33133787500,
contract_compile_bytes: 435469556,
read_memory_base: 245517887,
read_memory_byte: 1266516,
write_memory_base: 314208587,
write_memory_byte: 907339,
read_register_base: 214730012,
read_register_byte: 32263,
write_register_base: 335136975,
write_register_byte: 1266601,
utf8_decoding_base: 422128900,
utf8_decoding_byte: 102127392,
utf16_decoding_base: 564631037,
utf16_decoding_byte: 56652903,
sha256_base: 894214512,
sha256_byte: 7983126,
keccak256_base: 1335572675,
keccak256_byte: 7094613,
keccak512_base: 1310146550,
keccak512_byte: 12148654,
log_base: 564631037,
log_byte: 4360831,
storage_write_base: 10159547125,
storage_write_key_byte: 21367166,
storage_write_value_byte: 9146605,
storage_write_evicted_byte: 11522289,
storage_read_base: 22612159000,
storage_read_key_byte: 10699511,
storage_read_value_byte: 2369007,
storage_remove_base: 30539498875,
storage_remove_key_byte: 23588151,
storage_remove_ret_value_byte: 3319746,
storage_has_key_base: 20267938750,
storage_has_key_byte: 10537385,
storage_iter_create_prefix_base: 0,
storage_iter_create_prefix_byte: 0,
storage_iter_create_range_base: 0,
storage_iter_create_from_byte: 0,
storage_iter_create_to_byte: 0,
storage_iter_next_base: 0,
storage_iter_next_key_byte: 0,
storage_iter_next_value_byte: 0,
touching_trie_node: 6460616857,
promise_and_base: 435697507,
promise_and_per_promise: 1825906,
promise_return: 124926605,
validator_stake_base: 303944908800,
validator_total_stake_base: 303944908800,
},
grow_mem_cost: 1,
regular_op_cost: 1149206,
limit_config: VMLimitConfig {
max_gas_burnt: 200000000000000,
max_gas_burnt_view: 200000000000000,
max_stack_height: 16384,
initial_memory_pages: 1024,
max_memory_pages: 2048,
registers_memory_limit: 1073741824,
max_register_size: 104857600,
max_number_registers: 100,
max_number_logs: 100,
max_total_log_length: 16384,
max_total_prepaid_gas: 300000000000000,
max_actions_per_receipt: 100,
max_number_bytes_method_names: 2000,
max_length_method_name: 256,
max_arguments_length: 4194304,
max_length_returned_data: 4194304,
max_contract_size: 4194304,
max_length_storage_key: 4194304,
max_length_storage_value: 4194304,
max_promises_per_function_call_action: 1024,
max_number_input_data_dependencies: 128,
},
},
account_creation_config: AccountCreationConfig {
min_allowed_top_level_account_length: 0,
registrar_account_id: "registrar",
},
} MasterRuntimeConfig {
storage_amount_per_byte: 90900000000000000000,
transaction_costs: RuntimeFeesConfig {
action_receipt_creation_config: Fee {
send_sir: 156062187500,
send_not_sir: 156062187500,
execution: 156062187500,
},
data_receipt_creation_config: DataReceiptCreationConfig {
base_cost: Fee {
send_sir: 1295834652250,
send_not_sir: 1295834652250,
execution: 1295834652250,
},
cost_per_byte: Fee {
send_sir: 25984245,
send_not_sir: 25984245,
execution: 25984245,
},
},
action_creation_config: ActionCreationConfig {
create_account_cost: Fee {
send_sir: 146521000000,
send_not_sir: 146521000000,
execution: 146521000000,
},
deploy_contract_cost: Fee {
send_sir: 230843312500,
send_not_sir: 230843312500,
execution: 230843312500,
},
deploy_contract_cost_per_byte: Fee {
send_sir: 6859378,
send_not_sir: 6859378,
execution: 6859378,
},
function_call_cost: Fee {
send_sir: 1243229812500,
send_not_sir: 1243229812500,
execution: 1243229812500,
},
function_call_cost_per_byte: Fee {
send_sir: 1215766,
send_not_sir: 1215766,
execution: 1215766,
},
transfer_cost: Fee {
send_sir: 176898500000,
send_not_sir: 176898500000,
execution: 176898500000,
},
stake_cost: Fee {
send_sir: 175110500000,
send_not_sir: 175110500000,
execution: 175110500000,
},
add_key_cost: AccessKeyCreationConfig {
full_access_cost: Fee {
send_sir: 143960437500,
send_not_sir: 143960437500,
execution: 143960437500,
},
function_call_cost: Fee {
send_sir: 144988812500,
send_not_sir: 144988812500,
execution: 144988812500,
},
function_call_cost_per_byte: Fee {
send_sir: 23816012,
send_not_sir: 23816012,
execution: 23816012,
},
},
delete_key_cost: Fee {
send_sir: 128208750000,
send_not_sir: 128208750000,
execution: 128208750000,
},
delete_account_cost: Fee {
send_sir: 223104187500,
send_not_sir: 223104187500,
execution: 223104187500,
},
},
storage_usage_config: StorageUsageConfig {
num_bytes_account: 100,
num_extra_bytes_record: 40,
},
burnt_gas_reward: Ratio {
numer: 3,
denom: 10,
},
pessimistic_gas_price_inflation_ratio: Ratio {
numer: 103,
denom: 100,
},
},
wasm_config: VMConfig {
ext_costs: ExtCostsConfig {
base: 85755402,
contract_compile_base: 33262612500,
contract_compile_bytes: 435533418,
read_memory_base: 526175712,
read_memory_byte: 1266782,
write_memory_base: 595044862,
write_memory_byte: 907606,
read_register_base: 495207387,
read_register_byte: 32529,
write_register_base: 615480375,
write_register_byte: 1266868,
utf8_decoding_base: 703386787,
utf8_decoding_byte: 102162239,
utf16_decoding_base: 845574737,
utf16_decoding_byte: 56680742,
sha256_base: 1174796787,
sha256_byte: 8008894,
keccak256_base: 1616349112,
keccak256_byte: 7118891,
keccak512_base: 1590964550,
keccak512_byte: 12175852,
log_base: 845574737,
log_byte: 4377437,
storage_write_base: 23603892875,
storage_write_key_byte: 23855961,
storage_write_value_byte: 10649460,
storage_write_evicted_byte: 12285094,
storage_read_base: 25522372750,
storage_read_key_byte: 11102789,
storage_read_value_byte: 3046799,
storage_remove_base: 20989722750,
storage_remove_key_byte: 13203731,
storage_remove_ret_value_byte: 5219726,
storage_has_key_base: 23509302250,
storage_has_key_byte: 10842259,
storage_iter_create_prefix_base: 0,
storage_iter_create_prefix_byte: 0,
storage_iter_create_range_base: 0,
storage_iter_create_from_byte: 0,
storage_iter_create_to_byte: 0,
storage_iter_next_base: 0,
storage_iter_next_key_byte: 0,
storage_iter_next_value_byte: 0,
touching_trie_node: 7292106500,
promise_and_base: 464087012,
promise_and_per_promise: 1823154,
promise_return: 153455203,
validator_stake_base: 303944908800,
validator_total_stake_base: 303944908800,
},
grow_mem_cost: 1,
regular_op_cost: 1147910,
limit_config: VMLimitConfig {
max_gas_burnt: 200000000000000,
max_gas_burnt_view: 200000000000000,
max_stack_height: 16384,
initial_memory_pages: 1024,
max_memory_pages: 2048,
registers_memory_limit: 1073741824,
max_register_size: 104857600,
max_number_registers: 100,
max_number_logs: 100,
max_total_log_length: 16384,
max_total_prepaid_gas: 300000000000000,
max_actions_per_receipt: 100,
max_number_bytes_method_names: 2000,
max_length_method_name: 256,
max_arguments_length: 4194304,
max_length_returned_data: 4194304,
max_contract_size: 4194304,
max_length_storage_key: 4194304,
max_length_storage_value: 4194304,
max_promises_per_function_call_action: 1024,
max_number_input_data_dependencies: 128,
},
},
account_creation_config: AccountCreationConfig {
min_allowed_top_level_account_length: 0,
registrar_account_id: "registrar",
},
} |
…-base-param-estimator
…-base-param-estimator
…/nearcore into remove-base-param-estimator
for i in 0..1000 { | ||
ids[i] = promise_create( | ||
buf_len, | ||
buf.as_ptr() as _, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this just cast it to the type that the parameter expects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
@@ -23,5 +23,5 @@ set -ex | |||
cargo run --release --package neard --bin neard -- --home /tmp/data init --chain-id= --test-seed=alice.near --account-id=test.near --fast | |||
cargo run --release --package genesis-populate --bin genesis-populate -- --additional-accounts-num=200000 --home /tmp/data | |||
cargo build --release --package runtime-params-estimator $features | |||
./emu-cost/counter_plugin/qemu-x86_64 -cpu Westmere-v1 -plugin file=./emu-cost/counter_plugin/libcounter.so ../../target/release/runtime-params-estimator --home /tmp/data --accounts-num 20000 --iters 1 --warmup-iters 1 --vm-kind $vmkind | |||
./emu-cost/counter_plugin/qemu-x86_64 -cpu Westmere-v1 -plugin file=./emu-cost/counter_plugin/libcounter.so ../../target/release/runtime-params-estimator --home /tmp/data --accounts-num 20000 --iters 1 --warmup-iters 0 --vm-kind $vmkind |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is warmup-iters still useful after this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe. Don't want to remove it completely, but it makes sense to not run it.
This change doesn't update live config. Just the estimator. It contains the following changes: - Introduce warmup before estimating `actions`. - Update computation flow to remove warmup transactions and instead spawn transactions in the main loop, and then execute all receipts till the end to account for refunds. Pass `--warmup-iters 0` - Estimate cost for a receipt with sender==receiver. - Add `upper_with_base` that computes the cost by removing the base cost. - For DataReceipt costs, introduce a base call that doesn't doo data receipts, but makes 1000 promises. This base should be accounted from other fees. So we update DataReceipt computation to remove this base. - Update all Actions computation to remove corresponding receipt cost (either sir or not_sir receipts). - All base function calls are also remove `noop` cost for a function call. ## Test plan: - Run param estimator. - CI Added subtraction for the compilation cost for the function call base. This brings initial `function_call_cost` to just `50 Ggas`, while basic action receipt cost is `148 Ggas`. Re-run param estimator on gCloud instances to compare master branch vs this PR. # This PR ```rust RuntimeConfig { storage_amount_per_byte: 90900000000000000000, transaction_costs: RuntimeFeesConfig { action_receipt_creation_config: Fee { send_sir: 148319187500, send_not_sir: 148319187500, execution: 148319187500, }, data_receipt_creation_config: DataReceiptCreationConfig { base_cost: Fee { send_sir: 39667027250, send_not_sir: 39667027250, execution: 39667027250, }, cost_per_byte: Fee { send_sir: 13554355, send_not_sir: 13554355, execution: 13554355, }, }, action_creation_config: ActionCreationConfig { create_account_cost: Fee { send_sir: 15592062500, send_not_sir: 15592062500, execution: 15592062500, }, deploy_contract_cost: Fee { send_sir: 31954250000, send_not_sir: 31954250000, execution: 31954250000, }, deploy_contract_cost_per_byte: Fee { send_sir: 6725921, send_not_sir: 6725921, execution: 6725921, }, function_call_cost: Fee { send_sir: 49788325000, send_not_sir: 49788325000, execution: 49788325000, }, function_call_cost_per_byte: Fee { send_sir: 29907, send_not_sir: 29907, execution: 29907, }, transfer_cost: Fee { send_sir: 14936625000, send_not_sir: 14936625000, execution: 14936625000, }, stake_cost: Fee { send_sir: 53951687500, send_not_sir: 53951687500, execution: 53951687500, }, add_key_cost: AccessKeyCreationConfig { full_access_cost: Fee { send_sir: 21495312500, send_not_sir: 21495312500, execution: 21495312500, }, function_call_cost: Fee { send_sir: 20158937500, send_not_sir: 20158937500, execution: 20158937500, }, function_call_cost_per_byte: Fee { send_sir: 8814731, send_not_sir: 8814731, execution: 8814731, }, }, delete_key_cost: Fee { send_sir: 6212687500, send_not_sir: 6212687500, execution: 6212687500, }, delete_account_cost: Fee { send_sir: 94164750000, send_not_sir: 94164750000, execution: 94164750000, }, }, storage_usage_config: StorageUsageConfig { num_bytes_account: 100, num_extra_bytes_record: 40, }, burnt_gas_reward: Ratio { numer: 3, denom: 10, }, pessimistic_gas_price_inflation_ratio: Ratio { numer: 103, denom: 100, }, }, wasm_config: VMConfig { ext_costs: ExtCostsConfig { base: 82950416, contract_compile_base: 33133787500, contract_compile_bytes: 435469556, read_memory_base: 245517887, read_memory_byte: 1266516, write_memory_base: 314208587, write_memory_byte: 907339, read_register_base: 214730012, read_register_byte: 32263, write_register_base: 335136975, write_register_byte: 1266601, utf8_decoding_base: 422128900, utf8_decoding_byte: 102127392, utf16_decoding_base: 564631037, utf16_decoding_byte: 56652903, sha256_base: 894214512, sha256_byte: 7983126, keccak256_base: 1335572675, keccak256_byte: 7094613, keccak512_base: 1310146550, keccak512_byte: 12148654, log_base: 564631037, log_byte: 4360831, storage_write_base: 10159547125, storage_write_key_byte: 21367166, storage_write_value_byte: 9146605, storage_write_evicted_byte: 11522289, storage_read_base: 22612159000, storage_read_key_byte: 10699511, storage_read_value_byte: 2369007, storage_remove_base: 30539498875, storage_remove_key_byte: 23588151, storage_remove_ret_value_byte: 3319746, storage_has_key_base: 20267938750, storage_has_key_byte: 10537385, storage_iter_create_prefix_base: 0, storage_iter_create_prefix_byte: 0, storage_iter_create_range_base: 0, storage_iter_create_from_byte: 0, storage_iter_create_to_byte: 0, storage_iter_next_base: 0, storage_iter_next_key_byte: 0, storage_iter_next_value_byte: 0, touching_trie_node: 6460616857, promise_and_base: 435697507, promise_and_per_promise: 1825906, promise_return: 124926605, validator_stake_base: 303944908800, validator_total_stake_base: 303944908800, }, grow_mem_cost: 1, regular_op_cost: 1149206, limit_config: VMLimitConfig { max_gas_burnt: 200000000000000, max_gas_burnt_view: 200000000000000, max_stack_height: 16384, initial_memory_pages: 1024, max_memory_pages: 2048, registers_memory_limit: 1073741824, max_register_size: 104857600, max_number_registers: 100, max_number_logs: 100, max_total_log_length: 16384, max_total_prepaid_gas: 300000000000000, max_actions_per_receipt: 100, max_number_bytes_method_names: 2000, max_length_method_name: 256, max_arguments_length: 4194304, max_length_returned_data: 4194304, max_contract_size: 4194304, max_length_storage_key: 4194304, max_length_storage_value: 4194304, max_promises_per_function_call_action: 1024, max_number_input_data_dependencies: 128, }, }, account_creation_config: AccountCreationConfig { min_allowed_top_level_account_length: 0, registrar_account_id: "registrar", }, } ``` # Master ```rust RuntimeConfig { storage_amount_per_byte: 90900000000000000000, transaction_costs: RuntimeFeesConfig { action_receipt_creation_config: Fee { send_sir: 156062187500, send_not_sir: 156062187500, execution: 156062187500, }, data_receipt_creation_config: DataReceiptCreationConfig { base_cost: Fee { send_sir: 1295834652250, send_not_sir: 1295834652250, execution: 1295834652250, }, cost_per_byte: Fee { send_sir: 25984245, send_not_sir: 25984245, execution: 25984245, }, }, action_creation_config: ActionCreationConfig { create_account_cost: Fee { send_sir: 146521000000, send_not_sir: 146521000000, execution: 146521000000, }, deploy_contract_cost: Fee { send_sir: 230843312500, send_not_sir: 230843312500, execution: 230843312500, }, deploy_contract_cost_per_byte: Fee { send_sir: 6859378, send_not_sir: 6859378, execution: 6859378, }, function_call_cost: Fee { send_sir: 1243229812500, send_not_sir: 1243229812500, execution: 1243229812500, }, function_call_cost_per_byte: Fee { send_sir: 1215766, send_not_sir: 1215766, execution: 1215766, }, transfer_cost: Fee { send_sir: 176898500000, send_not_sir: 176898500000, execution: 176898500000, }, stake_cost: Fee { send_sir: 175110500000, send_not_sir: 175110500000, execution: 175110500000, }, add_key_cost: AccessKeyCreationConfig { full_access_cost: Fee { send_sir: 143960437500, send_not_sir: 143960437500, execution: 143960437500, }, function_call_cost: Fee { send_sir: 144988812500, send_not_sir: 144988812500, execution: 144988812500, }, function_call_cost_per_byte: Fee { send_sir: 23816012, send_not_sir: 23816012, execution: 23816012, }, }, delete_key_cost: Fee { send_sir: 128208750000, send_not_sir: 128208750000, execution: 128208750000, }, delete_account_cost: Fee { send_sir: 223104187500, send_not_sir: 223104187500, execution: 223104187500, }, }, storage_usage_config: StorageUsageConfig { num_bytes_account: 100, num_extra_bytes_record: 40, }, burnt_gas_reward: Ratio { numer: 3, denom: 10, }, pessimistic_gas_price_inflation_ratio: Ratio { numer: 103, denom: 100, }, }, wasm_config: VMConfig { ext_costs: ExtCostsConfig { base: 85755402, contract_compile_base: 33262612500, contract_compile_bytes: 435533418, read_memory_base: 526175712, read_memory_byte: 1266782, write_memory_base: 595044862, write_memory_byte: 907606, read_register_base: 495207387, read_register_byte: 32529, write_register_base: 615480375, write_register_byte: 1266868, utf8_decoding_base: 703386787, utf8_decoding_byte: 102162239, utf16_decoding_base: 845574737, utf16_decoding_byte: 56680742, sha256_base: 1174796787, sha256_byte: 8008894, keccak256_base: 1616349112, keccak256_byte: 7118891, keccak512_base: 1590964550, keccak512_byte: 12175852, log_base: 845574737, log_byte: 4377437, storage_write_base: 23603892875, storage_write_key_byte: 23855961, storage_write_value_byte: 10649460, storage_write_evicted_byte: 12285094, storage_read_base: 25522372750, storage_read_key_byte: 11102789, storage_read_value_byte: 3046799, storage_remove_base: 20989722750, storage_remove_key_byte: 13203731, storage_remove_ret_value_byte: 5219726, storage_has_key_base: 23509302250, storage_has_key_byte: 10842259, storage_iter_create_prefix_base: 0, storage_iter_create_prefix_byte: 0, storage_iter_create_range_base: 0, storage_iter_create_from_byte: 0, storage_iter_create_to_byte: 0, storage_iter_next_base: 0, storage_iter_next_key_byte: 0, storage_iter_next_value_byte: 0, touching_trie_node: 7292106500, promise_and_base: 464087012, promise_and_per_promise: 1823154, promise_return: 153455203, validator_stake_base: 303944908800, validator_total_stake_base: 303944908800, }, grow_mem_cost: 1, regular_op_cost: 1147910, limit_config: VMLimitConfig { max_gas_burnt: 200000000000000, max_gas_burnt_view: 200000000000000, max_stack_height: 16384, initial_memory_pages: 1024, max_memory_pages: 2048, registers_memory_limit: 1073741824, max_register_size: 104857600, max_number_registers: 100, max_number_logs: 100, max_total_log_length: 16384, max_total_prepaid_gas: 300000000000000, max_actions_per_receipt: 100, max_number_bytes_method_names: 2000, max_length_method_name: 256, max_arguments_length: 4194304, max_length_returned_data: 4194304, max_contract_size: 4194304, max_length_storage_key: 4194304, max_length_storage_value: 4194304, max_promises_per_function_call_action: 1024, max_number_input_data_dependencies: 128, }, }, account_creation_config: AccountCreationConfig { min_allowed_top_level_account_length: 0, registrar_account_id: "registrar", }, } ```
This change doesn't update live config. Just the estimator.
It contains the following changes:
actions
.--warmup-iters 0
upper_with_base
that computes the cost by removing the base cost.noop
cost for a function call.Test plan:
The config generated on my mac: