gear-tech/gear

Investigate how other types of sections (excluding code and data) in a wasm module contribute to instantiation time

ByteNacked opened this issue · 2 comments

Problem to Solve

Investigate how other types of sections (excluding code and data) in a wasm module contribute to instantiation time.
Section like:

  • type
  • table
  • global
  • etc..

Possible Solution

Investigate by writing instantiation module benches for these sections.

Local bench run
$ ./target/release/gear  benchmark pallet --chain=vara-dev --steps=50 --repeat=20 --pallet=pallet_gear --extrinsic=instantiate_module_code_section_per_kb,instantiate_module_data_section_per_kb,instantiate_module_global_section_per_kb,instantiate_module_table_section_per_kb,instantiate_module_type_section_per_kb   --heap-pages=4096
2024-05-06 15:14:12 [0] 💸 generated 1 npos voters, 1 from validators and 0 nominators
2024-05-06 15:14:12 [0] 💸 generated 1 npos targets
2024-05-06 15:14:12 Starting benchmark: pallet_gear::instantiate_module_code_section_per_kb
2024-05-06 15:14:18 Running  benchmark: pallet_gear.instantiate_module_code_section_per_kb(1 args) 32/50 1/1
2024-05-06 15:14:23 Running  benchmark: pallet_gear.instantiate_module_code_section_per_kb(1 args) 45/50 1/1
2024-05-06 15:14:25 Starting benchmark: pallet_gear::instantiate_module_data_section_per_kb
2024-05-06 15:14:28 Starting benchmark: pallet_gear::instantiate_module_global_section_per_kb
2024-05-06 15:14:28 Running  benchmark: pallet_gear.instantiate_module_global_section_per_kb(1 args) 5/50 1/1
2024-05-06 15:14:33 Running  benchmark: pallet_gear.instantiate_module_global_section_per_kb(1 args) 29/50 1/1
2024-05-06 15:14:38 Running  benchmark: pallet_gear.instantiate_module_global_section_per_kb(1 args) 41/50 1/1
2024-05-06 15:14:44 Running  benchmark: pallet_gear.instantiate_module_global_section_per_kb(1 args) 50/50 1/1
2024-05-06 15:14:44 Starting benchmark: pallet_gear::instantiate_module_table_section_per_kb
2024-05-06 15:14:48 Starting benchmark: pallet_gear::instantiate_module_type_section_per_kb
2024-05-06 15:14:49 Running  benchmark: pallet_gear.instantiate_module_type_section_per_kb(1 args) 10/50 1/1
2024-05-06 15:14:54 Running  benchmark: pallet_gear.instantiate_module_type_section_per_kb(1 args) 30/50 1/1
2024-05-06 15:14:59 Running  benchmark: pallet_gear.instantiate_module_type_section_per_kb(1 args) 41/50 1/1
Pallet: "pallet_gear", Extrinsic: "instantiate_module_code_section_per_kb", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========

Median Slopes Analysis
========
2024-05-06 15:15:04 Running  benchmark: pallet_gear.instantiate_module_type_section_per_kb(1 args) 50/50 1/1
-- Extrinsic Time --

Model:
Time ~=    36.28
    + c    0.101
              µs

Reads = 0 + (0 * c)
Writes = 0 + (0 * c)
Recorded proof Size = 0 + (0 * c)

Min Squares Analysis
========
-- Extrinsic Time --

