Skip to content

Proto: plumbing gas cost functions with memory allocation costs

Jun Furuse requested to merge jun@memory-allocation-final into master

This adds aliases let cost_XXX = cost_XXX_synthesized to Michelson_v1_gas_costs, in order to charge the memory allocation costs of the Michelson opcodes.

Some notes:

  • Formerly hand-edited function cost_N_ILsl_nat is now an alias of cost_N_ILsl_nat_synthesized
  • Formerly hand-edited function cost_N_ILsl_bytes is now an alias of cost_N_ILsl_bytes_synthesized
  • cost_N_IApply, cost_N_KMap_enter_body, cost_N_KList_enter_body are optimized versions of their corresponding synthesized versions.
  • cost_N_IDropN and cost_N_IDupN are simplified copies of their synthesized versions. (Originally they were simplified copies of non-synthesized versions.)
  • The manually edited cost functions of the partially carbonated opcodes (cost_N_IContract, cost_N_ICreate_contract, cost_NITransfer_tokens, cost_N_IEmit) are updated taking account of their memory allocation costs.
  • The parameters of the above partially carbonated opcodes are fixed in gas_parameters.json. Before they had intentionally lower values for the code generation. Now they have the actual values obtained from their benchmarks.

Gas changes in the regression tests by git-gas-diff.sh:

Lines with `Consumed gas: `:
  (Better means the value must decrease.)
  Accumulated value before: 267146.942
  Accumulated value now:    267197.459
  Total loss: ~0%
  Maximum loss on a line: 30.240 (~0%, line 10843)
  Maximum gain on a line: 0
  Number of lines with a change:      89
  Number of lines with a degradation: 89

Lines with `Estimated gas: `:
  (Better means the value must decrease.)
  Accumulated value before: 287474.574
  Accumulated value now:    287525.091
  Total loss: ~0%
  Maximum loss on a line: 30.250 (~0%, line 10829)
  Maximum gain on a line: 0
  Number of lines with a change:      68
  Number of lines with a degradation: 68

Lines with `Fee to the baker: ꜩ`:
  (Better means the value must decrease.)
  Accumulated value before: 0.012740
  Accumulated value now:    0.012747
  Total loss: ~0%
  Maximum loss on a line: 0.000003 (~0%, line 10832)
  Maximum gain on a line: 0
  Number of lines with a change:      5
  Number of lines with a degradation: 5

Lines with `Gas limit: `:
  (Better means the value must decrease.)
  Accumulated value before: 184569
  Accumulated value now:    184622
  Total loss: ~0%
  Maximum loss on a line: 31 (~0%, line 10835)
  Maximum gain on a line: 0
  Number of lines with a change:      20
  Number of lines with a degradation: 20

Lines with `Gas remaining: `:
  (Better means the value must increase.)
  Accumulated value before: 8319832.491
  Accumulated value now:    8319824.282
  Total loss: ~0%
  Maximum loss on a line: 3.031 (~0%, line 10644)
  Maximum gain on a line: 0
  Number of lines with a change:      8
  Number of lines with a degradation: 8

Lines with `just consumed gas: `:
  (Better means the value must decrease.)
  Accumulated value before: 1300.361
  Accumulated value now:    1339.754
  Total loss: ~3%
  Maximum loss on a line: 0.710 (~11%, line 6702)
  Maximum gain on a line: 0.002 (~8%, line 4510)
  Number of lines with a change:      2944
  Number of lines with a degradation: 2939

Lines with `payload fees(the block proposer) ....... +ꜩ`:
  (Better means the value must decrease.)
  Accumulated value before: 0.012740
  Accumulated value now:    0.012747
  Total loss: ~0%
  Maximum loss on a line: 0.000003 (~0%, line 10839)
  Maximum gain on a line: 0
  Number of lines with a change:      5
  Number of lines with a degradation: 5

Total number of lines with a change: 3152.
Total number of lines with a degradation: 3134.
Edited by Jun Furuse

Merge request reports