Data points distribution:
    c   mean µs  sigma µs       %
    0     36.82     0.495    1.3%
   10     39.04     0.394    1.0%
   20     39.09     0.409    1.0%
   31     40.04     0.321    0.8%
   41     41.35     0.795    1.9%
   52      42.9      0.72    1.6%
   62     41.94     0.404    0.9%
   73     43.72     0.724    1.6%
   83     43.49     0.391    0.8%
   94     46.41     0.505    1.0%
  104     46.98     0.519    1.1%
  114     47.34     1.115    2.3%
  125     48.43     0.456    0.9%
  135     50.26     1.205    2.3%
  146     51.31     1.337    2.6%
  156     53.34     2.054    3.8%
  167     52.49         1    1.9%
  177        54     1.364    2.5%
  188     55.23      1.92    3.4%
  198     57.08     2.177    3.8%
  208     57.61     1.394    2.4%
  219     56.93     1.072    1.8%
  229     58.57     0.969    1.6%
  240      58.3     0.981    1.6%
  250     60.09     1.411    2.3%
  261      61.6     1.501    2.4%
  271     62.68     1.397    2.2%
  282     68.16     4.623    6.7%
  292     61.99     1.592    2.5%
  303     64.27     1.066    1.6%
  313      64.9     1.158    1.7%
  323     63.82     1.188    1.8%
  334     67.83     0.896    1.3%
  344     66.42     0.607    0.9%
  355     72.66     2.077    2.8%
  365     72.15     1.584    2.1%
  376     69.02     0.929    1.3%
  386     77.17     2.285    2.9%
  397      74.7     1.239    1.6%
  407     82.85     2.497    3.0%
  417      78.6     2.157    2.7%
  428     78.12     1.588    2.0%
  438     80.93      2.29    2.8%
  449     82.18     1.225    1.4%
  459     90.18     2.857    3.1%
  470     96.42     6.062    6.2%
  480     84.89     1.905    2.2%
  491     94.39     1.454    1.5%
  501     104.9     5.433    5.1%
  512     96.54     2.941    3.0%

Quality and confidence:
param     error
c         0.001

Model:
Time ~=    34.61
    + c     0.11
              µs

Reads = 0 + (0 * c)
Writes = 0 + (0 * c)
Recorded proof Size = 0 + (0 * c)

Pallet: "pallet_gear", Extrinsic: "instantiate_module_data_section_per_kb", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=    55.35
    + d    0.328
              µs

Reads = 0 + (0 * d)
Writes = 0 + (0 * d)
Recorded proof Size = 0 + (0 * d)

Min Squares Analysis
========
-- Extrinsic Time --

Data points distribution:
    d   mean µs  sigma µs       %
    0     46.56     0.626    1.3%
   10     57.11     0.323    0.5%
   20     59.01     0.422    0.7%
   31     64.27     0.762    1.1%
   41     68.07     0.782    1.1%
   52     70.15     0.524    0.7%
   62      78.2     1.135    1.4%
   73     82.83     1.381    1.6%
   83     85.83     1.098    1.2%
   94      89.7     0.764    0.8%
  104      93.3     1.962    2.1%
  114     96.95     1.357    1.3%
  125     101.6     1.787    1.7%
  135     106.2     2.221    2.0%
  146     104.3     0.895    0.8%
  156     106.1       1.1    1.0%
  167     109.2     0.679    0.6%
  177     114.6     1.455    1.2%
  188     115.6     0.632    0.5%
  198       119     0.909    0.7%
  208     121.2     0.567    0.4%
  219     125.8     1.986    1.5%
  229     129.7     1.104    0.8%
  240     133.4     0.832    0.6%
  250     134.7     0.325    0.2%
  261     143.9     1.229    0.8%
  271     144.5     0.869    0.6%
  282     147.8     0.708    0.4%
  292     150.9     0.685    0.4%
  303     155.8     1.515    0.9%
  313     156.9     0.477    0.3%
  323     162.3     1.477    0.9%
  334     166.4     0.931    0.5%
  344     166.8     0.989    0.5%
  355     176.7     3.961    2.2%
  365     177.4     1.906    1.0%
  376     179.8     2.069    1.1%
  386       183     1.595    0.8%
  397     187.3     2.533    1.3%
  407     189.7     2.171    1.1%
  417     192.7      3.52    1.8%
  428     195.5      1.55    0.7%
  438       200     3.429    1.7%
  449     203.4     3.377    1.6%
  459     206.8     2.742    1.3%
  470     208.6     2.559    1.2%
  480       210     1.666    0.7%
  491     215.8     1.998    0.9%
  501     220.2     2.508    1.1%
  512     220.3     1.692    0.7%

Quality and confidence:
param     error
d             0

Model:
Time ~=    55.71
    + d    0.328
              µs

Reads = 0 + (0 * d)
Writes = 0 + (0 * d)
Recorded proof Size = 0 + (0 * d)

Pallet: "pallet_gear", Extrinsic: "instantiate_module_global_section_per_kb", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=    38.29
    + c    1.264
              µs

Reads = 0 + (0 * c)
Writes = 0 + (0 * c)
Recorded proof Size = 0 + (0 * c)

Min Squares Analysis
========
-- Extrinsic Time --

Data points distribution:
    c   mean µs  sigma µs       %
    0      37.2      0.83    2.2%
   10     51.87     1.527    2.9%
   20     65.25     1.223    1.8%
   31     81.44     2.572    3.1%
   41     92.71     1.291    1.3%
   52     106.1     1.341    1.2%
   62     118.6     1.642    1.3%
   73       137     2.462    1.7%
   83     147.7     1.863    1.2%
   94     157.1     1.387    0.8%
  104     173.6     2.238    1.2%
  114     186.5     4.014    2.1%
  125     194.8     0.932    0.4%
  135     207.2     1.216    0.5%
  146     220.3     0.743    0.3%
  156     232.1     0.901    0.3%
  167     245.4     1.242    0.5%
  177     258.4      1.26    0.4%
  188     272.9     0.977    0.3%
  198     285.9     1.371    0.4%
  208       304     3.731    1.2%
  219     317.4     1.603    0.5%
  229     324.7     1.974    0.6%
  240     338.1     1.237    0.3%
  250     349.2     1.077    0.3%
  261     365.1     1.363    0.3%
  271     372.9     1.549    0.4%
  282     391.2     1.351    0.3%
  292     404.8     2.851    0.7%
  303     416.1     1.927    0.4%
  313       427     1.577    0.3%
  323     443.8      1.88    0.4%
  334     455.4     2.549    0.5%
  344       476     7.331    1.5%
  355     480.5     1.955    0.4%
  365     494.8     3.102    0.6%
  376     508.4     1.211    0.2%
  386       544     4.703    0.8%
  397     529.3     1.235    0.2%
  407       553     3.069    0.5%
  417     570.4     1.676    0.2%
  428     582.3     3.009    0.5%
  438     593.2     2.261    0.3%
  449     601.4      1.32    0.2%
  459     628.1     3.103    0.4%
  470     653.7     3.232    0.4%
  480     659.1     3.308    0.5%
  491     663.9     1.433    0.2%
  501     688.6     4.378    0.6%
  512     699.3      1.86    0.2%

Quality and confidence:
param     error
c         0.002

Model:
Time ~=    36.22
    + c    1.275
              µs

Reads = 0 + (0 * c)
Writes = 0 + (0 * c)
Recorded proof Size = 0 + (0 * c)

Pallet: "pallet_gear", Extrinsic: "instantiate_module_table_section_per_kb", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=    34.77
    + t    4.212
              µs

Reads = 0 + (0 * t)
Writes = 0 + (0 * t)
Recorded proof Size = 0 + (0 * t)

Min Squares Analysis
========
-- Extrinsic Time --

Data points distribution:
    t   mean µs  sigma µs       %
    0     37.35     0.672    1.7%
   10     80.97     1.451    1.7%
   20     124.4     0.492    0.3%
   31     173.4     0.785    0.4%
   41     214.8     0.529    0.2%
   52     263.7     2.562    0.9%
   62     304.2     0.559    0.1%
   73     353.4     1.125    0.3%
   83     394.8     1.177    0.2%
   94     425.6      1.03    0.2%
  104     467.3     2.126    0.4%
  114     511.2     1.274    0.2%
  125     554.8     0.841    0.1%
  135     598.5     2.235    0.3%
  146       642     0.991    0.1%
  156     685.4     1.421    0.2%
  167     730.8     1.555    0.2%
  177     775.6     3.275    0.4%
  188     816.3      1.69    0.2%
  198     860.7     1.957    0.2%
  208     904.4     2.551    0.2%
  219     951.5     4.534    0.4%
  229      1000     3.868    0.3%
  240      1046     3.725    0.3%
  250      1089     4.882    0.4%
  261      1140     3.592    0.3%
  271      1179     4.031    0.3%
  282      1220     3.089    0.2%
  292      1261     2.282    0.1%
  303      1306     3.239    0.2%
  313      1351     4.205    0.3%
  323      1392     3.498    0.2%
  334      1437     2.953    0.2%
  344      1479     2.983    0.2%
  355      1525     2.464    0.1%
  365      1566     1.727    0.1%
  376      1615     4.276    0.2%
  386      1655     3.979    0.2%
  397      1707     4.414    0.2%
  407      1747     5.558    0.3%
  417      1790     8.061    0.4%
  428      1838     7.011    0.3%
  438      1884     5.253    0.2%
  449      1998      13.2    0.6%
  459      1996     4.375    0.2%
  470      2026     2.702    0.1%
  480      2058     4.714    0.2%
  491      2107     5.531    0.2%
  501      2146     8.024    0.3%
  512      2194     7.788    0.3%

Quality and confidence:
param     error
t         0.003

Model:
Time ~=    32.82
    + t    4.226
              µs

Reads = 0 + (0 * t)
Writes = 0 + (0 * t)
Recorded proof Size = 0 + (0 * t)

Pallet: "pallet_gear", Extrinsic: "instantiate_module_type_section_per_kb", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=    39.26
    + y    0.112
              µs

Reads = 0 + (0 * y)
Writes = 0 + (0 * y)
Recorded proof Size = 0 + (0 * y)

Min Squares Analysis
========
-- Extrinsic Time --

Data points distribution:
    y   mean µs  sigma µs       %
    0     35.56     0.211    0.5%
   10     36.88     0.588    1.5%
   20     38.63     0.953    2.4%
   31     41.82     1.853    4.4%
   41     40.87     0.551    1.3%
   52     42.53     0.601    1.4%
   62     44.96     1.262    2.8%
   73     44.61     0.435    0.9%
   83     47.09     1.005    2.1%
   94     46.81      0.93    1.9%
  104     49.57     0.566    1.1%
  114     50.52     0.602    1.1%
  125     50.97     0.447    0.8%
  135     51.15     1.387    2.7%
  146     57.47     1.187    2.0%
  156     55.34     1.894    3.4%
  167     62.22     0.888    1.4%
  177      60.7     1.656    2.7%
  188      63.4     1.422    2.2%
  198     64.68     0.756    1.1%
  208     64.96     0.486    0.7%
  219     66.17     0.366    0.5%
  229     67.34     1.133    1.6%
  240     67.99     1.412    2.0%
  250     69.09     1.156    1.6%
  261     69.36     0.555    0.8%
  271     85.28     3.426    4.0%
  282     71.86     0.826    1.1%
  292     73.77     1.383    1.8%
  303     75.08     1.314    1.7%
  313     77.06     1.851    2.4%
  323      78.2     1.772    2.2%
  334     85.26     2.682    3.1%
  344     100.9     20.73   20.5%
  355     81.49      2.44    2.9%
  365     80.49     1.923    2.3%
  376     80.74     0.553    0.6%
  386     81.09     0.766    0.9%
  397     87.41      1.36    1.5%
  407     83.49     1.307    1.5%
  417      87.9       1.3    1.4%
  428     86.66     0.656    0.7%
  438     82.61     1.095    1.3%
  449      91.3     1.676    1.8%
  459     86.62      1.05    1.2%
  470     83.51     0.492    0.5%
  480     85.48     1.158    1.3%
  491     89.25     2.738    3.0%
  501     86.67     1.537    1.7%
  512     85.95     1.196    1.3%

Quality and confidence:
param     error
y         0.001

Model:
Time ~=    39.77
    + y     0.11
              µs

Reads = 0 + (0 * y)
Writes = 0 + (0 * y)
Recorded proof Size = 0 + (0 * y)
Test measurement run
Pallet: "pallet_gear", Extrinsic: "instantiate_module_code_section_per_kb", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=    35.14
    + c    0.075
              µs

Reads = 0 + (0 * c)
Writes = 0 + (0 * c)
Recorded proof Size = 0 + (0 * c)

Min Squares Analysis
========
-- Extrinsic Time --

Data points distribution:
    c   mean µs  sigma µs       %
    0     34.06     0.336    0.9%
   10     36.59     0.166    0.4%
   20     37.94     0.369    0.9%
   31     38.02     0.202    0.5%
   41     38.63     0.378    0.9%
   52     40.08     0.866    2.1%
   62     40.52     1.203    2.9%
   73     40.07      0.33    0.8%
   83     40.18      0.22    0.5%
   94     43.06     0.826    1.9%
  104     43.48     1.064    2.4%
  114     44.47     1.296    2.9%
  125     44.58      0.52    1.1%
  135     46.47     1.086    2.3%
  146     46.61     1.099    2.3%
  156     47.46     1.592    3.3%
  167     48.95     1.711    3.4%
  177     48.56     0.811    1.6%
  188     49.33     1.269    2.5%
  198     49.45     0.656    1.3%
  208     49.88     0.448    0.8%
  219     51.34     0.559    1.0%
  229     50.56     0.178    0.3%
  240     52.32     0.466    0.8%
  250      52.7     0.552    1.0%
  261     54.32     0.883    1.6%
  271      54.3     0.638    1.1%
  282     55.66      0.86    1.5%
  292     55.83     0.714    1.2%
  303      56.9     0.431    0.7%
  313     59.41     1.389    2.3%
  323     60.34     1.638    2.7%
  334     61.56     1.021    1.6%
  344     59.57     0.299    0.5%
  355      60.2     0.684    1.1%
  365     63.97     1.096    1.7%
  376     64.44     1.099    1.7%
  386     65.54     1.086    1.6%
  397     65.29      0.55    0.8%
  407     65.92     0.881    1.3%
  417     68.46     0.549    0.8%
  428        69     0.809    1.1%
  438     67.69     0.492    0.7%
  449     68.59     0.247    0.3%
  459     69.18     0.605    0.8%
  470     70.03     0.739    1.0%
  480     72.28     0.778    1.0%
  491     73.27     1.279    1.7%
  501     73.15     0.978    1.3%
  512     73.42     0.354    0.4%

Quality and confidence:
param     error
c             0

Model:
Time ~=    35.23
    + c    0.075
              µs

Reads = 0 + (0 * c)
Writes = 0 + (0 * c)
Recorded proof Size = 0 + (0 * c)

Pallet: "pallet_gear", Extrinsic: "instantiate_module_data_section_per_kb", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=     48.9
    + d    0.192
              µs

Reads = 0 + (0 * d)
Writes = 0 + (0 * d)
Recorded proof Size = 0 + (0 * d)

Min Squares Analysis
========
-- Extrinsic Time --

Data points distribution:
    d   mean µs  sigma µs       %
    0     44.66     0.793    1.7%
   10     48.88     0.977    1.9%
   20     51.07     0.729    1.4%
   31     53.14      0.57    1.0%
   41     55.06     0.175    0.3%
   52     57.85     0.609    1.0%
   62     60.03     0.514    0.8%
   73     62.42     0.767    1.2%
   83     64.56     0.318    0.4%
   94     65.98     0.781    1.1%
  104     67.76     0.893    1.3%
  114      70.9      0.64    0.9%
  125     72.49     0.366    0.5%
  135     77.82     1.349    1.7%
  146     78.15     0.287    0.3%
  156     80.04     0.627    0.7%
  167     83.98     0.854    1.0%
  177     82.87     0.587    0.7%
  188     86.25     0.641    0.7%
  198     87.43      0.52    0.5%
  208      89.6      0.76    0.8%
  219     91.62     0.286    0.3%
  229     94.08     0.498    0.5%
  240     94.63     0.466    0.4%
  250      97.7     0.877    0.8%
  261     102.2     0.459    0.4%
  271       103     1.102    1.0%
  282     102.8     0.404    0.3%
  292     104.9      0.64    0.6%
  303     106.9     0.566    0.5%
  313     108.7     0.525    0.4%
  323     110.9      0.93    0.8%
  334       114     0.816    0.7%
  344     114.2     0.737    0.6%
  355     117.9     1.646    1.3%
  365     119.2     0.897    0.7%
  376     119.2     0.546    0.4%
  386     123.3     0.619    0.5%
  397     125.8     1.266    1.0%
  407     126.6     0.524    0.4%
  417     130.1     1.426    1.0%
  428       130      0.68    0.5%
  438     132.4      0.74    0.5%
  449     135.4     0.729    0.5%
  459       137     0.575    0.4%
  470     140.6     2.378    1.6%
  480     136.6     0.567    0.4%
  491     140.8     0.866    0.6%
  501     142.7     0.658    0.4%
  512     144.4     1.506    1.0%

Quality and confidence:
param     error
d             0

Model:
Time ~=    48.74
    + d    0.191
              µs

Reads = 0 + (0 * d)
Writes = 0 + (0 * d)
Recorded proof Size = 0 + (0 * d)

Pallet: "pallet_gear", Extrinsic: "instantiate_module_global_section_per_kb", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=     48.8
    + c    1.191
              µs

Reads = 0 + (0 * c)
Writes = 0 + (0 * c)
Recorded proof Size = 0 + (0 * c)

Min Squares Analysis
========
-- Extrinsic Time --

Data points distribution:
    c   mean µs  sigma µs       %
    0     33.75     0.173    0.5%
   10     49.56     0.942    1.9%
   20     63.25     0.392    0.6%
   31     78.36     0.277    0.3%
   41      91.8     0.601    0.6%
   52     105.6     0.697    0.6%
   62       119     0.515    0.4%
   73     133.3     0.639    0.4%
   83     146.6     0.524    0.3%
   94     160.5     1.012    0.6%
  104     173.5     1.129    0.6%
  114     185.8     0.772    0.4%
  125       202     1.206    0.5%
  135     213.1     0.744    0.3%
  146     231.3     2.701    1.1%
  156     242.6     1.762    0.7%
  167     258.8     1.232    0.4%
  177       271     1.498    0.5%
  188     283.8     1.391    0.4%
  198     295.9     1.295    0.4%
  208     312.1     1.966    0.6%
  219     323.4     2.102    0.6%
  229     344.8     3.363    0.9%
  240     352.2     1.879    0.5%
  250     366.7     1.333    0.3%
  261     387.3     2.489    0.6%
  271     397.5     3.117    0.7%
  282       382     3.607    0.9%
  292     390.5     2.354    0.6%
  303     407.7     2.586    0.6%
  313     415.3     0.993    0.2%
  323     431.4      1.26    0.2%
  334     441.6     3.576    0.8%
  344     448.9     1.942    0.4%
  355     465.1     2.116    0.4%
  365       477     3.056    0.6%
  376     494.1     3.413    0.6%
  386     505.3     1.888    0.3%
  397     521.1     2.148    0.4%
  407     528.1     2.997    0.5%
  417       540     2.699    0.4%
  428     555.5     3.509    0.6%
  438     568.6     4.148    0.7%
  449     576.5     1.952    0.3%
  459     596.7      2.36    0.3%
  470     606.1     3.098    0.5%
  480     622.5     3.157    0.5%
  491       625     4.523    0.7%
  501     643.8     5.707    0.8%
  512     654.4     4.764    0.7%

Quality and confidence:
param     error
c         0.003

Model:
Time ~=    51.35
    + c    1.186
              µs

Reads = 0 + (0 * c)
Writes = 0 + (0 * c)
Recorded proof Size = 0 + (0 * c)

Pallet: "pallet_gear", Extrinsic: "instantiate_module_table_section_per_kb", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=    38.43
    + t     4.12
              µs

Reads = 0 + (0 * t)
Writes = 0 + (0 * t)
Recorded proof Size = 0 + (0 * t)

Min Squares Analysis
========
-- Extrinsic Time --

Data points distribution:
    t   mean µs  sigma µs       %
    0     32.52     0.143    0.4%
   10     75.07     0.217    0.2%
   20     116.7     0.267    0.2%
   31     163.1     1.381    0.8%
   41     203.1     0.318    0.1%
   52     249.1     0.445    0.1%
   62     290.2     0.453    0.1%
   73     336.2     0.802    0.2%
   83     384.7     1.262    0.3%
   94     431.7     3.006    0.6%
  104     471.7     3.007    0.6%
  114     508.3     1.355    0.2%
  125     556.2     1.587    0.2%
  135       602     1.556    0.2%
  146     644.7     2.375    0.3%
  156     689.2     2.438    0.3%
  167     730.8     1.733    0.2%
  177     771.9     1.673    0.2%
  188     817.3     5.137    0.6%
  198     864.8     3.316    0.3%
  208       901     1.842    0.2%
  219       950       2.3    0.2%
  229     995.5     1.762    0.1%
  240      1018      3.13    0.3%
  250      1053     1.369    0.1%
  261      1097     1.549    0.1%
  271      1157     2.674    0.2%
  282      1205     1.779    0.1%
  292      1247     2.806    0.2%
  303      1282     1.164    0.0%
  313      1324     1.656    0.1%
  323      1362     0.888    0.0%
  334      1409     1.448    0.1%
  344      1451     2.979    0.2%
  355      1495     1.392    0.0%
  365      1539     3.146    0.2%
  376      1590     2.923    0.1%
  386      1634     2.284    0.1%
  397      1682     2.869    0.1%
  407      1729     5.371    0.3%
  417      1764      2.05    0.1%
  428      1801     2.427    0.1%
  438      1843     4.134    0.2%
  449      1886     1.376    0.0%
  459      1925      1.57    0.0%
  470      1973     1.312    0.0%
  480      2014     0.984    0.0%
  491      2059     2.342    0.1%
  501      2096     1.244    0.0%
  512      2146     5.114    0.2%

Quality and confidence:
param     error
t         0.002

Model:
Time ~=    39.08
    + t    4.119
              µs

Reads = 0 + (0 * t)
Writes = 0 + (0 * t)
Recorded proof Size = 0 + (0 * t)

Pallet: "pallet_gear", Extrinsic: "instantiate_module_type_section_per_kb", Lowest values: [], Highest values: [], Steps: 50, Repeat: 20
Raw Storage Info
========

Median Slopes Analysis
========
-- Extrinsic Time --

Model:
Time ~=    35.19
    + y    0.099
              µs

Reads = 0 + (0 * y)
Writes = 0 + (0 * y)
Recorded proof Size = 0 + (0 * y)

Min Squares Analysis
========
-- Extrinsic Time --

Data points distribution:
    y   mean µs  sigma µs       %
    0     32.68     0.164    0.5%
   10     33.78     0.119    0.3%
   20     35.81     0.446    1.2%
   31     37.02     0.203    0.5%
   41     38.89     0.835    2.1%
   52     39.05     0.175    0.4%
   62     42.55     0.909    2.1%
   73     42.81     0.908    2.1%
   83     44.71     1.352    3.0%
   94     44.57     1.114    2.4%
  104     48.18     0.579    1.2%
  114     46.05     0.774    1.6%
  125     47.59     0.806    1.6%
  135     48.16      0.29    0.6%
  146     49.46     0.438    0.8%
  156     50.36     0.335    0.6%
  167     51.72     0.203    0.3%
  177     59.78     0.973    1.6%
  188     56.72     0.379    0.6%
  198     61.59     0.464    0.7%
  208     54.76     0.283    0.5%
  219      55.4     0.399    0.7%
  229     60.12     0.611    1.0%
  240     60.76     0.517    0.8%
  250     60.74     0.411    0.6%
  261     61.53     1.586    2.5%
  271     62.64     1.368    2.1%
  282     65.11     0.982    1.5%
  292     61.54     0.942    1.5%
  303     62.36     0.486    0.7%
  313     64.37     0.933    1.4%
  323     64.65      0.55    0.8%
  334     69.95       3.4    4.8%
  344     75.86     3.035    4.0%
  355      76.2     0.699    0.9%
  365     77.87     0.715    0.9%
  376     76.78     1.801    2.3%
  386     75.45     0.991    1.3%
  397     78.95     2.048    2.5%
  407     78.23     1.978    2.5%
  417     80.02     1.712    2.1%
  428     81.61     2.805    3.4%
  438      73.8      0.47    0.6%
  449     78.11      1.04    1.3%
  459     79.02     0.985    1.2%
  470     81.23     1.555    1.9%
  480     80.53      0.77    0.9%
  491     81.94     0.487    0.5%
  501     82.72     0.467    0.5%
  512     84.19     0.873    1.0%

Quality and confidence:
param     error
y             0

Model:
Time ~=    35.53
    + y      0.1
              µs

Reads = 0 + (0 * y)
Writes = 0 + (0 * y)
Recorded proof Size = 0 + (0 * y)

Created file: "./target/weights.json"

For this investigation, three additional benches were added to estimate the approximate instantiation weight of sections:

  • Global
  • Table (with elements)
  • Type

Bench results

The table summarize result of several subsequent runs on reference bench machine.

section weight in micro sec
code 0.3
data 0.54
global 2.7
table 19.0
type 0.4

bench_stand_bench_result.txt

Global

As bench results show, the weight of the global section is quite high at 2.7. However, due to the low number of global segments in an average wasm module (max 4 global segments according to the dapps/contracts repo).

Table (with elements)

As bench results show, the weight of the table section (with elements) is high at 19.0.
This is likely due to additional memory allocation for the table and initialization of its elements (memcpy).
In theory it should be similar to data section instantiation weight, expect the fact what data section instantiation doesn't allocates memory.

It's probably better to charge for the instantiation of the table section separately because the table could have an arbitrary size, and as a result, it could be abused.

Type section

The weight of the types section should be comparable to, or close to, the weight of code section instantiation, because no heavy work should be done during the instantiation of these sections, nor memory copying or allocation.

As the benchmark results show, the types weight is 0.4 (for comparison, the code weight is 0.3).

Summary

For the instantiation of global and table sections, we should charge separately. Additionally, it may be necessary to limit the number of segments in these sections.

For the type section, it's probably better not to charge separately but to charge it as part of the code section (code size).