Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Benchmarking of Slacked Gas Metering performance impact #11677

Open
pepyakin opened this issue Jun 15, 2022 · 29 comments
Open

Benchmarking of Slacked Gas Metering performance impact #11677

pepyakin opened this issue Jun 15, 2022 · 29 comments
Assignees

Comments

@pepyakin
Copy link
Contributor

pepyakin commented Jun 15, 2022

This task aims to:

  1. Test the performance impact of the slacked gas metering feature (write-up here) compared to no metering.
  2. Find the best trade-off for the parameters. The prototype is available in my fork of wasmtime here.

In that fork, I abused the consume_fuel feature making the out-of-gas checks async.

The usage can be seen in the example:

  1. Install the signal handler for SIGUSR1.
  2. Each time the signal arrives, check if the fuel ran out.
  3. Spawn a thread that periodically interrupts the code.

My changes are incomplete, and some parts of the wasmtime do not work in my branch. Specifically, it lacks the typed func support. Only Linux x86_64 is supported. The API is subject to a change.

My proposal to approach this is:

  1. Switch wasmtime to the version in my fork.
  2. Configure wasmtime to consume_fuel.
  3. Ensure enough fuel is available in the store before execution. Hardcoding it is okay.
  4. Install the signal handler. I don't mind coding it right in the wasmtime executor code. We are hacking, after all.
  5. Spawn a thread that periodically sends the SIGUSR1 signal to the thread executing the wasm runtime call. The frequency should be configurable to help us estimate the impact of the frequency on performance. I guess the thread should stop sending signals after the execution is completed.
  6. Switch registration of host functions from typed to untyped versions.
  7. (UPD): Get rid of typed functions when calling into wasm.

Since the host functions are now untyped, this affects the performance. Therefore, the baseline (for the no-fuel metering scenario) should also be collected with untyped host functions.

Bonus points:

  1. It would be good if the teams like Moonbeam could take this benchmark and evaluate the impact on their use cases.
  2. I am curious about the effect of the non-slacked consume_fuel feature in the current upstream wasmtime version.

There may be bugs in the implementation. Please share if any is discovered.

@koute
Copy link
Contributor

koute commented Jun 27, 2022

Here are some benchmark numbers. The times in the first three benchmarks are in microseconds, and for the last benchmark they're in seconds.


call_empty_function (this measures instantiation overhead when no memory is touched)

threads fuel without_fuel
1 6.83 6.96
2 16.37 16.88
4 27.45 28.78
8 40.50 40.98
16 56.67 57.46

dirty_1mb_of_memory (this mostly measures instantiation overhead when a bunch of memory is dirtied)

threads fuel without_fuel
1 144.60 141.36
2 210.38 206.28
4 311.41 310.10
8 521.12 516.85
16 730.88 710.06

burn_cpu_cycles (this does a lot of work summing numbers in a loop essentially burning a lot of CPU inside of WASM)

threads fuel without_fuel
1 10602.86 10488.88
2 10796.17 10578.70
4 10791.26 10677.54
8 10794.94 10744.65
16 10949.30 10880.29

block_production (a more real-world benchmark which produces a block with 5925 transactions)

kind fuel without_fuel
no proof 1.9302 1.9058
with proof 1.9934 1.9612

This was ran with 1ms interval to trigger the fuel check signal handler, with the same wasmtime branch for both with fuel and without fuel, with substrate modified to use untyped calls into the runtime/into the host.

I'll also check the vanilla consume_fuel implementation, and try with an even higher fuel check frequency.

@pepyakin How short do think we'll want to go with the fuel check interval? (Assuming we're going to use this in production.)

@koute
Copy link
Contributor

koute commented Jun 28, 2022

Some more numbers. Everything is in microseconds, and for all of the benchmarks their 1 thread variant was run. Exactly the same base commit of wasmtime was used in all of the benchmarks, that is: the no_fuel and vanilla_fuel were run with wasmtime from f19d8cc8510535b03eb92e6eb9a643bd47f5314e, while async_fuel were run with @pepyakin 's fork from here (which branched from commit f19d8cc8510535b03eb92e6eb9a643bd47f5314e).

time/iter [us]

threads no_fuel vanilla_fuel async_fuel_10000us async_fuel_1000us async_fuel_500us async_fuel_250us async_fuel_100us async_fuel_50us
call_empty_function 7 7 6 6 7 7 7 7
dirty_1mb_of_memory 141 145 143 145 144 146 146 147
burn_cpu_cycles 10404 10464 10408 10472 10471 10291 10709 10685
block_production 1889225 1930673 1906314 1917302 1911202 1922949 1969804 1968728

deviation (+/-) [us]

threads no_fuel vanilla_fuel async_fuel_10000us async_fuel_1000us async_fuel_500us async_fuel_250us async_fuel_100us async_fuel_50us
call_empty_function 0 0 0 0 0 0 0 0
dirty_1mb_of_memory 1 1 0 1 1 1 1 1
burn_cpu_cycles 58 52 66 49 53 148 50 63
block_production 10545 6305 18691 20813 4775 4136 12395 3617

Unless I did something wrong (and I checked the results manually, so I don't think so?) it seems like the vanilla fuel metering is roughly just as efficient as this async one. (Maybe a little bit less so, but there's a lot of variation in the result, so it's kind of a wash.) So either we don't need it, or the benchmarks have a gap where they don't stress a scenario where the async metering would be a win.

I'll try again with more of an end-to-end test running a full node to compare the no_fuel, vanilla_fuel and async_fuel.

@pepyakin
Copy link
Contributor Author

Those are fascinating findings.

Unless my benchmarks were broken, they showed vanilla had a considerable overhead. The lowest difference was in keccak and the highest difference was in regex and wasmi.

The question is now how that applies to workflows we are interested in (and even, what those workflows are). The situation with wasmi is concerning since I anticipate that people would like to implement STFs that use VMs. So I think we should test that. Would you be able to hack up a test case with wasmi? I also hear that seal/ink is going to use wasmi compiled in wasm for contracts initially, so maybe @athei can help with that.

Then as I mentioned in OP, we should evaluate the numbers on our users' workflows. That is, try to gather the numbers for the workloads that parachains teams think are representative. Moonbeam also uses EVM which is VM, so it would be doubly interesting.

Risking stating the obvious, but if vanilla works as well as the async version, the vanilla wins hands down. Vanilla is already implemented, it is easier to test and reason about, and it does not require additional low-level machinery. For our use case, it also does not require any additional security assumptions.

@koute
Copy link
Contributor

koute commented Jun 29, 2022

Okay, indeed, the difference can be bigger depending on the benchmark. I ported the regex_redux benchmark into our test runtime (it uses wasmi from within the runtime to interpret a WASM kernel which uses the regex crate) and here are the results:

threads no_fuel vanilla_fuel async_fuel_10000us async_fuel_1000us async_fuel_500us async_fuel_250us async_fuel_100us async_fuel_50us
wasmi_regex_redux 509210 634072 580606 578404 567814 580504 581095 587233

So the overhead is very highly dependent on the exact workload we're running, although the difference (while it is there and is significant) is not as bad as I'd expect it. The run with vanilla fuel checks takes ~125% of the baseline time and the runs with the async fuel checks take ~110%.

An interesting note here is that I had to significantly increase the fuel amount to get this benchmark to run. The heaviest benchmark I ran before (the block production one) required me to set the fuel (and this is not exact, since I was just adding zeros at the end until it worked) to 100 million, while this new benchmark required it to be set to 10000 million, so two orders of magnitude more.

I'll maybe try to jig a benchmark with Moonbeam and see what's the difference there. I've found our smart-bench repo so maybe that can be easily repurposed to test this.

@pepyakin
Copy link
Contributor Author

Those numbers are significantly different from whatever I saw locally and I am curious to know why we see this difference. Could you update your branch if you haven't so that I can reproduce?

Those are fascinating results. It looks like maybe using vanilla can be used already. Later on we might optimize it with the slacked metering it needed and it is worth it. For that we can refocus on implementing the schedule: I assume cost 1 for each instruction is not good.

Then regarding the transfers, I assume the results we were seeing is because the most execution happens in the node/IO?

@koute
Copy link
Contributor

koute commented Jun 29, 2022

Yeah, it'd be a good idea if another set of eyes could double-check those results.

I've pushed all of the changes to my branch; go into the wasmtime-benches in the root directory and run the run2.sh to rerun the wasmi_regex_redux benchmark and run1.sh for the other benchmarks.

Then regarding the transfers, I assume the results we were seeing is because the most execution happens in the node/IO?

I could check if necessary, but it's certainly doing less work in the WASM. It's still not an insignificant amount of work though, since I do have to set the fuel fairly high for it to work.

@pepyakin
Copy link
Contributor Author

Below are the results of running ./run2.sh. I used two machines: a bare metal hetzner AMD Ryzen x5950 and my unplugged laptop based on Apple Silicon (M1 Max, aarch64). I was also using my laptop a bit so I guess it is noisy, but it is still significantly faster than x5950.

The numbers in ns so I converted them into us. Weird thing I had to increase the amount of fuel for M1 Max by adding 3 zeroes. I also took the liberty to reformat the table, I find it way easier to read it this way, hope it's not troubling. The percentages are normalized to the no_fuel case on the same machine.

machine x5950 M1 Max
no_fuel 373724 291178
vanilla_fuel 416475 (+11.4%) 373128 (+28.1%)
async_fuel_10000us 361922 (-3.1%) 291064 (-0.03%)
async_fuel_1000us 363092 -
async_fuel_500us 362494 -
async_fuel_250us 367351 -
async_fuel_100us 369303 -
async_fuel_50us 366331 -

The numbers overall are in line with what I observed before. I guess the differences we see can be explained by the different microarchitectures. This is a bit annoying since we now need to pick the golden machine.

@koute
Copy link
Contributor

koute commented Jun 30, 2022

Those are very interesting results, I wouldn't expect that a newer microarchitecture would make the fuel checks essentially zero cost. This is a stupid question, but you did enable the fuel checks for the async fuel benchmarks and if you lower the amount of fuel it interrupts itself properly, right? (:

Anyway, I just had an idea. I ran a quick experiment: I took your wasmtime branch and applied this patch:

diff --git a/crates/cranelift/src/func_environ.rs b/crates/cranelift/src/func_environ.rs
index 5acb66ec7..76f22d38e 100644
--- a/crates/cranelift/src/func_environ.rs
+++ b/crates/cranelift/src/func_environ.rs
@@ -355,7 +355,7 @@ impl<'module_environment> FuncEnvironment<'module_environment> {
 
     fn fuel_function_entry(&mut self, builder: &mut FunctionBuilder<'_>) {
         // self.fuel_load_into_var(builder);
-        // self.fuel_check(builder);
+        self.fuel_check(builder);
     }
 
     fn fuel_function_exit(&mut self, builder: &mut FunctionBuilder<'_>) {
@@ -526,7 +526,7 @@ impl<'module_environment> FuncEnvironment<'module_environment> {
     /// Checks the amount of remaining, and if we've run out of fuel we call
     /// the out-of-fuel function.
     fn fuel_check(&mut self, builder: &mut FunctionBuilder) {
-        self.fuel_increment_var(builder);
+        // self.fuel_increment_var(builder);
         let out_of_gas_block = builder.create_block();
         builder.set_cold_block(out_of_gas_block);
         let continuation_block = builder.create_block();
@@ -554,7 +554,7 @@ impl<'module_environment> FuncEnvironment<'module_environment> {
         // Note that we save/reload fuel around this since the out-of-gas
         // intrinsic may alter how much fuel is in the system.
         builder.switch_to_block(out_of_gas_block);
-        self.fuel_save_from_var(builder);
+        // self.fuel_save_from_var(builder);
         let out_of_gas_sig = self.builtin_function_signatures.out_of_gas(builder.func);
         let (vmctx, out_of_gas) = self.translate_load_builtin_function_address(
             &mut builder.cursor(),
@@ -563,7 +563,7 @@ impl<'module_environment> FuncEnvironment<'module_environment> {
         builder
             .ins()
             .call_indirect(out_of_gas_sig, out_of_gas, &[vmctx]);
-        self.fuel_load_into_var(builder);
+        // self.fuel_load_into_var(builder);
         builder.ins().jump(continuation_block, &[]);
         builder.seal_block(continuation_block);

and ran the benchmark with it; here are the results:

no_fuel vanilla_fuel pinned_vanilla_fuel async_fuel_10000us
wasmi_regex_redux 509210 634072 594834 580606

So basically this is a hybrid of the vanilla fuel checks where it checks for fuel synchronously but it uses your pinned register instead of storing it in a variable, and the performance is still quite competitive. And I can confirm that the fuel checks work here - if I lower the fuel it gets interrupted properly. So maybe this could be a still-fast-but-simpler alternative to going full async?

Could you also check how this performs on your machines? Command line invocation to run this after applying the patch and switching to that wasmtime copy in Cargo.toml:

HACK_CONSUME_FUEL=1 HACK_FUEL=10000000000 cargo bench --features wasmtime,sc-executor-wasmtime/fuel-check-vanilla --bench bench -- --output-format=bencher wasmi_regex_redux_from_test_runtime_with_pooling_cow_fresh_on_1_threads

(Note the fuel-check-vanilla since this doesn't need the extra signaling thread.)

@pepyakin
Copy link
Contributor Author

I just re-ran all the benchmarks and can confirm that they result in the very similar numbers. Lowering the fuel available results in a proper interrupt, which indicates it actually doing metering.

Regarding the vanilla fuel + pinned reg. I think your snippet lacks the fuel check in the loop headers. I uncommented it there and run the benchmarks.

I actually tried this (I think revisions before b36a6bae3ba945cb83f758097cbd382a51e24746 correspond to that approach) and was not satisfied with the results. In my local benchmarks (based on wasmi keccak, regex redux and rev_comp), it shows pretty nasty regressions around -10% on keccak and rev_comp and -21% on regex_redux (FWIW, they do not include a separate interrupter thread).

However, for your run2.sh benchmark, it performs way better on x5950: 367594 us (1.6% increase from no fuel)

@pepyakin
Copy link
Contributor Author

M1 results

  • No fuel: 286486 us
  • Vanilla fuel: 375514 us (31% increase)
  • Vanilla fuel + pinned reg: 385862 us (34.6% increase)
  • Async fuel: 296153 us (3.37% increase from no fuel)

I cross-checked the result several times, and yes, it seems that the vanilla metering that leverages pinned register is slower than flushing/reloading the counter allowing it to spill.

@pepyakin
Copy link
Contributor Author

And to top it off, run1.sh on x5950 shows similar performance on the block production benchmark.

  • no fuel: 2159813 us
  • vanilla fuel: 2208390 us (2.2% increase)
  • vanilla fuel + pinned reg: 2165488 us (2.2% increase)
  • async fuel: 2198707 us (1.8% increase)

@shawntabrizi
Copy link
Member

From what I understand with what @pepyakin told me in DM, that this fuel metering is baked into the Wasm runtime, and exists whether or not we use it.

If so, can we generate a Wasm runtime with the fuel metering, and simply run all the runtime benchmarks to see the impact of each extrinsic?

@pepyakin
Copy link
Contributor Author

To give the context,

When you initialize wasmtime, you need to create an engine. You can configure it to embed the fuel metering. If you do so, then all the modules you create with that engine will consume gas. When you create a module from wasm bytecode, wasmtime will translate it to the native code. In case the consume_fuel option enabled then the fuel checks will be embedded into the native code as well.

the discussion was about introducing, perhaps, a special host function that would execute the given function from the module and do so with metering enabled. For this to work, there are two options:

  1. Either compile the module twice, once with the engine configured to consume_fuel and once without. That has a downside that the expensive compilation will have to be performed twice. It also will complicate the caching logic used in PVFs since we will now have to keep two different compiled artifacts around.
  2. Or alternatively, you would compile the module once with consume_fuel and just always do metering. In case, the fuel runs out when outside of that special host function, we just ignore that (and replenish fuel as needed).

So with that clarification out of the way,

and simply run all the runtime benchmarks to see the impact of each extrinsic?

Yes, I think this is possible and easy to achieve. We need just to:

  1. configure the engine as I said above
  2. then add fuel to the store. The exact amount of fuel does not matter, as long as it is enough.

Those two steps should be enough to run the benchmarks.

@koute
Copy link
Contributor

koute commented Jul 1, 2022

And to top it off, run1.sh on x5950 shows similar performance on the block production benchmark.

  • no fuel: 2159813 us

  • vanilla fuel: 2208390 us (2.2% increase)

  • vanilla fuel + pinned reg: 2165488 us (2.2% increase)

  • async fuel: 2198707 us (1.8% increase)

If my math is right the pinned reg percentage should be 0.2% here, no? (: Which is faster than even the async fuel run, but from what I've seen in my runs I'm assuming this is in the margin of error and they're essentially comparable here.

M1 results

  • No fuel: 286486 us

  • Vanilla fuel: 375514 us (31% increase)

  • Vanilla fuel + pinned reg: 385862 us (34.6% increase)

  • Async fuel: 296153 us (3.37% increase from no fuel)

I cross-checked the result several times, and yes, it seems that the vanilla metering that leverages pinned register is slower than flushing/reloading the counter allowing it to spill.

I guess this is a side effect of M1's huge internal register file; since that memory location is accessed so often it's kept in a register internally anyway, but by letting the hardware manage it we're not hogging one ISA register from being used.

Anyway, I think we do now have conclusive evidence that:

  1. the performance highly depends on the workload,
  2. the performance highly depends on the microarchitecture you're running on,
  3. the async fuel strategy of metering is essentially always the fastest out of the alternatives; the difference is just by how much exactly.
  1. Or alternatively, you would compile the module once with consume_fuel and just always do metering. In case, the fuel runs out when outside of that special host function, we just ignore that (and replenish fuel as needed).

Wouldn't it be enough to just set the fuel to u64::MAX so that it essentially never runs out, or am I missing something here? We recreate the store on each invocation anyway so this way we shouldn't require any runtime replenishment.

@pepyakin
Copy link
Contributor Author

pepyakin commented Jul 1, 2022

If my math is right the pinned reg percentage should be 0.2% here, no? (: Which is faster than even the async fuel run, but from what I've seen in my runs I'm assuming this is in the margin of error and they're essentially comparable here.

Oh god, I am not sure what happened there. Decided not to risk it and re-run:

  • no fuel: 2200360581 ns
  • vanilla fuel: 2245729077 ns (2% increase)
  • vanilla fuel + pinned reg: 2245572724 ns (2% increase)
  • async fuel: 2185571063 ns (0.6% decrease)

Wouldn't it be enough to just set the fuel to u64::MAX so that it essentially never runs out, or am I missing something here? We recreate the store on each invocation anyway so this way we shouldn't require any runtime replenishment.

When I said "replenish as needed" I did not mean it between calls but within a call. If you run the code without metering you should never observe OOG and that's why I felt to pedantically1 mention that. But you are right, u64::MAX should be enough for everybody. @shawntabrizi: don't mind this, for experimental benchmarks, it will be fine to use u64::MAX.

Anyway, I think we do now have conclusive evidence that:

  1. the performance highly depends on the workload,
  2. the performance highly depends on the microarchitecture you're running on,
  3. the async fuel strategy of metering is essentially always the fastest out of the alternatives; the difference is just by how much exactly.

Yes, agreed.

From here, we should look at what's the impact on extrinsics. Maybe we should run the same tests on the reference hardware?

Footnotes

  1. Pedantically speaking, we have the legacy reuse mechanism, where IIRC we reuse the same instance together with the store. There we would probably need to refuel it in between the calls.

@koute
Copy link
Contributor

koute commented Jul 1, 2022

From here, we should look at what's the impact on extrinsics. Maybe we should run the same tests on the reference hardware?

Yep. I'm currently doing that; I got a moonbeam node running, and got the EVM benches from the smart-bench running. It's little awkward and slow to run, but it works. The benches don't provide actual real execution time, but I hacked that in and it seems to work and is reliable enough from run-to-run; the execution time increases the more extrinsic I queue, and the times are mostly consistent between independent runs. So I'll just port over all of the necessary substrate changes and get some numbers.

I can also run these on the reference hardware since I did get access to it a few months back.

Footnotes

  1. Pedantically speaking, we have the legacy reuse mechanism, where IIRC we reuse the same instance together with the store. There we would probably need to refuel it in between the calls.

Yeah, that's correct.

@koute
Copy link
Contributor

koute commented Jul 1, 2022

Here are the numbers for block execution on Moonbeam running 256 extrinsics of the erc20 contract benchmark in a single block on my Threadripper 3070x:

  • no fuel: 175ms
  • vanilla fuel: 234ms
  • async fuel: 177ms

This looks really really good. At least for this benchmark there's essentially no impact on performance with the async fuel checks. (I made sure to check that lowering the fuel breaks the execution and it does, so metering is working.)

I'll grab numbers on our reference hardware next week.

@koute
Copy link
Contributor

koute commented Jul 4, 2022

Here are the numbers from our reference hardware. (i7-7700K running on bare metal)

time/iter [us]

no_fuel vanilla_fuel async_fuel_10000us async_fuel_1000us async_fuel_500us async_fuel_250us async_fuel_100us async_fuel_50us
wasmi_regex_redux 497881 549998 508793 523502 539745 518016 519645 523354
call_empty_function 9 8 9 9 9 10 9 9
dirty_1mb_of_memory 239 238 238 247 253 261 245 247
burn_cpu_cycles 11864 12623 11625 11957 12209 12590 11946 11998
block_production 2056793 2096540 2046412 2145501 2196709 2231476 2113473 2165745

deviation

no_fuel vanilla_fuel async_fuel_10000us async_fuel_1000us async_fuel_500us async_fuel_250us async_fuel_100us async_fuel_50us
wasmi_regex_redux 676 1116 872 5377 5519 15645 238 317
call_empty_function 0 0 0 0 0 0 0 0
dirty_1mb_of_memory 0 0 0 0 1 0 0 0
burn_cpu_cycles 25 30 32 13 18 50 2 2
block_production 4968 2164 2916 13325 3137 9899 1953 2381

And here are numbers for block execution on Moonbeam (exactly the same benchmark as the last time):

  • no fuel: 163ms
  • vanilla fuel: 219ms
  • async fuel: 165ms

Looks pretty good to me.

So (assuming we want to use this) I guess the next step would be to get the implementation to be less hacky and get it upstreamed?

@pepyakin
Copy link
Contributor Author

pepyakin commented Jul 4, 2022

I think we would need to perform more tests. Specifically:

  1. We need to see the impact on the weight benchmarks with the fuel metering enabled.
  2. I think we should enable parachains teams to test how this change impacts their workflows more closely. I guess we can ask the teams to perform those tests.
  3. More specifically, we need more data for EVM execution and wasmi execution on various contracts. ERC20 is very common, but I think we need workflows that are more CPU bound. Perhaps we need to take gas-heavy contracts that don't do much IO. One thing that comes to mind is the re-implementation of some crypto. Or I guess a typical workflow is verifying or creating a Merkle proof.

I think it's worth starting iterating on a better prototype. Right now, there is no flushing and checking the fuel counter before the libcalls. I don't think this will affect the performance, but it's better to be safe than sorry.

Besides that, there is some non-benchmark-related work. Namely, we should change wasmtime in a way that allows customizing the costs of instructions. Then, we should look into the security-related implications. Those things come to mind:

  1. Is it possible to overflow the counter between the interrupts?
  2. How do we benchmark the costs of different bytecodes?
  3. What is the worst case for how long does it take to execute 1 unit worth of fuel?

After doing all that, we may consider switching to fully metered execution.

@koute
Copy link
Contributor

koute commented Jul 4, 2022

I think we would need to perform more tests. Specifically:

  1. We need to see the impact on the weight benchmarks with the fuel metering enabled.

So just rerun all of our weight generation machinery with this enabled? Yeah, I think I can do that.

  1. I think we should enable parachains teams to test how this change impacts their workflows more closely. I guess we can ask the teams to perform those tests.

What would that entail exactly? I can prepare a substrate branch (or even maybe multiple branches for a few polkadot releases if necessary) so that the teams could relatively easily just plug this into their parachain and test away, but what exactly do we want them to test?

  1. More specifically, we need more data for EVM execution and wasmi execution on various contracts. ERC20 is very common, but I think we need workflows that are more CPU bound. Perhaps we need to take gas-heavy contracts that don't do much IO. One thing that comes to mind is the re-implementation of some crypto. Or I guess a typical workflow is verifying or creating a Merkle proof.

With the current setup that I have I can now easily run any of the benches from the smart-bench (and AFAIK it can also run wasmi-based benchmarks), so if we could get some good representative benchmarks that are more gas-heavy into there I could run them.

For EVM the only benches in there are erc20, erc721 and erc1155 which benchmark roughly the same (which is why I didn't include them all and just ran the erc20), and a few really simple toy ones.

I could maybe jig some new benchmark contracts up, but it isn't exactly my area of expertise so I'd be nice if someone could lend us a hand here.

I think it's worth starting iterating on a better prototype. Right now, there is no flushing and checking the fuel counter before the libcalls. I don't think this will affect the performance, but it's better to be safe than sorry.

Agreed.

Besides that, there is some non-benchmark-related work. Namely, we should change wasmtime in a way that allows customizing the costs of instructions. Then, we should look into the security-related implications. Those things come to mind:

  1. Is it possible to overflow the counter between the interrupts?

Good question.

The counter is 64-bit, right? In which case I don't think it should be possible to directly overflow it assuming each instruction consumes ~1 fuel. Consider the following program:

#![feature(bench_black_box)]

fn main() {
    for nth in 0..u64::MAX {
        std::hint::black_box(nth);
    }
}

This compiles down to the following assembly:

Dump of assembler code for function _ZN3tst4main17h302b5c3ca372dc0eE:
   0x000055bdb5143970 <+0>:	push   %rax
   0x000055bdb5143971 <+1>:	xor    %eax,%eax
   0x000055bdb5143973 <+3>:	mov    %rsp,%rcx
   0x000055bdb5143976 <+6>:	cs nopw 0x0(%rax,%rax,1)
   0x000055bdb5143980 <+16>:	mov    %rax,(%rsp)
=> 0x000055bdb5143984 <+20>:	add    $0x1,%rax
   0x000055bdb5143988 <+24>:	cmp    $0xffffffffffffffff,%rax
   0x000055bdb514398c <+28>:	jne    0x55bdb5143980 <_ZN3tst4main17h302b5c3ca372dc0eE+16>
   0x000055bdb514398e <+30>:	pop    %rax
   0x000055bdb514398f <+31>:	ret    

On my machine in roughly ~25 seconds this has counted up to 105100371379, so assuming the full range of a u64 it'd roughly take 139 years for this to overflow, and this is pretty much a best case scenario.

So unless the costs of instructions will be orders of magnitude higher or there's an indirect way to influence/overwrite the counter I don't think an overflow is realistic?

  1. How do we benchmark the costs of different bytecodes?

Yeah, this is going to be really tough, because the actual execution time will vary widely depending on which instructions cranelift's going to emit, on which exact microarchitecture it's going to run, and also on the neighboring code (cache pressure, register pressure, etc.).

I guess maybe we could take a page out of what we're doing right now with the weights, and rig up some benchmarks which would measure this on reference hardware, so that would simplify it a little bit. It's definitely not going to be perfect though. I don't have a good answer to this. I think we'd need to experiment here.

@pepyakin
Copy link
Contributor Author

pepyakin commented Jul 4, 2022

The counter is 64-bit, right? In which case I don't think it should be possible to directly overflow it assuming each instruction consumes ~1 fuel. Consider the following program:

Each instruction takes 1 fuel currently, but as I mentioned in the last message, we should override that behavior in wasmtime with a proper schedule. We would probably want to assign a value that is higher than 1 for the cheapest instruction. We may want to accommodate for quicker hardware and/or compilers in the future. Maybe setting the cheapest instruction to 10-100 would make sense.

Then, the counter is 64-bit. However, it is set up in such a way, that the amount of fuel is represented as a negative value. For each basic block, we increment the counter with the corresponding cost of that basic block. Should the counter become positive, that means the fuel ran out. That essentially makes the counter 32-bit.

                                    approx. value of the
                                    fuel counter at the
                                           start

                                             │
                                             │
                                             │
                                             ▼
──────────────────────────────────────────────────────
                            ▲
0                           │                    0xFFFFFFFF_FFFFFFFF
                            │                             or
                            │                             -1

                    0x7FFFFFFF_FFFFFFFF
                             or
                    9223372036854775807
                             or
                    i64::max_value()

That basically means the counter has |fuel amount| + 2^32 until the overflow. The interrupt has 2^32 units to catch the overflow: from 0 to 0x7FFFFFFF_FFFFFFFF. In case that does not happen, there will be another chance to do it again when the counter gets into the positive area.

If we do the synchronous check before calling into the host functions and libcalls, then the attacker will be only left with wasm code. Even things like memory.{copy, fill} etc should work given they check the amount of fuel before execution. As I see it, the attacker could try their luck with conjuring code that is both costly in terms of gas and actually really quick to execute. Not sure how likely is the success in this case.

We can also do a couple of things:

  1. I think the current construction of the fuel counter is needed to make sure the synchronous checks are fast. However, for async checks, we might be able to change the approach for fuel metering. E.g. treat the counter as an unsigned integer and then check it against the fuel limit. That would allow us to get those 139 years of buffer : )
  2. We can impose the upper bound on the sizes/costs of basic blocks.
  3. And of course, we can manipulate the interrupt frequency.

Those are thoughts off the top of my head. We need to dig deeper into this and make sure it is sound.

Yeah, this is going to be really tough, because the actual execution time will vary widely depending on which instructions cranelift's going to emit, on which exact microarchitecture it's going to run, and also on the neighboring code (cache pressure, register pressure, etc.).

Sure. We don't need to be absolutely precise though. We just need to make sure either:

  1. In the worst case, the code takes N seconds within the given limit. In this case, every PVF execution is guaranteed to finish within the backing stage on the target hardware. However, this will be pessimistic and on average case we could squeeze more performance.
  2. In most cases the code takes N seconds to finish and it does not take more than M seconds to finish, N<M. This is a more relaxed version. We ensure that DoS is not possible by capping it by M seconds. If the PVF takes more than N seconds to finish then it is not considered for inclusion. In that case, the validators could be griefed (likely by the parathreads) for not getting the backing points.

In either case, we have a big margin for error it seems. In case the variability is low and the worst case is not far away from the best case, there will be more computation available for the PVF authors.

I think this may look something like what @athei did for measuring contracts.

I could maybe jig some new benchmark contracts up, but it isn't exactly my area of expertise so I'd be nice if someone could lend us a hand here.

What would that entail exactly? I can prepare a substrate branch (or even maybe multiple branches for a few polkadot releases if necessary) so that the teams could relatively easily just plug this into their parachain and test away, but what exactly do we want them to test?

Hopefully, it's not too naive, to assume that we can politely ask the parachains teams to run the workflows they care about on an experimental version. This would give us additional information on whether we are regressing the performance too much. I am not sure what that would look like, but an experimental branch from a release should work.

@athei
Copy link
Member

athei commented Jul 5, 2022

I could maybe jig some new benchmark contracts up, but it isn't exactly my area of expertise so I'd be nice if someone could lend us a hand here.

I think for a start you could run the pallet-contracts weight benchmarks off your branch. You could even use the bot for that. For some computation heavy contracts you could use the ones from here: https://medium.com/pendulum-chain/the-bright-future-of-webassembly-smart-contracts-fd7e74301aea

Each instruction takes 1 fuel currently, but as I mentioned in the last message, we should override that behavior in wasmtime with a proper schedule. We would probably want to assign a value that is higher than 1 for the cheapest instruction. We may want to accommodate for quicker hardware and/or compilers in the future. Maybe setting the cheapest instruction to 10-100 would make sense.

What we need to do is benchmark every instruction and every host function. This is exactly what the pallet-contracts benchmarks do. If we go ahead with this plan we can use them to benchmark the runtime instead of contract execution. Of course we need to change all the host function benchmarks because right now they are against the contracts API. But the point here is that all the code to procedurally generate the benchmarking fixtures is already there.

@koute
Copy link
Contributor

koute commented Jul 7, 2022

Here are some numbers from our weight benchmarks. They were run locally on my 3070x. I'll post the results from the reference hardware later (they're still running, since I queued up more pallets there). The raw weights were all divided by 1000 to make the table easier to read.

Benchmark results
no-fuel vanilla-fuel % async-fuel %
frame_benchmarking/addition 340 346 102 312 92
frame_benchmarking/subtraction 331 339 102 312 94
frame_benchmarking/multiplication 328 336 102 309 94
frame_benchmarking/division 328 336 102 313 95
frame_benchmarking/hashing 38752449 37670703 97 38019124 98
frame_benchmarking/sr25519_verification/i 58405 58797 101 58692 100
frame_benchmarking/storage_read/i 3509 3595 102 3583 102
frame_benchmarking/storage_write/i 732 758 104 758 104
frame_system/remark_with_event/b 1 2 200 1 100
frame_system/set_heap_pages 9780 10030 103 9650 99
frame_system/set_storage/i 1014 1089 107 1010 100
frame_system/kill_storage/i 741 770 104 736 99
frame_system/kill_prefix/p 1195 1197 100 1202 101
pallet_bags_list/rebag_non_terminal 96440 98301 102 95910 99
pallet_bags_list/rebag_terminal 93820 96530 103 94300 101
pallet_bags_list/put_in_front_of 103520 106000 102 102660 99
pallet_balances/transfer 78830 83080 105 79960 101
pallet_balances/transfer_keep_alive 59210 62740 106 59260 100
pallet_balances/set_balance_creating 35780 37650 105 36390 102
pallet_balances/set_balance_killing 41660 44160 106 41960 101
pallet_balances/force_transfer 77890 82520 106 78700 101
pallet_balances/transfer_all 71850 75830 106 72130 100
pallet_balances/force_unreserve 33600 35160 105 33560 100
pallet_bounties/propose_bounty 50895 52833 104 50486 99
pallet_bounties/approve_bounty 17600 17550 100 16690 95
pallet_bounties/propose_curator 13480 13570 101 12700 94
pallet_bounties/unassign_curator 48010 48810 102 47580 99
pallet_bounties/accept_curator 42480 43700 103 41790 98
pallet_bounties/award_bounty 34660 35220 102 34160 99
pallet_bounties/claim_bounty 135751 141480 104 134850 99
pallet_bounties/close_bounty_proposed 57170 59070 103 56070 98
pallet_bounties/close_bounty_active 93940 96520 103 92650 99
pallet_bounties/extend_bounty_expiry 30570 31070 102 29800 97
pallet_bounties/spend_funds/b 62957 65482 104 63712 101
pallet_child_bounties/add_child_bounty 96126 99238 103 95257 99
pallet_child_bounties/propose_curator 23850 24630 103 23590 99
pallet_child_bounties/accept_curator 48000 50010 104 47700 99
pallet_child_bounties/unassign_curator 53920 55440 103 52930 98
pallet_child_bounties/award_child_bounty 37300 38620 104 36580 98
pallet_child_bounties/claim_child_bounty 136810 141491 103 133650 98
pallet_child_bounties/close_child_bounty_added 87040 89180 102 85530 98
pallet_child_bounties/close_child_bounty_active 106540 109930 103 103720 97
pallet_collective/set_members/m 10535 14644 139 10969 104
pallet_collective/set_members/p 16069 20180 126 16587 103
pallet_collective/execute 27415 28830 105 28605 104
pallet_collective/execute/b 2 2 100 1 50
pallet_collective/execute/m 26 42 162 26 100
pallet_collective/propose_execute 32618 33549 103 33012 101
pallet_collective/propose_execute/b 1 2 200 2 200
pallet_collective/propose_execute/m 41 66 161 43 105
pallet_collective/propose_proposed 41988 45725 109 43613 104
pallet_collective/propose_proposed/b 7 7 100 6 86
pallet_collective/propose_proposed/m 33 51 155 49 148
pallet_collective/propose_proposed/p 308 323 105 298 97
pallet_collective/vote 43016 43221 100 45114 105
pallet_collective/vote/m 71 117 165 56 79
pallet_collective/close_early_disapproved 49456 50283 102 52014 105
pallet_collective/close_early_disapproved/m 45 71 158 28 62
pallet_collective/close_early_disapproved/p 264 285 108 250 95
pallet_collective/close_early_approved 56079 59519 106 59591 106
pallet_collective/close_early_approved/b 6 8 133 5 83
pallet_collective/close_early_approved/m 75 83 111 58 77
pallet_collective/close_early_approved/p 305 322 106 289 95
pallet_collective/close_disapproved 53609 58465 109 54339 101
pallet_collective/close_disapproved/m 38 58 153 43 113
pallet_collective/close_disapproved/p 261 270 103 256 98
pallet_collective/close_approved 61225 62927 103 60666 99
pallet_collective/close_approved/b 6 8 133 6 100
pallet_collective/close_approved/m 59 93 158 80 136
pallet_collective/close_approved/p 309 324 105 296 96
pallet_collective/disapprove_proposal 31205 33602 108 32071 103
pallet_collective/disapprove_proposal/p 311 322 104 300 96
pallet_contracts/on_process_deletion_queue_batch 3020 3070 102 3020 100
pallet_contracts/on_initialize_per_trie_key 8517 592 7 5988 70
pallet_contracts/on_initialize_per_trie_key/k 1105 1151 104 1144 104
pallet_contracts/on_initialize_per_queue_item/q 3375 3474 103 3405 101
pallet_contracts/reinstrument 36493 52298 143 46226 127
pallet_contracts/reinstrument/c 49 72 147 55 112
pallet_contracts/call_with_code_per_byte 292202 701394 240 248617 85
pallet_contracts/call_with_code_per_byte/c 75 98 131 77 103
pallet_contracts/instantiate_with_code 334902 974475 291 387012 116
pallet_contracts/instantiate_with_code/c 140 195 139 154 110
pallet_contracts/instantiate_with_code/s 1 2 200 1 100
pallet_contracts/instantiate 264365 491969 186 268680 102
pallet_contracts/instantiate/s 2 2 100 2 100
pallet_contracts/call 187081 417220 223 197922 106
pallet_contracts/upload_code 82667 128305 155 101612 123
pallet_contracts/upload_code/c 49 72 147 56 114
pallet_contracts/remove_code 49560 52140 105 50270 101
pallet_contracts/set_code 42130 44120 105 43030 102
pallet_contracts/seal_caller 229763 655041 285 236647 103
pallet_contracts/seal_caller/r 91949 111120 121 95825 104
pallet_contracts/seal_is_contract 115655 537349 465 115747 100
pallet_contracts/seal_is_contract/r 506211 542924 107 514431 102
pallet_contracts/seal_code_hash 120438 555777 461 143082 119
pallet_contracts/seal_code_hash/r 635216 683060 108 649439 102
pallet_contracts/seal_own_code_hash 228854 654149 286 237089 104
pallet_contracts/seal_own_code_hash/r 105904 123473 117 109295 103
pallet_contracts/seal_caller_is_origin 222719 633810 285 227358 102
pallet_contracts/seal_caller_is_origin/r 17939 24510 137 19510 109
pallet_contracts/seal_address 226859 647617 285 242765 107
pallet_contracts/seal_address/r 91932 107553 117 93898 102
pallet_contracts/seal_gas_left 230635 642952 279 242779 105
pallet_contracts/seal_gas_left/r 91226 107133 117 94627 104
pallet_contracts/seal_balance 237629 644582 271 257203 108
pallet_contracts/seal_balance/r 276719 305339 110 280024 101
pallet_contracts/seal_value_transferred 229585 649983 283 237591 103
pallet_contracts/seal_value_transferred/r 91739 107876 118 94134 103
pallet_contracts/seal_minimum_balance 231163 647916 280 235890 102
pallet_contracts/seal_minimum_balance/r 91057 107803 118 94296 104
pallet_contracts/seal_block_number 228234 648433 284 236336 104
pallet_contracts/seal_block_number/r 91378 107208 117 94824 104
pallet_contracts/seal_now 229382 652443 284 234518 102
pallet_contracts/seal_now/r 91308 106778 117 94599 104
pallet_contracts/seal_weight_to_fee 232247 655893 282 243880 105
pallet_contracts/seal_weight_to_fee/r 204268 240683 118 211958 104
pallet_contracts/seal_gas 160506 386297 241 166697 104
pallet_contracts/seal_gas/r 41619 49107 118 42983 103
pallet_contracts/seal_input 233301 655745 281 238060 102
pallet_contracts/seal_input/r 79821 96262 121 82006 103
pallet_contracts/seal_input_per_kb 330295 166088 50 324326 98
pallet_contracts/seal_input_per_kb/n 7790 27433 352 10082 129
pallet_contracts/seal_return 221600 635343 287 225791 102
pallet_contracts/seal_return/r 3117 2380 76 1901 61
pallet_contracts/seal_return_per_kb 224136 637630 284 229577 102
pallet_contracts/seal_return_per_kb/n 159 505 318 185 116
pallet_contracts/seal_terminate 226419 721735 319 230908 102
pallet_contracts/seal_terminate/r 102706 39153 38 105493 103
pallet_contracts/seal_random 234201 670995 287 247280 106
pallet_contracts/seal_random/r 311246 344999 111 319152 103
pallet_contracts/seal_deposit_event 243146 707668 291 226208 93
pallet_contracts/seal_deposit_event/r 535083 577099 108 552992 103
pallet_contracts/seal_deposit_event_per_topic_and_kb 855419 1300028 152 836868 98
pallet_contracts/seal_deposit_event_per_topic_and_kb/t 424773 454457 107 445481 105
pallet_contracts/seal_deposit_event_per_topic_and_kb/n 47401 98799 208 55614 117
pallet_contracts/seal_debug_message 171185 404575 236 174155 102
pallet_contracts/seal_debug_message/r 51620 65426 127 54044 105
pallet_contracts/seal_set_storage 87003 503161 578 102275 118
pallet_contracts/seal_set_storage/r 488437 513519 105 496610 102
pallet_contracts/seal_set_storage_per_new_kb 721035 1164260 161 739723 103
pallet_contracts/seal_set_storage_per_new_kb/n 17484 45884 262 20457 117
pallet_contracts/seal_set_storage_per_old_kb 723011 1166944 161 737880 102
pallet_contracts/seal_set_storage_per_old_kb/n 6860 6633 97 6583 96
pallet_contracts/seal_clear_storage 130863 535828 409 154337 118
pallet_contracts/seal_clear_storage/r 465237 496722 107 481571 104
pallet_contracts/seal_clear_storage_per_kb 706467 1147398 162 726793 103
pallet_contracts/seal_clear_storage_per_kb/n 5922 6625 112 6119 103
pallet_contracts/seal_get_storage 131445 568061 432 142547 108
pallet_contracts/seal_get_storage/r 411227 441878 107 422567 103
pallet_contracts/seal_get_storage_per_kb 648182 1092849 169 657287 101
pallet_contracts/seal_get_storage_per_kb/n 39546 78653 199 42666 108
pallet_contracts/seal_contains_storage 135739 560911 413 144712 107
pallet_contracts/seal_contains_storage/r 368365 378849 103 374465 102
pallet_contracts/seal_contains_storage_per_kb 590349 1027051 174 595414 101
pallet_contracts/seal_contains_storage_per_kb/n 5531 5520 100 5798 105
pallet_contracts/seal_take_storage 138079 555741 402 128329 93
pallet_contracts/seal_take_storage/r 520999 543252 104 529258 102
pallet_contracts/seal_take_storage_per_kb 777855 1250838 161 783994 101
pallet_contracts/seal_take_storage_per_kb/n 39569 76247 193 44029 111
pallet_contracts/seal_transfer 246759 464266 188 660812 268
pallet_contracts/seal_transfer/r 3261669 3495699 107 3338026 102
pallet_contracts/seal_call/r 15932651 70849543 445 16291003 102
pallet_contracts/seal_delegate_call/r 15514240 60602663 391 16247693 105
pallet_contracts/seal_call_per_transfer_clone_kb 10683551 35827913 335 11318719 106
pallet_contracts/seal_call_per_transfer_clone_kb/c 8064 22239 276 10177 126
pallet_contracts/seal_instantiate/r 25533908 76311843 299 26578363 104
pallet_contracts/seal_instantiate_per_transfer_salt_kb 17353336 47836517 276 13451249 78
pallet_contracts/seal_instantiate_per_transfer_salt_kb/s 117198 147306 126 117557 100
pallet_contracts/seal_hash_sha2_256 226767 637514 281 226467 100
pallet_contracts/seal_hash_sha2_256/r 79508 92549 116 81625 103
pallet_contracts/seal_hash_sha2_256_per_kb/n 54389 92690 170 56659 104
pallet_contracts/seal_hash_keccak_256 227101 641536 282 233470 103
pallet_contracts/seal_hash_keccak_256/r 107254 122511 114 109000 102
pallet_contracts/seal_hash_keccak_256_per_kb/n 230902 269563 117 236413 102
pallet_contracts/seal_hash_blake2_256 228978 654510 286 235102 103
pallet_contracts/seal_hash_blake2_256/r 88374 104904 119 90666 103
pallet_contracts/seal_hash_blake2_256_per_kb/n 90896 124267 137 93128 102
pallet_contracts/seal_hash_blake2_128 231333 647556 280 238792 103
pallet_contracts/seal_hash_blake2_128/r 88595 103348 117 86309 97
pallet_contracts/seal_hash_blake2_128_per_kb/n 89909 125705 140 93375 104
pallet_contracts/seal_ecdsa_recover 296828 860082 290 160701 54
pallet_contracts/seal_ecdsa_recover/r 3601013 3619961 101 3638715 101
pallet_contracts/seal_ecdsa_to_eth_address 226009 681820 302 251587 111
pallet_contracts/seal_ecdsa_to_eth_address/r 2064099 2179251 106 2168002 105
pallet_contracts/seal_set_code_hash/r 1426909 1533330 107 1447172 101
pallet_contracts/instr_i64const 65038 253758 390 65524 101
pallet_contracts/instr_i64const/r 1622 1618 100 1630 100
pallet_contracts/instr_i64load 66459 257134 387 66480 100
pallet_contracts/instr_i64load/r 3471 3552 102 3499 101
pallet_contracts/instr_i64store 66443 258126 388 66428 100
pallet_contracts/instr_i64store/r 3443 3580 104 3481 101
pallet_contracts/instr_select 65328 254355 389 65095 100
pallet_contracts/instr_select/r 4208 4085 97 4228 100
pallet_contracts/instr_if 65070 256564 394 65381 100
pallet_contracts/instr_if/r 3971 3785 95 3989 100
pallet_contracts/instr_br 64531 253837 393 64591 100
pallet_contracts/instr_br/r 2519 2352 93 2510 100
pallet_contracts/instr_br_if 64823 255115 394 64492 99
pallet_contracts/instr_br_if/r 3385 3089 91 3431 101
pallet_contracts/instr_br_table 65142 249577 383 65384 100
pallet_contracts/instr_br_table/r 3380 3381 100 3530 104
pallet_contracts/instr_br_table_per_entry 70618 258127 366 71593 101
pallet_contracts/instr_call 65570 253881 387 66868 102
pallet_contracts/instr_call/r 8651 10787 125 9652 112
pallet_contracts/instr_call_indirect 74587 259287 348 75092 101
pallet_contracts/instr_call_indirect/r 10967 14078 128 12703 116
pallet_contracts/instr_call_indirect_per_param 86368 278582 323 89230 103
pallet_contracts/instr_call_indirect_per_param/p 980 967 99 998 102
pallet_contracts/instr_local_get 65618 255343 389 66143 101
pallet_contracts/instr_local_get/r 1522 1390 91 1581 104
pallet_contracts/instr_local_set 65422 256021 391 66079 101
pallet_contracts/instr_local_set/r 1624 1418 87 1661 102
pallet_contracts/instr_local_tee 65344 253135 387 66169 101
pallet_contracts/instr_local_tee/r 2353 2232 95 2393 102
pallet_contracts/instr_global_get 83209 272601 328 83044 100
pallet_contracts/instr_global_get/r 2021 2033 101 1958 97
pallet_contracts/instr_global_set 83439 272014 326 83720 100
pallet_contracts/instr_global_set/r 2197 2210 101 2185 99
pallet_contracts/instr_memory_current 64972 252787 389 65538 101
pallet_contracts/instr_memory_current/r 1703 1571 92 1708 100
pallet_contracts/instr_memory_grow 65963 253469 384 65561 99
pallet_contracts/instr_memory_grow/r 166532 483633 290 185033 111
pallet_contracts/instr_i64clz 65424 252330 386 65474 100
pallet_contracts/instr_i64clz/r 2430 2313 95 2461 101
pallet_contracts/instr_i64ctz 65093 251851 387 65432 101
pallet_contracts/instr_i64ctz/r 2442 2306 94 2462 101
pallet_contracts/instr_i64popcnt 65287 255125 391 65468 100
pallet_contracts/instr_i64popcnt/r 2435 2315 95 2464 101
pallet_contracts/instr_i64eqz 64969 254905 392 65540 101
pallet_contracts/instr_i64eqz/r 2448 2331 95 2464 101
pallet_contracts/instr_i64extendsi32 65157 254791 391 65294 100
pallet_contracts/instr_i64extendsi32/r 2449 2342 96 2447 100
pallet_contracts/instr_i64extendui32 65069 255357 392 65429 101
pallet_contracts/instr_i64extendui32/r 2450 2294 94 2439 100
pallet_contracts/instr_i32wrapi64 65060 253898 390 65483 101
pallet_contracts/instr_i32wrapi64/r 2435 2352 97 2452 101
pallet_contracts/instr_i64eq 65036 254384 391 65489 101
pallet_contracts/instr_i64eq/r 3340 3219 96 3389 101
pallet_contracts/instr_i64ne 65101 256244 394 65238 100
pallet_contracts/instr_i64ne/r 3358 3144 94 3403 101
pallet_contracts/instr_i64lts 65036 253919 390 65281 100
pallet_contracts/instr_i64lts/r 3330 3288 99 3424 103
pallet_contracts/instr_i64ltu 64822 257022 397 65752 101
pallet_contracts/instr_i64ltu/r 3344 3183 95 3400 102
pallet_contracts/instr_i64gts 64910 259688 400 67596 104
pallet_contracts/instr_i64gts/r 3347 3110 93 3216 96
pallet_contracts/instr_i64gtu 65296 255795 392 62684 96
pallet_contracts/instr_i64gtu/r 3334 3244 97 3412 102
pallet_contracts/instr_i64les 64399 255527 397 65527 102
pallet_contracts/instr_i64les/r 3380 3267 97 3377 100
pallet_contracts/instr_i64leu 65700 256767 391 65579 100
pallet_contracts/instr_i64leu/r 3317 3214 97 3387 102
pallet_contracts/instr_i64ges 65092 258538 397 65312 100
pallet_contracts/instr_i64ges/r 3337 3119 93 3391 102
pallet_contracts/instr_i64geu 65220 255639 392 65774 101
pallet_contracts/instr_i64geu/r 3340 3206 96 3361 101
pallet_contracts/instr_i64add 65106 256001 393 65410 100
pallet_contracts/instr_i64add/r 3332 3124 94 3370 101
pallet_contracts/instr_i64sub 63533 255610 402 65343 103
pallet_contracts/instr_i64sub/r 3416 3173 93 3379 99
pallet_contracts/instr_i64mul 65030 253756 390 65415 101
pallet_contracts/instr_i64mul/r 3368 3209 95 3378 100
pallet_contracts/instr_i64divs 64529 254142 394 65295 101
pallet_contracts/instr_i64divs/r 3357 3196 95 3368 100
pallet_contracts/instr_i64divu 64704 251899 389 65591 101
pallet_contracts/instr_i64divu/r 3438 3210 93 3424 100
pallet_contracts/instr_i64rems 65160 254436 390 65275 100
pallet_contracts/instr_i64rems/r 3344 3176 95 3399 102
pallet_contracts/instr_i64remu 65115 255617 393 65886 101
pallet_contracts/instr_i64remu/r 3424 3199 93 3450 101
pallet_contracts/instr_i64and 64762 254421 393 65404 101
pallet_contracts/instr_i64and/r 3375 3183 94 3384 100
pallet_contracts/instr_i64or 64685 257500 398 65267 101
pallet_contracts/instr_i64or/r 3395 3092 91 3414 101
pallet_contracts/instr_i64xor 64612 257352 398 67291 104
pallet_contracts/instr_i64xor/r 3385 3012 89 3364 99
pallet_contracts/instr_i64shl 65479 253599 387 65104 99
pallet_contracts/instr_i64shl/r 3362 3124 93 3403 101
pallet_contracts/instr_i64shrs 65086 252697 388 65098 100
pallet_contracts/instr_i64shrs/r 3375 3102 92 3387 100
pallet_contracts/instr_i64shru 64736 253263 391 65755 102
pallet_contracts/instr_i64shru/r 3371 3069 91 3378 100
pallet_contracts/instr_i64rotl 64822 252789 390 65384 101
pallet_contracts/instr_i64rotl/r 3364 3106 92 3388 101
pallet_contracts/instr_i64rotr 65176 254231 390 65825 101
pallet_contracts/instr_i64rotr/r 3335 3071 92 3377 101

Notes

Some of the benchmarks seem... broken? Few of the benchmarks sometimes randomly didn't emit the results at all, or randomly just returned a weight of 0. I'm not sure if I was doing something wrong maybe? Here are the issues that my post-processing script filtered out: (the "missing weights" entries are for those which sometimes don't get emitted at all, and "zero weights" are for those which sometimes just return a 0)

WARN: Missing weights for 'pallet_collective/set_members/n': no-fuel, vanilla-fuel
WARN: Missing weights for 'pallet_contracts/seal_call_per_transfer_clone_kb/t': vanilla-fuel
WARN: Missing weights for 'pallet_contracts/seal_instantiate_per_transfer_salt_kb/t': vanilla-fuel
WARN: Missing weights for 'pallet_contracts/instr_br_table_per_entry/e': no-fuel, vanilla-fuel
WARN: Missing weights for 'frame_benchmarking/hashing/i': no-fuel, async-fuel
WARN: Missing weights for 'frame_system/remark/b': no-fuel, async-fuel
WARN: Missing weights for 'pallet_bounties/propose_bounty/d': no-fuel, async-fuel
WARN: Zero weights for 'frame_benchmarking/sr25519_verification': vanilla-fuel, async-fuel (async-fuel=0, no-fuel=493000, vanilla-fuel=0)
WARN: Zero weights for 'frame_benchmarking/storage_write': no-fuel, vanilla-fuel (async-fuel=1715000, no-fuel=0, vanilla-fuel=0)
WARN: Zero weights for 'frame_system/remark_with_event': no-fuel, vanilla-fuel (async-fuel=6319000, no-fuel=0, vanilla-fuel=0)
WARN: Zero weights for 'frame_system/kill_storage': no-fuel, vanilla-fuel (async-fuel=855000, no-fuel=0, vanilla-fuel=0)
WARN: Zero weights for 'pallet_contracts/on_initialize_per_queue_item': vanilla-fuel (async-fuel=4228000, no-fuel=5460000, vanilla-fuel=0)
WARN: Zero weights for 'pallet_contracts/seal_delegate_call': no-fuel, async-fuel (async-fuel=0, no-fuel=0, vanilla-fuel=17131832000)
WARN: Zero weights for 'pallet_contracts/seal_hash_sha2_256_per_kb': vanilla-fuel (async-fuel=318971000, no-fuel=240825000, vanilla-fuel=0)
WARN: Zero weights for 'pallet_contracts/seal_hash_keccak_256_per_kb': vanilla-fuel (async-fuel=189424000, no-fuel=913044000, vanilla-fuel=0)
WARN: Zero weights for 'pallet_contracts/seal_hash_blake2_256_per_kb': vanilla-fuel (async-fuel=347517000, no-fuel=146142000, vanilla-fuel=0)
WARN: Zero weights for 'pallet_contracts/seal_hash_blake2_128_per_kb': vanilla-fuel (async-fuel=244870000, no-fuel=372549000, vanilla-fuel=0)
WARN: Zero weights for 'pallet_contracts/seal_set_code_hash': no-fuel, async-fuel (async-fuel=0, no-fuel=0, vanilla-fuel=21800000)

The benchmarks were run with the following command:

./substrate-vanilla benchmark pallet --chain=dev --steps=50 --repeat=20 --pallet=$PALLET_NAME --extrinsic="*" --execution=wasm --wasm-execution=compiled --heap-pages=4096 --output=$OUTPUT_CSV --template=weight-template.hbs

@koute
Copy link
Contributor

koute commented Jul 8, 2022

Okay, I got the numbers from the reference hardware. However, after analyzing how these are calculated I don't think these numbers are appropriate for comparison purposes. The reason for that is twofold:

  1. The weights are a product of running linear regression over the raw measurements. In some cases this produces very noisy results. The component weights which represent the slope of the regression (that is, the rows with e.g. "/i" etc. at the end) are still somewhat consistent, but the base weights which represent the intercept value are not. (It really depends on the exact benchmark.)
  2. There's a bug in the weight generation code where it doesn't handle negative intercept values; the intercept value is cast into an u128, so when it's negative (which can happen and is normal, since it tries to minimize the least squares error of the formula) it saturates those weights to zero, which is the reason for the weights sometimes having a high value and sometimes being zero, seemingly at random. (This may be a potential security issue; if we hit this bug we might get an extrinsic which actually costs something but weight-wise it will be treated as free if all of its components are also zero. I'll try to maybe whip up a PR to fix it.)

Fortunately the benchmarking command has a command line argument to get it to output the raw measurements it made as a .json; unfortunately silly me didn't enable it, so now I need to run all of the benchmarks again (and this takes a little under 24 hours for the set of pallets I have here).

So, here are the numbers anyway since I've already gathered the data, but please take them with a huge grain of salt. I'll post new numbers next week generated from the raw measurements.

Benchmark results
no-fuel vanilla-fuel % async-fuel %
frame_benchmarking/addition 389 419 108 310 80
frame_benchmarking/subtraction 393 411 105 303 77
frame_benchmarking/multiplication 381 386 101 297 78
frame_benchmarking/division 390 401 103 296 76
frame_benchmarking/hashing 33920692 33757864 100 36023973 106
frame_benchmarking/sr25519_verification 2510 2382 95 15597 621
frame_benchmarking/sr25519_verification/i 47982 48021 100 48573 101
frame_benchmarking/storage_read/i 3108 3163 102 3168 102
frame_benchmarking/storage_write/i 634 657 104 657 104
frame_system/remark 3554 5935 167 3913 110
frame_system/remark_with_event 239 2958 1238 20538 8593
frame_system/remark_with_event/b 1 2 200 1 100
frame_system/set_heap_pages 10395 10749 103 10371 100
frame_system/set_storage/i 924 980 106 933 101
frame_system/kill_storage/i 692 723 104 692 100
frame_system/kill_prefix 3816 2537 66 4384 115
frame_system/kill_prefix/p 1099 1095 100 1103 100
pallet_bags_list/rebag_non_terminal 90660 93587 103 93667 103
pallet_bags_list/rebag_terminal 88758 91450 103 90946 102
pallet_bags_list/put_in_front_of 97600 99473 102 98833 101
pallet_balances/transfer 75707 76660 101 75391 100
pallet_balances/transfer_keep_alive 57913 60590 105 59423 103
pallet_balances/set_balance_creating 37097 36529 98 37194 100
pallet_balances/set_balance_killing 42259 42409 100 41740 99
pallet_balances/force_transfer 74358 77861 105 75519 102
pallet_balances/transfer_all 67454 71796 106 69995 104
pallet_balances/force_unreserve 34609 35827 104 34632 100
pallet_bounties/propose_bounty 50326 51848 103 50235 100
pallet_bounties/propose_bounty/d 1 2 200 2 200
pallet_bounties/approve_bounty 19608 20338 104 19232 98
pallet_bounties/propose_curator 15063 16174 107 14767 98
pallet_bounties/unassign_curator 47936 50121 105 48043 100
pallet_bounties/accept_curator 42705 44031 103 42605 100
pallet_bounties/award_bounty 35226 36004 102 34944 99
pallet_bounties/claim_bounty 124899 128487 103 123727 99
pallet_bounties/close_bounty_proposed 56156 57926 103 56181 100
pallet_bounties/close_bounty_active 89225 91145 102 88430 99
pallet_bounties/extend_bounty_expiry 31108 32831 106 31127 100
pallet_bounties/spend_funds/b 56167 58147 104 56579 101
pallet_child_bounties/add_child_bounty 90152 93016 103 89087 99
pallet_child_bounties/propose_curator 25355 26023 103 25084 99
pallet_child_bounties/accept_curator 47531 49009 103 47190 99
pallet_child_bounties/unassign_curator 52837 54856 104 52892 100
pallet_child_bounties/award_child_bounty 37774 38471 102 36987 98
pallet_child_bounties/claim_child_bounty 124049 129454 104 122411 99
pallet_child_bounties/close_child_bounty_added 83013 85318 103 81632 98
pallet_child_bounties/close_child_bounty_active 100643 103069 102 99274 99
pallet_collective/set_members/m 10652 15479 145 11447 107
pallet_collective/set_members/p 15812 20312 128 16803 106
pallet_collective/execute 29453 29648 101 29577 100
pallet_collective/execute/b 2 2 100 2 100
pallet_collective/execute/m 32 49 153 37 116
pallet_collective/propose_execute 32635 34658 106 34038 104
pallet_collective/propose_execute/b 3 2 67 2 67
pallet_collective/propose_execute/m 63 80 127 65 103
pallet_collective/propose_proposed 45706 44132 97 44849 98
pallet_collective/propose_proposed/b 6 9 150 8 133
pallet_collective/propose_proposed/m 47 62 132 45 96
pallet_collective/propose_proposed/p 289 320 111 304 105
pallet_collective/vote 45696 46598 102 47609 104
pallet_collective/vote/m 100 124 124 76 76
pallet_collective/close_early_disapproved 51312 52320 102 51406 100
pallet_collective/close_early_disapproved/m 59 72 122 60 102
pallet_collective/close_early_disapproved/p 245 273 111 261 107
pallet_collective/close_early_approved 56735 58885 104 62086 109
pallet_collective/close_early_approved/b 7 8 114 5 71
pallet_collective/close_early_approved/m 90 103 114 70 78
pallet_collective/close_early_approved/p 289 310 107 290 100
pallet_collective/close_disapproved 54451 54709 100 55628 102
pallet_collective/close_disapproved/m 71 96 135 66 93
pallet_collective/close_disapproved/p 248 273 110 252 102
pallet_collective/close_approved 63183 65809 104 64889 103
pallet_collective/close_approved/b 6 6 100 6 100
pallet_collective/close_approved/m 82 94 115 78 95
pallet_collective/close_approved/p 284 306 108 283 100
pallet_collective/disapprove_proposal 34357 34366 100 34319 100
pallet_collective/disapprove_proposal/p 284 315 111 301 106
pallet_contracts/on_process_deletion_queue_batch 3076 3030 99 3078 100
pallet_contracts/on_initialize_per_trie_key 18706 18121 97 16985 91
pallet_contracts/on_initialize_per_trie_key/k 968 980 101 981 101
pallet_contracts/on_initialize_per_queue_item 14514 10309 71 5341 37
pallet_contracts/on_initialize_per_queue_item/q 2785 2902 104 2920 105
pallet_contracts/reinstrument 40639 52637 130 42866 105
pallet_contracts/reinstrument/c 51 69 135 54 106
pallet_contracts/call_with_code_per_byte 367983 605396 165 397458 108
pallet_contracts/call_with_code_per_byte/c 65 79 122 67 103
pallet_contracts/instantiate_with_code 455564 732056 161 397168 87
pallet_contracts/instantiate_with_code/c 136 173 127 141 104
pallet_contracts/instantiate_with_code/s 2 2 100 2 100
pallet_contracts/instantiate 320161 463027 145 338711 106
pallet_contracts/instantiate/s 2 2 100 2 100
pallet_contracts/call 247266 389092 157 249344 101
pallet_contracts/upload_code 91894 101036 110 83061 90
pallet_contracts/upload_code/c 52 71 137 56 108
pallet_contracts/remove_code 50937 52531 103 50831 100
pallet_contracts/set_code 43305 45349 105 43552 101
pallet_contracts/seal_caller 344752 611778 177 360688 105
pallet_contracts/seal_caller/r 82936 93150 112 84192 102
pallet_contracts/seal_is_contract 224412 469161 209 210432 94
pallet_contracts/seal_is_contract/r 462962 487824 105 479094 103
pallet_contracts/seal_code_hash 243783 498546 205 258719 106
pallet_contracts/seal_code_hash/r 575103 620952 108 591206 103
pallet_contracts/seal_own_code_hash 352161 613829 174 372782 106
pallet_contracts/seal_own_code_hash/r 94631 105660 112 97203 103
pallet_contracts/seal_caller_is_origin 342613 606695 177 343954 100
pallet_contracts/seal_caller_is_origin/r 16301 21509 132 18850 116
pallet_contracts/seal_address 353058 608898 172 355090 101
pallet_contracts/seal_address/r 81593 93403 114 86508 106
pallet_contracts/seal_gas_left 350811 617547 176 368545 105
pallet_contracts/seal_gas_left/r 81631 91967 113 84864 104
pallet_contracts/seal_balance 359448 618453 172 376947 105
pallet_contracts/seal_balance/r 241864 261540 108 248705 103
pallet_contracts/seal_value_transferred 356882 614641 172 374865 105
pallet_contracts/seal_value_transferred/r 81393 91795 113 83386 102
pallet_contracts/seal_minimum_balance 345726 614998 178 375003 108
pallet_contracts/seal_minimum_balance/r 82396 91511 111 82805 100
pallet_contracts/seal_block_number 350904 611536 174 353973 101
pallet_contracts/seal_block_number/r 81438 91997 113 84211 103
pallet_contracts/seal_now 347540 613155 176 363989 105
pallet_contracts/seal_now/r 82318 91738 111 83021 101
pallet_contracts/seal_weight_to_fee 360123 619966 172 333953 93
pallet_contracts/seal_weight_to_fee/r 182573 209501 115 193463 106
pallet_contracts/seal_gas 223902 365507 163 230041 103
pallet_contracts/seal_gas/r 37598 42239 112 39186 104
pallet_contracts/seal_input 347221 616033 177 374849 108
pallet_contracts/seal_input/r 72398 81639 113 72926 101
pallet_contracts/seal_input_per_kb 449809 721315 160 482477 107
pallet_contracts/seal_input_per_kb/n 9619 19038 198 9739 101
pallet_contracts/seal_return 339821 599505 176 345213 102
pallet_contracts/seal_return/r 2607 2152 83 2654 102
pallet_contracts/seal_return_per_kb 343454 602869 176 354351 103
pallet_contracts/seal_return_per_kb/n 230 460 200 225 98
pallet_contracts/seal_terminate 344681 607302 176 346788 101
pallet_contracts/seal_terminate/r 100167 105611 105 101792 102
pallet_contracts/seal_random 351588 627109 178 360905 103
pallet_contracts/seal_random/r 268328 293376 109 279656 104
pallet_contracts/seal_deposit_event 369558 628453 170 380568 103
pallet_contracts/seal_deposit_event/r 457576 495316 108 473002 103
pallet_contracts/seal_deposit_event_per_topic_and_kb 867505 1160651 134 904787 104
pallet_contracts/seal_deposit_event_per_topic_and_kb/t 403818 413922 103 394641 98
pallet_contracts/seal_deposit_event_per_topic_and_kb/n 74773 115726 155 77820 104
pallet_contracts/seal_debug_message 234303 383935 164 237475 101
pallet_contracts/seal_debug_message/r 48647 57682 119 50476 104
pallet_contracts/seal_set_storage 206817 470072 227 195883 95
pallet_contracts/seal_set_storage/r 471721 485793 103 478252 101
pallet_contracts/seal_set_storage_per_new_kb 831427 1110262 134 855609 103
pallet_contracts/seal_set_storage_per_new_kb/n 26449 44826 169 26871 102
pallet_contracts/seal_set_storage_per_old_kb 832520 1110500 133 858487 103
pallet_contracts/seal_set_storage_per_old_kb/n 10121 9621 95 10209 101
pallet_contracts/seal_clear_storage 254314 513270 202 249093 98
pallet_contracts/seal_clear_storage/r 450185 460864 102 452895 101
pallet_contracts/seal_clear_storage_per_kb 824641 1097262 133 838977 102
pallet_contracts/seal_clear_storage_per_kb/n 8775 9033 103 9597 109
pallet_contracts/seal_get_storage 255944 530242 207 270092 106
pallet_contracts/seal_get_storage/r 380724 409215 107 391016 103
pallet_contracts/seal_get_storage_per_kb 745726 1036715 139 782280 105
pallet_contracts/seal_get_storage_per_kb/n 57846 89312 154 61208 106
pallet_contracts/seal_contains_storage 260208 515673 198 273638 105
pallet_contracts/seal_contains_storage/r 340124 357320 105 347892 102
pallet_contracts/seal_contains_storage_per_kb 687867 975040 142 719173 105
pallet_contracts/seal_contains_storage_per_kb/n 8350 8108 97 8191 98
pallet_contracts/seal_take_storage 240873 509387 211 278456 116
pallet_contracts/seal_take_storage/r 493774 520443 105 503315 102
pallet_contracts/seal_take_storage_per_kb 881876 1170509 133 917694 104
pallet_contracts/seal_take_storage_per_kb/n 58135 89821 155 60366 104
pallet_contracts/seal_transfer 317046 535835 169 230364 73
pallet_contracts/seal_transfer/r 2883437 3072634 107 2942987 102
pallet_contracts/seal_call 9473 327165 3454 1542319 16281
pallet_contracts/seal_call/r 25136723 45625307 182 25750941 102
pallet_contracts/seal_delegate_call/r 24957456 45593001 183 25822086 103
pallet_contracts/seal_call_per_transfer_clone_kb 15558008 26781880 172 15737230 101
pallet_contracts/seal_call_per_transfer_clone_kb/t 2494829 2573240 103 2592355 104
pallet_contracts/seal_call_per_transfer_clone_kb/c 9697 19187 198 10527 109
pallet_contracts/seal_instantiate/r 35043336 55895215 160 36279475 104
pallet_contracts/seal_instantiate_per_transfer_salt_kb 21423835 32969897 154 22902798 107
pallet_contracts/seal_instantiate_per_transfer_salt_kb/t 1416449 1561541 110 336830 24
pallet_contracts/seal_instantiate_per_transfer_salt_kb/s 126665 148710 117 130573 103
pallet_contracts/seal_hash_sha2_256 346094 603595 174 355371 103
pallet_contracts/seal_hash_sha2_256/r 86661 98069 113 92216 106
pallet_contracts/seal_hash_sha2_256_per_kb/n 320739 338497 106 330254 103
pallet_contracts/seal_hash_keccak_256 347171 608495 175 361402 104
pallet_contracts/seal_hash_keccak_256/r 101974 111086 109 104159 102
pallet_contracts/seal_hash_keccak_256_per_kb 500616 699393 140 69709 14
pallet_contracts/seal_hash_keccak_256_per_kb/n 257447 275820 107 264703 103
pallet_contracts/seal_hash_blake2_256 349752 603359 173 361077 103
pallet_contracts/seal_hash_blake2_256/r 79273 88805 112 83672 106
pallet_contracts/seal_hash_blake2_256_per_kb 446783 815502 183 285209 64
pallet_contracts/seal_hash_blake2_256_per_kb/n 98038 116070 118 100590 103
pallet_contracts/seal_hash_blake2_128 346112 605251 175 361748 105
pallet_contracts/seal_hash_blake2_128/r 79608 88842 112 80369 101
pallet_contracts/seal_hash_blake2_128_per_kb 467522 765865 164 906398 194
pallet_contracts/seal_hash_blake2_128_per_kb/n 97972 116077 118 98949 101
pallet_contracts/seal_ecdsa_recover 403196 654270 162 330120 82
pallet_contracts/seal_ecdsa_recover/r 3073550 3093620 101 3171031 103
pallet_contracts/seal_ecdsa_to_eth_address 359056 595056 166 343605 96
pallet_contracts/seal_ecdsa_to_eth_address/r 2230843 2291505 103 2319410 104
pallet_contracts/seal_set_code_hash/r 1306174 1380128 106 1356975 104
pallet_contracts/instr_i64const 120212 235835 196 121080 101
pallet_contracts/instr_i64const/r 1559 1470 94 1590 102
pallet_contracts/instr_i64load 120989 236532 195 120770 100
pallet_contracts/instr_i64load/r 3324 3424 103 3673 110
pallet_contracts/instr_i64store 120878 236558 196 121483 101
pallet_contracts/instr_i64store/r 3642 3615 99 3731 102
pallet_contracts/instr_select 120110 235671 196 119347 99
pallet_contracts/instr_select/r 4068 3784 93 4142 102
pallet_contracts/instr_if 120240 235897 196 121016 101
pallet_contracts/instr_if/r 3979 3642 92 4014 101
pallet_contracts/instr_br 120202 235757 196 120406 100
pallet_contracts/instr_br/r 2440 2295 94 2521 103
pallet_contracts/instr_br_if 122170 236103 193 119658 98
pallet_contracts/instr_br_if/r 3240 3048 94 3424 106
pallet_contracts/instr_br_table 118966 235263 198 120606 101
pallet_contracts/instr_br_table/r 3547 3269 92 3548 100
pallet_contracts/instr_br_table_per_entry 125178 240416 192 125441 100
pallet_contracts/instr_br_table_per_entry/e 3 4 133 5 167
pallet_contracts/instr_call 120281 235775 196 118686 99
pallet_contracts/instr_call/r 8714 9539 109 8721 100
pallet_contracts/instr_call_indirect 126863 245194 193 129244 102
pallet_contracts/instr_call_indirect/r 11183 13152 118 11796 105
pallet_contracts/instr_call_indirect_per_param 138916 258940 186 139357 100
pallet_contracts/instr_call_indirect_per_param/p 942 916 97 969 103
pallet_contracts/instr_local_get 120770 236860 196 122106 101
pallet_contracts/instr_local_get/r 1468 1385 94 1482 101
pallet_contracts/instr_local_set 120791 236791 196 120280 100
pallet_contracts/instr_local_set/r 1573 1455 92 1640 104
pallet_contracts/instr_local_tee 120767 237031 196 122531 101
pallet_contracts/instr_local_tee/r 2274 2131 94 2290 101
pallet_contracts/instr_global_get 135242 251532 186 135731 100
pallet_contracts/instr_global_get/r 2048 2162 106 2144 105
pallet_contracts/instr_global_set 135186 250993 186 135547 100
pallet_contracts/instr_global_set/r 2245 2379 106 2352 105
pallet_contracts/instr_memory_current 120404 236454 196 121324 101
pallet_contracts/instr_memory_current/r 1605 1486 93 1619 101
pallet_contracts/instr_memory_grow 119992 235462 196 120020 100
pallet_contracts/instr_memory_grow/r 233490 459765 197 240427 103
pallet_contracts/instr_i64clz 120095 235617 196 120343 100
pallet_contracts/instr_i64clz/r 2355 2204 94 2385 101
pallet_contracts/instr_i64ctz 120060 235909 196 120812 101
pallet_contracts/instr_i64ctz/r 2354 2196 93 2391 102
pallet_contracts/instr_i64popcnt 120069 235685 196 121073 101
pallet_contracts/instr_i64popcnt/r 2356 2201 93 2422 103
pallet_contracts/instr_i64eqz 120272 235822 196 118833 99
pallet_contracts/instr_i64eqz/r 2372 2197 93 2492 105
pallet_contracts/instr_i64extendsi32 120744 236134 196 121764 101
pallet_contracts/instr_i64extendsi32/r 2345 2172 93 2323 99
pallet_contracts/instr_i64extendui32 120248 235440 196 120736 100
pallet_contracts/instr_i64extendui32/r 2350 2193 93 2341 100
pallet_contracts/instr_i32wrapi64 120033 235916 197 121052 101
pallet_contracts/instr_i32wrapi64/r 2368 2172 92 2343 99
pallet_contracts/instr_i64eq 120063 235603 196 119515 100
pallet_contracts/instr_i64eq/r 3228 2995 93 3343 104
pallet_contracts/instr_i64ne 120062 236013 197 120964 101
pallet_contracts/instr_i64ne/r 3254 2984 92 3294 101
pallet_contracts/instr_i64lts 120149 236434 197 121026 101
pallet_contracts/instr_i64lts/r 3224 2971 92 3320 103
pallet_contracts/instr_i64ltu 120325 235751 196 119097 99
pallet_contracts/instr_i64ltu/r 3229 2989 93 3343 104
pallet_contracts/instr_i64gts 120113 236143 197 120090 100
pallet_contracts/instr_i64gts/r 3237 2978 92 3338 103
pallet_contracts/instr_i64gtu 120132 235676 196 120422 100
pallet_contracts/instr_i64gtu/r 3238 2991 92 3328 103
pallet_contracts/instr_i64les 120136 235625 196 119687 100
pallet_contracts/instr_i64les/r 3232 2995 93 3353 104
pallet_contracts/instr_i64leu 120185 236175 197 119662 100
pallet_contracts/instr_i64leu/r 3239 2977 92 3322 103
pallet_contracts/instr_i64ges 120092 235399 196 121170 101
pallet_contracts/instr_i64ges/r 3225 3021 94 3209 100
pallet_contracts/instr_i64geu 120692 235782 195 119301 99
pallet_contracts/instr_i64geu/r 3210 2991 93 3327 104
pallet_contracts/instr_i64add 120083 236186 197 120714 101
pallet_contracts/instr_i64add/r 3234 2983 92 3230 100
pallet_contracts/instr_i64sub 120108 235636 196 121410 101
pallet_contracts/instr_i64sub/r 3240 2995 92 3235 100
pallet_contracts/instr_i64mul 120341 236009 196 118855 99
pallet_contracts/instr_i64mul/r 3225 2998 93 3341 104
pallet_contracts/instr_i64divs 119937 235484 196 119498 100
pallet_contracts/instr_i64divs/r 3908 3660 94 4117 105
pallet_contracts/instr_i64divu 119948 235578 196 121264 101
pallet_contracts/instr_i64divu/r 3768 3492 93 3843 102
pallet_contracts/instr_i64rems 119923 235797 197 119440 100
pallet_contracts/instr_i64rems/r 3947 3646 92 4224 107
pallet_contracts/instr_i64remu 120080 236147 197 121108 101
pallet_contracts/instr_i64remu/r 3768 3464 92 3833 102
pallet_contracts/instr_i64and 120083 235676 196 119006 99
pallet_contracts/instr_i64and/r 3232 2975 92 3363 104
pallet_contracts/instr_i64or 120168 235901 196 119298 99
pallet_contracts/instr_i64or/r 3228 2961 92 3360 104
pallet_contracts/instr_i64xor 120218 236533 197 119977 100
pallet_contracts/instr_i64xor/r 3230 2952 91 3304 102
pallet_contracts/instr_i64shl 120276 236300 196 120656 100
pallet_contracts/instr_i64shl/r 3228 2950 91 3240 100
pallet_contracts/instr_i64shrs 120433 235658 196 121687 101
pallet_contracts/instr_i64shrs/r 3207 2970 93 3197 100
pallet_contracts/instr_i64shru 120298 235650 196 121440 101
pallet_contracts/instr_i64shru/r 3225 2970 92 3211 100
pallet_contracts/instr_i64rotl 120233 235672 196 120815 100
pallet_contracts/instr_i64rotl/r 3211 2974 93 3214 100
pallet_contracts/instr_i64rotr 120177 235886 196 119855 100
pallet_contracts/instr_i64rotr/r 3235 2983 92 3312 102
pallet_democracy/propose 72753 73585 101 72335 99
pallet_democracy/second 52508 53219 101 51906 99
pallet_democracy/second/s 152 177 116 152 100
pallet_democracy/vote_new 64946 67215 103 64824 100
pallet_democracy/vote_new/r 159 181 114 164 103
pallet_democracy/vote_existing 64823 66932 103 64330 99
pallet_democracy/vote_existing/r 153 177 116 172 112
pallet_democracy/emergency_cancel 32498 33697 104 32177 99
pallet_democracy/blacklist 94810 97675 103 94467 100
pallet_democracy/blacklist/p 343 362 106 346 101
pallet_democracy/external_propose 18821 19275 102 18530 98
pallet_democracy/external_propose/v 35 45 129 34 97
pallet_democracy/external_propose_majority 7501 7678 102 7484 100
pallet_democracy/external_propose_default 7524 7988 106 7535 100
pallet_democracy/fast_track 34374 35173 102 34200 99
pallet_democracy/veto_external 34926 36054 103 34761 100
pallet_democracy/veto_external/v 54 72 133 55 102
pallet_democracy/cancel_proposal 76738 78890 103 76938 100
pallet_democracy/cancel_proposal/p 324 345 106 311 96
pallet_democracy/cancel_referendum 23339 24131 103 22945 98
pallet_democracy/cancel_queued 37754 39789 105 37724 100
pallet_democracy/cancel_queued/r 903 1200 133 884 98
pallet_democracy/on_initialize_base 6702 6487 97 2011 30
pallet_democracy/on_initialize_base/r 4636 4818 104 4916 106
pallet_democracy/on_initialize_base_with_launch_period 13345 15007 112 11797 88
pallet_democracy/on_initialize_base_with_launch_period/r 4671 4793 103 4849 104
pallet_democracy/delegate 64086 65715 103 62291 97
pallet_democracy/delegate/r 6614 6829 103 6774 102
pallet_democracy/undelegate 33699 35621 106 32902 98
pallet_democracy/undelegate/r 6678 6820 102 6720 101
pallet_democracy/clear_public_proposals 8960 9332 104 8823 98
pallet_democracy/note_preimage 49659 50712 102 49046 99
pallet_democracy/note_preimage/b 2 3 150 2 100
pallet_democracy/note_imminent_preimage 35013 35917 103 34303 98
pallet_democracy/note_imminent_preimage/b 2 2 100 2 100
pallet_democracy/reap_preimage 46372 47268 102 46134 99
pallet_democracy/reap_preimage/b 1 2 200 1 100
pallet_democracy/unlock_remove 43485 44871 103 43269 100
pallet_democracy/unlock_remove/r 62 64 103 76 123
pallet_democracy/unlock_set 41373 43437 105 41901 101
pallet_democracy/unlock_set/r 166 167 101 151 91
pallet_democracy/remove_vote 25987 26835 103 26232 101
pallet_democracy/remove_vote/r 131 171 131 145 111
pallet_democracy/remove_other_vote 25846 27122 105 26098 101
pallet_democracy/remove_other_vote/r 129 152 118 142 110
pallet_election_provider_multi_phase/on_initialize_nothing 21939 22760 104 23812 109
pallet_election_provider_multi_phase/on_initialize_open_signed 24361 25391 104 26042 107
pallet_election_provider_multi_phase/on_initialize_open_unsigned 24168 25421 105 25116 104
pallet_election_provider_multi_phase/finalize_signed_phase_accept_solution 51347 54345 106 51960 101
pallet_election_provider_multi_phase/finalize_signed_phase_reject_solution 39703 38865 98 38349 97
pallet_election_provider_multi_phase/create_snapshot_internal/v 266 270 102 312 117
pallet_election_provider_multi_phase/create_snapshot_internal/t 115 110 96 123 107
pallet_election_provider_multi_phase/elect_queued 114026 136799 120 180658 158
pallet_election_provider_multi_phase/elect_queued/a 758 915 121 711 94
pallet_election_provider_multi_phase/elect_queued/d 234 285 122 218 93
pallet_election_provider_multi_phase/submit 79145 85361 108 81681 103
pallet_election_provider_multi_phase/submit_unsigned/v 1029 1404 136 1143 111
pallet_election_provider_multi_phase/submit_unsigned/t 88 222 252 168 191
pallet_election_provider_multi_phase/submit_unsigned/a 8135 11497 141 8779 108
pallet_election_provider_multi_phase/submit_unsigned/d 1885 2509 133 2146 114
pallet_election_provider_multi_phase/feasibility_check/v 993 1304 131 1077 108
pallet_election_provider_multi_phase/feasibility_check/t 85 17 20 30 35
pallet_election_provider_multi_phase/feasibility_check/a 6889 9606 139 7286 106
pallet_election_provider_multi_phase/feasibility_check/d 1770 2373 134 1834 104
pallet_elections_phragmen/vote_equal 47673 49490 104 47793 100
pallet_elections_phragmen/vote_equal/v 255 307 120 264 104
pallet_elections_phragmen/vote_more 70886 74054 104 70896 100
pallet_elections_phragmen/vote_more/v 282 283 100 298 106
pallet_elections_phragmen/vote_less 71142 73481 103 71001 100
pallet_elections_phragmen/vote_less/v 233 308 132 290 124
pallet_elections_phragmen/remove_voter 64680 68253 106 65623 101
pallet_elections_phragmen/submit_candidacy 62379 65219 105 61907 99
pallet_elections_phragmen/submit_candidacy/c 105 138 131 141 134
pallet_elections_phragmen/renounce_candidacy_candidate 55380 57400 104 57137 103
pallet_elections_phragmen/renounce_candidacy_candidate/c 92 111 121 96 104
pallet_elections_phragmen/renounce_candidacy_members 73607 75943 103 74396 101
pallet_elections_phragmen/renounce_candidacy_runners_up 55832 56771 102 56058 100
pallet_elections_phragmen/remove_member_without_replacement 2000000000 2000000000 100 2000000000 100
pallet_elections_phragmen/remove_member_with_replacement 85823 89013 104 87282 102
pallet_elections_phragmen/remove_member_wrong_refund 19279 19362 100 20027 104
pallet_elections_phragmen/clean_defunct_voters/v 94076 98747 105 96455 103
pallet_elections_phragmen/clean_defunct_voters/d 563 702 125 1352 240
pallet_elections_phragmen/election_phragmen/c 77794 92781 119 83471 107
pallet_elections_phragmen/election_phragmen/v 81050 112330 139 89538 110
pallet_elections_phragmen/election_phragmen/e 4920 7101 144 5536 113
pallet_gilt/place_bid 64762 72000 111 65832 102
pallet_gilt/place_bid/l 69 102 148 72 104
pallet_gilt/place_bid_max 134812 164528 122 138836 103
pallet_gilt/retract_bid 65387 73101 112 67457 103
pallet_gilt/retract_bid/l 58 85 147 59 102
pallet_gilt/set_target 9802 10290 105 9402 96
pallet_gilt/thaw 78996 86227 109 79443 101
pallet_gilt/pursue_target_noop 2963 3042 103 2869 97
pallet_gilt/pursue_target_per_item 55703 56411 101 52594 94
pallet_gilt/pursue_target_per_item/b 8087 8727 108 8173 101
pallet_gilt/pursue_target_per_queue 17787 26680 150 11990 67
pallet_gilt/pursue_target_per_queue/q 14403 15206 106 14812 103
pallet_identity/add_registrar 28509 29010 102 27736 97
pallet_identity/add_registrar/r 260 306 118 321 123
pallet_identity/set_identity 57613 60534 105 57337 100
pallet_identity/set_identity/r 205 238 116 248 121
pallet_identity/set_identity/x 765 931 122 790 103
pallet_identity/set_subs_new 50846 52304 103 46742 92
pallet_identity/set_subs_new/s 5637 5927 105 5927 105
pallet_identity/set_subs_old 48525 50200 103 48615 100
pallet_identity/set_subs_old/p 1918 2013 105 1983 103
pallet_identity/clear_identity 59224 62782 106 65110 110
pallet_identity/clear_identity/s 1926 2022 105 1965 102
pallet_identity/clear_identity/x 408 495 121 414 101
pallet_identity/request_judgement 59325 61886 104 57700 97
pallet_identity/request_judgement/r 255 329 129 363 142
pallet_identity/request_judgement/x 804 1000 124 836 104
pallet_identity/cancel_request 56117 58228 104 57502 102
pallet_identity/cancel_request/r 143 201 141 137 96
pallet_identity/cancel_request/x 804 994 124 818 102
pallet_identity/set_fee 14075 14966 106 14242 101
pallet_identity/set_fee/r 222 271 122 254 114
pallet_identity/set_account_id 14239 14979 105 14491 102
pallet_identity/set_account_id/r 221 269 122 247 112
pallet_identity/set_fields 14128 15081 107 14453 102
pallet_identity/set_fields/r 222 264 119 233 105
pallet_identity/provide_judgement 41025 43267 105 41964 102
pallet_identity/provide_judgement/r 231 256 111 228 99
pallet_identity/provide_judgement/x 796 999 126 815 102
pallet_identity/kill_identity 78025 82996 106 79807 102
pallet_identity/kill_identity/r 210 157 75 187 89
pallet_identity/kill_identity/s 1938 2027 105 1992 103
pallet_identity/add_sub 61473 64026 104 61963 101
pallet_identity/add_sub/s 131 147 112 132 101
pallet_identity/rename_sub 22993 24217 105 23636 103
pallet_identity/rename_sub/s 56 54 96 61 109
pallet_identity/remove_sub 62204 64806 104 62774 101
pallet_identity/remove_sub/s 126 142 113 129 102
pallet_identity/quit_sub 43216 45038 104 43993 102
pallet_identity/quit_sub/s 122 138 113 118 97
pallet_im_online/validate_unsigned_and_then_heartbeat 101016 102971 102 103483 102
pallet_im_online/validate_unsigned_and_then_heartbeat/k 49 67 137 51 104
pallet_im_online/validate_unsigned_and_then_heartbeat/e 566 639 113 569 101
pallet_indices/claim 45080 46293 103 45012 100
pallet_indices/transfer 54644 55130 101 54301 99
pallet_indices/free 45328 46745 103 47169 104
pallet_indices/force_transfer 46623 48788 105 47278 101
pallet_indices/freeze 52838 52771 100 52193 99
pallet_membership/add_member 26770 28024 105 26654 100
pallet_membership/add_member/m 60 84 140 66 110
pallet_membership/remove_member 30716 31887 104 30978 101
pallet_membership/remove_member/m 60 80 133 61 102
pallet_membership/swap_member 30958 32392 105 31202 101
pallet_membership/swap_member/m 74 99 134 75 101
pallet_membership/reset_member 31943 33099 104 32398 101
pallet_membership/reset_member/m 179 260 145 180 101
pallet_membership/change_key 32268 33819 105 32403 100
pallet_membership/change_key/m 72 95 132 73 101
pallet_membership/set_prime 8410 9074 108 8578 102
pallet_membership/set_prime/m 30 40 133 30 100
pallet_membership/clear_prime 3377 3608 107 3315 98
pallet_multisig/as_multi_threshold_1 23058 25124 109 23139 100
pallet_multisig/as_multi_threshold_1/z 1 1 100 1 100
pallet_multisig/as_multi_create 59429 62978 106 61669 104
pallet_multisig/as_multi_create/s 102 113 111 105 103
pallet_multisig/as_multi_create/z 1 1 100 1 100
pallet_multisig/as_multi_create_store 67356 68606 102 66629 99
pallet_multisig/as_multi_create_store/s 97 107 110 103 106
pallet_multisig/as_multi_create_store/z 2 2 100 2 100
pallet_multisig/as_multi_approve 41742 43478 104 41307 99
pallet_multisig/as_multi_approve/s 92 102 111 98 107
pallet_multisig/as_multi_approve/z 1 1 100 1 100
pallet_multisig/as_multi_approve_store 65739 68166 104 65730 100
pallet_multisig/as_multi_approve_store/s 95 105 111 98 103
pallet_multisig/as_multi_approve_store/z 2 2 100 2 100
pallet_multisig/as_multi_complete 78567 80881 103 77609 99
pallet_multisig/as_multi_complete/s 151 174 115 148 98
pallet_multisig/as_multi_complete/z 2 4 200 3 150
pallet_multisig/approve_as_multi_create 57666 59329 103 57618 100
pallet_multisig/approve_as_multi_create/s 123 138 112 131 107
pallet_multisig/approve_as_multi_approve 37179 38371 103 37402 101
pallet_multisig/approve_as_multi_approve/s 124 137 110 123 99
pallet_multisig/approve_as_multi_complete 99237 115148 116 99512 100
pallet_multisig/approve_as_multi_complete/s 172 191 111 185 108
pallet_multisig/cancel_as_multi 83449 91221 109 83270 100
pallet_multisig/cancel_as_multi/s 121 130 107 125 103
pallet_nomination_pools/join 210090 216756 103 213122 101
pallet_nomination_pools/bond_extra_transfer 194674 202189 104 199285 102
pallet_nomination_pools/bond_extra_reward 231370 240755 104 236795 102
pallet_nomination_pools/claim_payout 87020 90439 104 89194 102
pallet_nomination_pools/unbond 200796 207821 103 203903 102
pallet_nomination_pools/pool_withdraw_unbonded 68496 70826 103 69676 102
pallet_nomination_pools/pool_withdraw_unbonded/s 52 51 98 63 121
pallet_nomination_pools/withdraw_unbonded_update 143403 148316 103 146527 102
pallet_nomination_pools/withdraw_unbonded_update/s 51 50 98 53 104
pallet_nomination_pools/withdraw_unbonded_kill 251070 258101 103 260222 104
pallet_nomination_pools/create 235921 239853 102 238571 101
pallet_nomination_pools/nominate 83984 85025 101 84516 101
pallet_nomination_pools/nominate/n 3552 3683 104 3634 102
pallet_nomination_pools/set_state 43785 44269 101 43787 100
pallet_nomination_pools/set_metadata 23681 24286 103 23848 101
pallet_nomination_pools/set_metadata/n 2 3 150 2 100
pallet_nomination_pools/set_configs 11352 11945 105 11294 99
pallet_nomination_pools/update_roles 35954 36465 101 36961 103
pallet_nomination_pools/chill 78492 80319 102 79604 101
pallet_offences/report_offence_im_online/r 139267 202702 146 145400 104
pallet_offences/report_offence_im_online/o 724442 858417 118 752863 104
pallet_offences/report_offence_im_online/n 2385640 2525357 106 2451549 103
pallet_offences/report_offence_grandpa 160530 168676 105 161406 101
pallet_offences/report_offence_grandpa/n 21711 22528 104 22701 105
pallet_offences/report_offence_babe 160586 168831 105 160068 100
pallet_offences/report_offence_babe/n 21642 22215 103 22808 105
pallet_preimage/note_preimage/s 2 2 100 2 100
pallet_preimage/note_requested_preimage/s 2 2 100 2 100
pallet_preimage/note_no_deposit_preimage/s 2 2 100 2 100
pallet_preimage/unnote_preimage 76687 76156 99 77879 102
pallet_preimage/unnote_no_deposit_preimage 51182 51270 100 54254 106
pallet_preimage/request_preimage 72112 72858 101 74251 103
pallet_preimage/request_no_deposit_preimage 48476 49697 103 51872 107
pallet_preimage/request_unnoted_preimage 30246 31049 103 30958 102
pallet_preimage/request_requested_preimage 14315 14137 99 14588 102
pallet_preimage/unrequest_preimage 50740 50902 100 52578 104
pallet_preimage/unrequest_unnoted_preimage 31653 32915 104 32484 103
pallet_preimage/unrequest_multi_referenced_preimage 14081 14311 102 14176 101
pallet_proxy/proxy 30336 31211 103 30135 99
pallet_proxy/proxy/p 71 82 115 84 118
pallet_proxy/proxy_announced 60758 61690 102 59885 99
pallet_proxy/proxy_announced/a 300 361 120 307 102
pallet_proxy/proxy_announced/p 77 87 113 64 83
pallet_proxy/remove_announcement 43885 44123 101 42631 97
pallet_proxy/remove_announcement/a 305 370 121 305 100
pallet_proxy/remove_announcement/p 7 3 43 12 171
pallet_proxy/reject_announcement 43466 44002 101 42834 99
pallet_proxy/reject_announcement/a 308 370 120 317 103
pallet_proxy/reject_announcement/p 15 5 33 11 73
pallet_proxy/announce 57250 58132 102 56174 98
pallet_proxy/announce/a 297 340 114 306 103
pallet_proxy/announce/p 81 87 107 82 101
pallet_proxy/add_proxy 49001 49328 101 48111 98
pallet_proxy/add_proxy/p 121 145 120 142 117
pallet_proxy/remove_proxy 49173 49563 101 47922 97
pallet_proxy/remove_proxy/p 129 154 119 156 121
pallet_proxy/remove_proxies 41530 41444 100 41154 99
pallet_proxy/remove_proxies/p 73 89 122 54 74
pallet_proxy/anonymous 55821 55454 99 54420 97
pallet_proxy/kill_anonymous 43010 43085 100 42161 98
pallet_proxy/kill_anonymous/p 81 83 102 80 99
pallet_recovery/as_recovered 12454 12684 102 12431 100
pallet_recovery/set_recovered 23493 23756 101 23350 99
pallet_recovery/create_recovery 48534 50291 104 48708 100
pallet_recovery/create_recovery/n 230 150 65 189 82
pallet_recovery/initiate_recovery 55777 57526 103 56063 101
pallet_recovery/vouch_recovery 36857 38112 103 36346 99
pallet_recovery/vouch_recovery/n 431 450 104 429 100
pallet_recovery/claim_recovery 48891 50322 103 48229 99
pallet_recovery/claim_recovery/n 172 132 77 206 120
pallet_recovery/close_recovery 55745 56764 102 54863 98
pallet_recovery/close_recovery/n 203 527 260 289 142
pallet_recovery/remove_recovery 53569 58296 109 53776 100
pallet_recovery/remove_recovery/n 227 90 40 161 71
pallet_recovery/cancel_recovered 21204 21539 102 21569 102
pallet_scheduler/on_initialize_periodic_named_resolved 17153 15705 92 15311 89
pallet_scheduler/on_initialize_periodic_named_resolved/s 37769 40133 106 38043 101
pallet_scheduler/on_initialize_named_resolved 17196 18376 107 20092 117
pallet_scheduler/on_initialize_named_resolved/s 28957 30806 106 28973 100
pallet_scheduler/on_initialize_periodic_resolved 17628 16189 92 12681 72
pallet_scheduler/on_initialize_periodic_resolved/s 31268 33343 107 31529 101
pallet_scheduler/on_initialize_resolved 18775 14045 75 15247 81
pallet_scheduler/on_initialize_resolved/s 26117 28189 108 26530 102
pallet_scheduler/on_initialize_named_aborted 12932 12785 99 7975 62
pallet_scheduler/on_initialize_named_aborted/s 10855 12089 111 11289 104
pallet_scheduler/on_initialize_aborted 13946 14542 104 11749 84
pallet_scheduler/on_initialize_aborted/s 5377 6159 115 5475 102
pallet_scheduler/on_initialize_periodic_named 23682 24949 105 17494 74
pallet_scheduler/on_initialize_periodic_named/s 19427 21372 110 19870 102
pallet_scheduler/on_initialize_periodic 23238 21003 90 18118 78
pallet_scheduler/on_initialize_periodic/s 13308 15341 115 13699 103
pallet_scheduler/on_initialize_named 24767 28377 115 18995 77
pallet_scheduler/on_initialize_named/s 10937 12302 112 11393 104
pallet_scheduler/on_initialize 24094 23661 98 19046 79
pallet_scheduler/on_initialize/s 8482 9747 115 8812 104
pallet_scheduler/schedule 31267 33074 106 30381 97
pallet_scheduler/schedule/s 108 107 99 111 103
pallet_scheduler/cancel 31067 32700 105 30326 98
pallet_scheduler/cancel/s 883 1218 138 900 102
pallet_scheduler/schedule_named 37527 39320 105 36565 97
pallet_scheduler/schedule_named/s 129 129 100 128 99
pallet_scheduler/cancel_named 33807 35125 104 33701 100
pallet_scheduler/cancel_named/s 881 1238 141 887 101
pallet_session/set_keys 71902 74731 104 72752 101
pallet_session/purge_keys 53163 55240 104 54163 102
pallet_staking/bond 77069 77377 100 76117 99
pallet_staking/bond_extra 129445 132605 102 127311 98
pallet_staking/unbond 140164 141599 101 135702 97
pallet_staking/withdraw_unbonded_update 58723 59710 102 57552 98
pallet_staking/withdraw_unbonded_update/s 56 56 100 64 114
pallet_staking/withdraw_unbonded_kill 116191 116854 101 113173 97
pallet_staking/validate 90426 92116 102 88512 98
pallet_staking/kick 31167 34326 110 40242 129
pallet_staking/kick/k 14378 14745 103 14253 99
pallet_staking/nominate 94334 94339 100 93641 99
pallet_staking/nominate/n 5371 5475 102 5423 101
pallet_staking/chill 85025 84811 100 82944 98
pallet_staking/set_payee 18929 19023 100 18268 97
pallet_staking/set_controller 32504 33039 102 32424 100
pallet_staking/set_validator_count 7264 7432 102 6943 96
pallet_staking/force_no_eras 7689 7828 102 7408 96
pallet_staking/force_new_era 7677 7919 103 7390 96
pallet_staking/force_new_era_always 7662 7776 101 7404 97
pallet_staking/set_invulnerables 8598 8653 101 8325 97
pallet_staking/set_invulnerables/v 11 11 100 11 100
pallet_staking/force_unstake 112458 112935 100 108870 97
pallet_staking/force_unstake/s 2152 2209 103 2299 107
pallet_staking/cancel_deferred_slash 927251 1762364 190 954199 103
pallet_staking/cancel_deferred_slash/s 4764 9939 209 5030 106
pallet_staking/payout_stakers_dead_controller 120830 117276 97 116338 96
pallet_staking/payout_stakers_dead_controller/n 46372 47170 102 46768 101
pallet_staking/payout_stakers_alive_staked 161438 177425 110 226904 141
pallet_staking/payout_stakers_alive_staked/n 60964 61838 101 61143 100
pallet_staking/rebond 128204 131039 102 126499 99
pallet_staking/rebond/l 67 80 119 82 122
pallet_staking/set_history_depth/e 34028 34272 101 34336 101
pallet_staking/reap_stash 123484 124546 101 120822 98
pallet_staking/reap_stash/s 2156 2215 103 2266 105
pallet_staking/new_era/v 294997 386423 131 312274 106
pallet_staking/new_era/n 45477 54346 120 47743 105
pallet_staking/get_npos_voters/v 34911 35453 102 35493 102
pallet_staking/get_npos_voters/n 30929 32118 104 31654 102
pallet_staking/get_npos_voters/s 31980 48819 153 6732 21
pallet_staking/get_npos_targets/v 10685 10926 102 11140 104
pallet_staking/set_staking_configs_all_set 13278 13689 103 12635 95
pallet_staking/set_staking_configs_all_remove 12971 12503 96 12124 93
pallet_staking/chill_other 104293 105812 101 102235 98
pallet_staking/force_apply_min_commission 20775 21118 102 20786 100
pallet_timestamp/set 15017 15113 101 15051 100
pallet_timestamp/on_finalize 4675 4830 103 4730 101
pallet_tips/report_awesome 55464 55349 100 55204 100
pallet_tips/report_awesome/r 2 3 150 4 200
pallet_tips/retract_tip 51458 52073 101 51705 100
pallet_tips/tip_new 36836 36169 98 36739 100
pallet_tips/tip_new/r 2 3 150 2 100
pallet_tips/tip_new/t 223 250 112 219 98
pallet_tips/tip 23946 24225 101 23767 99
pallet_tips/tip/t 431 553 128 440 102
pallet_tips/close_tip 82879 83339 101 81880 99
pallet_tips/close_tip/t 205 431 210 414 202
pallet_tips/slash_tip 32067 31870 99 31430 98
pallet_tips/slash_tip/t 18 37 206 74 411
pallet_treasury/spend 424 510 120 406 96
pallet_treasury/propose_spend 45405 48305 106 46795 103
pallet_treasury/reject_proposal 50759 52958 104 51781 102
pallet_treasury/approve_proposal 18245 19232 105 18953 104
pallet_treasury/approve_proposal/p 120 118 98 132 110
pallet_treasury/remove_approval 11975 12961 108 12357 103
pallet_treasury/on_initialize_proposals 43705 45920 105 41529 95
pallet_treasury/on_initialize_proposals/p 54903 56735 103 56980 104
pallet_utility/batch 32522 38665 119 27812 86
pallet_utility/batch/c 5430 5774 106 5563 102
pallet_utility/as_derivative 8874 9032 102 8556 96
pallet_utility/batch_all 36288 32454 89 31890 88
pallet_utility/batch_all/c 5779 6183 107 5849 101
pallet_utility/dispatch_as 21782 21733 100 22110 102
pallet_utility/force_batch 50965 34903 68 29641 58
pallet_utility/force_batch/c 5414 5755 106 5568 103
pallet_vesting/vest_locked 57520 57782 100 59050 103
pallet_vesting/vest_locked/l 104 124 119 111 107
pallet_vesting/vest_locked/s 101 136 135 104 103
pallet_vesting/vest_unlocked 56807 57219 101 59026 104
pallet_vesting/vest_unlocked/l 97 108 111 86 89
pallet_vesting/vest_unlocked/s 60 87 145 51 85
pallet_vesting/vest_other_locked 57594 57933 101 59333 103
pallet_vesting/vest_other_locked/l 102 116 114 93 91
pallet_vesting/vest_other_locked/s 102 135 132 102 100
pallet_vesting/vest_other_unlocked 56721 57597 102 58604 103
pallet_vesting/vest_other_unlocked/l 93 106 114 92 99
pallet_vesting/vest_other_unlocked/s 53 76 143 47 89
pallet_vesting/vested_transfer 88572 90688 102 91159 103
pallet_vesting/vested_transfer/l 97 103 106 106 109
pallet_vesting/vested_transfer/s 41 58 141 47 115
pallet_vesting/force_vested_transfer 88288 89688 102 91317 103
pallet_vesting/force_vested_transfer/l 89 100 112 94 106
pallet_vesting/force_vested_transfer/s 44 73 166 31 70
pallet_vesting/not_unlocking_merge_schedules 58910 59579 101 61389 104
pallet_vesting/not_unlocking_merge_schedules/l 102 123 121 100 98
pallet_vesting/not_unlocking_merge_schedules/s 109 130 119 91 83
pallet_vesting/unlocking_merge_schedules 58632 59466 101 60025 102
pallet_vesting/unlocking_merge_schedules/l 102 119 117 112 110
pallet_vesting/unlocking_merge_schedules/s 100 121 121 109 109

@athei
Copy link
Member

athei commented Jul 8, 2022

The weights are a product of running linear regression over the raw measurements. In some cases this produces very noisy results. The component weights which represent the slope of the regression (that is, the rows with e.g. "/i" etc. at the end) are still somewhat consistent, but the base weights which represent the intercept value are not. (It really depends on the exact benchmark.)

FWIW: All the contract benchmarks which have /r end up disregarding the base weight (by using benchmark(1) - benchmark(0)).

There's a bug in the weight generation code

Is there an issue for this bug?

@koute
Copy link
Contributor

koute commented Jul 8, 2022

There's a bug in the weight generation code

Is there an issue for this bug?

Okay, I've made an issue describing this.

@koute
Copy link
Contributor

koute commented Jul 11, 2022

Newest results from the reference hardware based on raw measurements. All numbers are in % relative to the baseline case when running with no gas metering. For extrinsics with components the values you see here are averages over percentage scores for each unique set of component values. (I could generate a table with those not averaged, but it'd be insanely long.)

Benchmark results
vanilla-fuel async-fuel
frame_benchmarking/addition 92.9 89.9
frame_benchmarking/subtraction 88.9 85.0
frame_benchmarking/multiplication 90.0 85.2
frame_benchmarking/division 89.3 85.6
frame_benchmarking/hashing 101.8 106.2
frame_benchmarking/sr25519_verification 100.0 102.2
frame_benchmarking/storage_read 105.0 102.8
frame_benchmarking/storage_write 104.0 105.4
frame_system/remark 161.7 104.9
frame_system/remark_with_event 117.9 102.5
frame_system/set_heap_pages 98.6 97.2
frame_system/set_storage 106.3 101.1
frame_system/kill_storage 102.6 100.6
frame_system/kill_prefix 100.1 100.9
pallet_bags_list/rebag_non_terminal 104.5 100.5
pallet_bags_list/rebag_terminal 103.2 100.4
pallet_bags_list/put_in_front_of 105.8 102.1
pallet_balances/transfer 102.8 101.2
pallet_balances/transfer_keep_alive 105.6 100.5
pallet_balances/set_balance_creating 100.2 100.3
pallet_balances/set_balance_killing 103.8 101.6
pallet_balances/force_transfer 105.7 101.7
pallet_balances/transfer_all 103.5 98.9
pallet_balances/force_unreserve 101.2 99.3
pallet_bounties/propose_bounty 105.3 104.1
pallet_bounties/approve_bounty 106.4 102.5
pallet_bounties/propose_curator 106.4 104.3
pallet_bounties/unassign_curator 103.5 100.2
pallet_bounties/accept_curator 104.9 104.1
pallet_bounties/award_bounty 107.6 102.8
pallet_bounties/claim_bounty 105.4 102.4
pallet_bounties/close_bounty_proposed 106.0 103.5
pallet_bounties/close_bounty_active 106.7 102.7
pallet_bounties/extend_bounty_expiry 105.6 104.4
pallet_bounties/spend_funds 105.8 104.7
pallet_child_bounties/add_child_bounty 103.1 101.6
pallet_child_bounties/propose_curator 103.7 99.7
pallet_child_bounties/accept_curator 103.8 100.7
pallet_child_bounties/unassign_curator 101.7 99.8
pallet_child_bounties/award_child_bounty 103.8 98.8
pallet_child_bounties/claim_child_bounty 104.1 100.0
pallet_child_bounties/close_child_bounty_added 103.6 100.0
pallet_child_bounties/close_child_bounty_active 104.0 101.9
pallet_collective/set_members 125.7 106.5
pallet_collective/execute 105.7 100.5
pallet_collective/propose_execute 106.7 100.7
pallet_collective/propose_proposed 104.8 101.6
pallet_collective/vote 104.1 102.4
pallet_collective/close_early_disapproved 104.7 101.8
pallet_collective/close_early_approved 104.8 101.7
pallet_collective/close_disapproved 104.8 101.3
pallet_collective/close_approved 104.7 101.9
pallet_collective/disapprove_proposal 102.4 100.5
pallet_contracts/on_process_deletion_queue_batch 111.5 98.6
pallet_contracts/on_initialize_per_trie_key 99.8 100.4
pallet_contracts/on_initialize_per_queue_item 109.2 102.6
pallet_contracts/reinstrument 136.8 104.1
pallet_contracts/call_with_code_per_byte 126.2 103.5
pallet_contracts/instantiate_with_code 126.8 103.1
pallet_contracts/instantiate 127.8 103.2
pallet_contracts/call 158.7 102.1
pallet_contracts/upload_code 134.8 104.7
pallet_contracts/remove_code 107.7 101.9
pallet_contracts/set_code 108.6 101.6
pallet_contracts/seal_caller 134.5 103.6
pallet_contracts/seal_is_contract 120.6 103.6
pallet_contracts/seal_code_hash 121.1 104.2
pallet_contracts/seal_own_code_hash 134.5 104.1
pallet_contracts/seal_caller_is_origin 162.2 104.9
pallet_contracts/seal_address 136.4 103.3
pallet_contracts/seal_gas_left 136.4 102.8
pallet_contracts/seal_balance 125.6 103.8
pallet_contracts/seal_value_transferred 136.8 102.5
pallet_contracts/seal_minimum_balance 136.5 103.2
pallet_contracts/seal_block_number 136.7 104.4
pallet_contracts/seal_now 136.2 103.7
pallet_contracts/seal_weight_to_fee 127.5 105.5
pallet_contracts/seal_gas 136.2 101.3
pallet_contracts/seal_input 139.1 104.4
pallet_contracts/seal_input_per_kb 192.4 101.4
pallet_contracts/seal_return 176.5 101.7
pallet_contracts/seal_return_per_kb 181.4 103.2
pallet_contracts/seal_terminate 168.1 103.6
pallet_contracts/seal_random 121.7 103.9
pallet_contracts/seal_deposit_event 118.2 105.0
pallet_contracts/seal_deposit_event_per_topic_and_kb 128.8 103.7
pallet_contracts/seal_debug_message 136.5 101.9
pallet_contracts/seal_set_storage 120.3 105.6
pallet_contracts/seal_set_storage_per_new_kb 144.2 104.5
pallet_contracts/seal_set_storage_per_old_kb 134.3 103.2
pallet_contracts/seal_clear_storage 118.3 103.4
pallet_contracts/seal_clear_storage_per_kb 134.2 102.0
pallet_contracts/seal_get_storage 122.7 105.4
pallet_contracts/seal_get_storage_per_kb 145.6 104.9
pallet_contracts/seal_contains_storage 120.5 103.6
pallet_contracts/seal_contains_storage_per_kb 139.1 102.7
pallet_contracts/seal_take_storage 120.6 104.0
pallet_contracts/seal_take_storage_per_kb 142.1 103.7
pallet_contracts/seal_transfer 113.3 103.4
pallet_contracts/seal_call 181.7 103.8
pallet_contracts/seal_delegate_call 183.3 103.4
pallet_contracts/seal_call_per_transfer_clone_kb 170.8 103.6
pallet_contracts/seal_instantiate 162.4 103.3
pallet_contracts/seal_instantiate_per_transfer_salt_kb 129.4 102.5
pallet_contracts/seal_hash_sha2_256 132.3 101.7
pallet_contracts/seal_hash_sha2_256_per_kb 107.0 102.0
pallet_contracts/seal_hash_keccak_256 133.3 102.8
pallet_contracts/seal_hash_keccak_256_per_kb 108.5 102.1
pallet_contracts/seal_hash_blake2_256 139.7 104.1
pallet_contracts/seal_hash_blake2_256_per_kb 120.2 102.1
pallet_contracts/seal_hash_blake2_128 139.2 101.3
pallet_contracts/seal_hash_blake2_128_per_kb 120.2 101.8
pallet_contracts/seal_ecdsa_recover 105.8 102.6
pallet_contracts/seal_ecdsa_to_eth_address 112.2 112.8
pallet_contracts/seal_set_code_hash 115.0 106.1
pallet_contracts/instr_i64const 172.9 101.1
pallet_contracts/instr_i64load 161.0 101.6
pallet_contracts/instr_i64store 158.1 101.3
pallet_contracts/instr_select 153.7 101.2
pallet_contracts/instr_if 153.5 99.4
pallet_contracts/instr_br 164.5 101.3
pallet_contracts/instr_br_if 158.2 101.1
pallet_contracts/instr_br_table 156.9 100.4
pallet_contracts/instr_br_table_per_entry 192.2 101.0
pallet_contracts/instr_call 146.9 100.2
pallet_contracts/instr_call_indirect 146.5 102.7
pallet_contracts/instr_call_indirect_per_param 161.5 101.1
pallet_contracts/instr_local_get 173.8 101.9
pallet_contracts/instr_local_set 172.8 101.1
pallet_contracts/instr_local_tee 166.2 101.9
pallet_contracts/instr_global_get 164.7 101.6
pallet_contracts/instr_global_set 163.6 101.5
pallet_contracts/instr_memory_current 172.2 101.1
pallet_contracts/instr_memory_grow 196.9 100.2
pallet_contracts/instr_i64clz 165.2 101.5
pallet_contracts/instr_i64ctz 165.2 101.5
pallet_contracts/instr_i64popcnt 165.2 101.6
pallet_contracts/instr_i64eqz 164.9 100.7
pallet_contracts/instr_i64extendsi32 164.8 100.9
pallet_contracts/instr_i64extendui32 164.7 100.8
pallet_contracts/instr_i32wrapi64 164.3 100.9
pallet_contracts/instr_i64eq 158.7 100.7
pallet_contracts/instr_i64ne 158.4 100.9
pallet_contracts/instr_i64lts 158.5 100.8
pallet_contracts/instr_i64ltu 158.5 100.9
pallet_contracts/instr_i64gts 158.6 101.0
pallet_contracts/instr_i64gtu 158.4 100.7
pallet_contracts/instr_i64les 158.6 100.6
pallet_contracts/instr_i64leu 158.6 101.3
pallet_contracts/instr_i64ges 158.8 101.4
pallet_contracts/instr_i64geu 158.5 101.2
pallet_contracts/instr_i64add 158.5 101.9
pallet_contracts/instr_i64sub 158.5 101.5
pallet_contracts/instr_i64mul 158.6 102.0
pallet_contracts/instr_i64divs 155.1 100.3
pallet_contracts/instr_i64divu 155.5 100.7
pallet_contracts/instr_i64rems 154.8 101.6
pallet_contracts/instr_i64remu 155.1 99.7
pallet_contracts/instr_i64and 158.4 101.0
pallet_contracts/instr_i64or 158.3 101.2
pallet_contracts/instr_i64xor 158.4 100.7
pallet_contracts/instr_i64shl 158.1 100.9
pallet_contracts/instr_i64shrs 158.6 101.4
pallet_contracts/instr_i64shru 158.5 100.5
pallet_contracts/instr_i64rotl 158.4 101.4
pallet_contracts/instr_i64rotr 158.1 101.8
pallet_democracy/propose 104.6 101.0
pallet_democracy/second 106.0 101.1
pallet_democracy/vote_new 105.6 100.9
pallet_democracy/vote_existing 106.5 101.6
pallet_democracy/emergency_cancel 104.7 100.2
pallet_democracy/blacklist 105.4 100.9
pallet_democracy/external_propose 104.7 99.1
pallet_democracy/external_propose_majority 104.6 99.2
pallet_democracy/external_propose_default 102.9 97.6
pallet_democracy/fast_track 104.8 100.5
pallet_democracy/veto_external 105.8 100.1
pallet_democracy/cancel_proposal 105.9 101.0
pallet_democracy/cancel_referendum 103.1 101.8
pallet_democracy/cancel_queued 120.5 100.5
pallet_democracy/on_initialize_base 104.3 100.3
pallet_democracy/on_initialize_base_with_launch_period 103.9 100.5
pallet_democracy/delegate 105.5 100.4
pallet_democracy/undelegate 104.6 100.9
pallet_democracy/clear_public_proposals 104.0 101.1
pallet_democracy/note_preimage 110.3 101.5
pallet_democracy/note_imminent_preimage 111.8 100.7
pallet_democracy/reap_preimage 111.7 101.8
pallet_democracy/unlock_remove 104.2 102.0
pallet_democracy/unlock_set 107.0 102.9
pallet_democracy/remove_vote 107.0 100.7
pallet_democracy/remove_other_vote 107.3 102.0
pallet_election_provider_multi_phase/on_initialize_nothing 101.6 100.0
pallet_election_provider_multi_phase/on_initialize_open_signed 100.5 101.2
pallet_election_provider_multi_phase/on_initialize_open_unsigned 101.9 99.1
pallet_election_provider_multi_phase/finalize_signed_phase_accept_solution 101.7 98.3
pallet_election_provider_multi_phase/finalize_signed_phase_reject_solution 102.2 98.2
pallet_election_provider_multi_phase/create_snapshot_internal 104.9 110.2
pallet_election_provider_multi_phase/elect_queued 123.2 104.5
pallet_election_provider_multi_phase/submit 105.6 99.4
pallet_election_provider_multi_phase/submit_unsigned 135.2 104.2
pallet_election_provider_multi_phase/feasibility_check 135.8 104.2
pallet_elections_phragmen/vote_equal 104.6 100.5
pallet_elections_phragmen/vote_more 105.6 101.0
pallet_elections_phragmen/vote_less 104.8 100.1
pallet_elections_phragmen/remove_voter 104.6 100.1
pallet_elections_phragmen/submit_candidacy 109.5 103.7
pallet_elections_phragmen/renounce_candidacy_candidate 106.4 101.8
pallet_elections_phragmen/renounce_candidacy_members 105.8 102.6
pallet_elections_phragmen/renounce_candidacy_runners_up 104.7 102.2
pallet_elections_phragmen/remove_member_without_replacement 100.0 100.0
pallet_elections_phragmen/remove_member_with_replacement 106.4 102.5
pallet_elections_phragmen/remove_member_wrong_refund 102.3 103.2
pallet_elections_phragmen/clean_defunct_voters 107.3 101.9
pallet_elections_phragmen/election_phragmen 131.2 109.1
pallet_gilt/place_bid 120.5 101.7
pallet_gilt/place_bid_max 120.1 103.1
pallet_gilt/retract_bid 118.8 102.1
pallet_gilt/set_target 103.1 96.6
pallet_gilt/thaw 101.1 100.0
pallet_gilt/pursue_target_noop 105.6 95.8
pallet_gilt/pursue_target_per_item 105.7 99.9
pallet_gilt/pursue_target_per_queue 105.4 102.1
pallet_identity/add_registrar 102.3 101.2
pallet_identity/set_identity 108.9 101.5
pallet_identity/set_subs_new 102.9 102.3
pallet_identity/set_subs_old 103.8 102.4
pallet_identity/clear_identity 105.8 102.5
pallet_identity/request_judgement 110.6 101.9
pallet_identity/cancel_request 109.5 101.4
pallet_identity/set_fee 104.1 100.6
pallet_identity/set_account_id 103.7 100.5
pallet_identity/set_fields 103.7 100.9
pallet_identity/provide_judgement 111.7 101.1
pallet_identity/kill_identity 103.1 102.4
pallet_identity/add_sub 102.3 100.5
pallet_identity/rename_sub 100.6 100.2
pallet_identity/remove_sub 102.2 100.8
pallet_identity/quit_sub 102.9 100.8
pallet_im_online/validate_unsigned_and_then_heartbeat 112.4 102.0
pallet_indices/claim 104.1 100.2
pallet_indices/transfer 104.1 97.9
pallet_indices/free 106.0 101.0
pallet_indices/force_transfer 102.0 98.1
pallet_indices/freeze 103.7 99.9
pallet_membership/add_member 106.1 99.2
pallet_membership/remove_member 105.9 100.9
pallet_membership/swap_member 107.4 101.9
pallet_membership/reset_member 111.2 100.5
pallet_membership/change_key 106.9 100.7
pallet_membership/set_prime 106.7 99.5
pallet_membership/clear_prime 104.1 98.6
pallet_multisig/as_multi_threshold_1 114.6 102.5
pallet_multisig/as_multi_create 107.0 102.5
pallet_multisig/as_multi_create_store 108.6 102.6
pallet_multisig/as_multi_approve 108.7 102.5
pallet_multisig/as_multi_approve_store 109.4 101.8
pallet_multisig/as_multi_complete 112.4 102.8
pallet_multisig/approve_as_multi_create 104.1 102.2
pallet_multisig/approve_as_multi_approve 105.5 102.4
pallet_multisig/approve_as_multi_complete 115.8 102.5
pallet_multisig/cancel_as_multi 109.6 102.8
pallet_nomination_pools/join 102.3 101.8
pallet_nomination_pools/bond_extra_transfer 103.1 102.1
pallet_nomination_pools/bond_extra_reward 104.6 102.7
pallet_nomination_pools/claim_payout 101.8 99.5
pallet_nomination_pools/unbond 102.5 100.3
pallet_nomination_pools/pool_withdraw_unbonded 103.5 101.4
pallet_nomination_pools/withdraw_unbonded_update 102.5 102.0
pallet_nomination_pools/withdraw_unbonded_kill 101.8 102.5
pallet_nomination_pools/create 100.9 101.3
pallet_nomination_pools/nominate 99.8 99.8
pallet_nomination_pools/set_state 101.3 100.3
pallet_nomination_pools/set_metadata 101.2 99.9
pallet_nomination_pools/set_configs 102.2 104.1
pallet_nomination_pools/update_roles 101.6 100.8
pallet_nomination_pools/chill 101.7 102.0
pallet_offences/report_offence_im_online 113.3 104.6
pallet_offences/report_offence_grandpa 103.8 103.4
pallet_offences/report_offence_babe 103.6 103.4
pallet_preimage/note_preimage 121.8 103.3
pallet_preimage/note_requested_preimage 122.0 102.4
pallet_preimage/note_no_deposit_preimage 122.0 103.1
pallet_preimage/unnote_preimage 104.1 104.3
pallet_preimage/unnote_no_deposit_preimage 106.8 104.8
pallet_preimage/request_preimage 105.5 104.4
pallet_preimage/request_no_deposit_preimage 107.5 103.8
pallet_preimage/request_unnoted_preimage 107.4 103.5
pallet_preimage/request_requested_preimage 106.1 106.0
pallet_preimage/unrequest_preimage 106.1 106.2
pallet_preimage/unrequest_unnoted_preimage 104.9 105.4
pallet_preimage/unrequest_multi_referenced_preimage 100.8 105.9
pallet_proxy/proxy 105.4 103.3
pallet_proxy/proxy_announced 107.0 103.4
pallet_proxy/remove_announcement 105.8 103.1
pallet_proxy/reject_announcement 105.6 102.8
pallet_proxy/announce 105.9 102.3
pallet_proxy/add_proxy 105.1 102.5
pallet_proxy/remove_proxy 104.9 102.9
pallet_proxy/remove_proxies 104.0 103.2
pallet_proxy/anonymous 103.4 102.8
pallet_proxy/kill_anonymous 104.9 103.5
pallet_recovery/as_recovered 105.6 100.6
pallet_recovery/set_recovered 101.5 104.8
pallet_recovery/create_recovery 101.6 101.7
pallet_recovery/initiate_recovery 102.0 101.5
pallet_recovery/vouch_recovery 103.0 102.1
pallet_recovery/claim_recovery 102.8 101.1
pallet_recovery/close_recovery 102.0 99.9
pallet_recovery/remove_recovery 101.9 101.7
pallet_recovery/cancel_recovered 104.4 103.0
pallet_scheduler/on_initialize_periodic_named_resolved 108.4 104.2
pallet_scheduler/on_initialize_named_resolved 109.1 104.9
pallet_scheduler/on_initialize_periodic_resolved 108.9 103.6
pallet_scheduler/on_initialize_resolved 109.7 103.9
pallet_scheduler/on_initialize_named_aborted 111.7 103.7
pallet_scheduler/on_initialize_aborted 114.3 103.5
pallet_scheduler/on_initialize_periodic_named 110.8 102.8
pallet_scheduler/on_initialize_periodic 111.8 102.6
pallet_scheduler/on_initialize_named 113.2 103.6
pallet_scheduler/on_initialize 114.3 103.2
pallet_scheduler/schedule 104.6 101.3
pallet_scheduler/cancel 119.4 102.1
pallet_scheduler/schedule_named 104.6 102.0
pallet_scheduler/cancel_named 118.1 102.6
pallet_session/set_keys 101.1 101.9
pallet_session/purge_keys 100.7 101.0
pallet_staking/bond 102.9 103.3
pallet_staking/bond_extra 104.2 105.8
pallet_staking/unbond 103.7 106.0
pallet_staking/withdraw_unbonded_update 102.6 104.1
pallet_staking/withdraw_unbonded_kill 103.9 104.3
pallet_staking/validate 102.5 102.7
pallet_staking/kick 105.6 105.6
pallet_staking/nominate 103.0 104.0
pallet_staking/chill 103.3 104.1
pallet_staking/set_payee 103.7 104.4
pallet_staking/set_controller 104.1 106.8
pallet_staking/set_validator_count 101.1 105.9
pallet_staking/force_no_eras 100.9 104.1
pallet_staking/force_new_era 103.4 105.9
pallet_staking/force_new_era_always 103.2 107.1
pallet_staking/set_invulnerables 104.5 104.8
pallet_staking/force_unstake 105.6 107.9
pallet_staking/cancel_deferred_slash 204.0 107.1
pallet_staking/payout_stakers_dead_controller 104.1 105.8
pallet_staking/payout_stakers_alive_staked 103.7 105.0
pallet_staking/rebond 104.0 104.5
pallet_staking/set_history_depth 101.6 105.9
pallet_staking/reap_stash 104.6 106.8
pallet_staking/new_era 113.1 106.1
pallet_staking/get_npos_voters 103.9 105.2
pallet_staking/get_npos_targets 101.5 104.0
pallet_staking/set_staking_configs_all_set 102.3 104.2
pallet_staking/set_staking_configs_all_remove 101.8 103.1
pallet_staking/chill_other 102.8 104.6
pallet_staking/force_apply_min_commission 100.7 102.5
pallet_timestamp/set 103.0 97.7
pallet_timestamp/on_finalize 104.0 99.8
pallet_tips/report_awesome 103.0 101.1
pallet_tips/retract_tip 103.3 102.1
pallet_tips/tip_new 102.7 101.2
pallet_tips/tip 108.7 102.9
pallet_tips/close_tip 104.7 102.8
pallet_tips/slash_tip 104.3 101.3
pallet_treasury/spend 91.1 102.3
pallet_treasury/propose_spend 101.4 100.0
pallet_treasury/reject_proposal 104.2 102.0
pallet_treasury/approve_proposal 101.3 101.1
pallet_treasury/remove_approval 100.5 100.7
pallet_treasury/on_initialize_proposals 103.2 103.0
pallet_utility/batch 109.9 102.3
pallet_utility/as_derivative 104.3 98.2
pallet_utility/batch_all 109.8 102.0
pallet_utility/dispatch_as 103.8 101.5
pallet_utility/force_batch 109.2 101.2
pallet_vesting/vest_locked 101.5 98.7
pallet_vesting/vest_unlocked 101.4 98.7
pallet_vesting/vest_other_locked 101.6 99.0
pallet_vesting/vest_other_unlocked 101.3 99.4
pallet_vesting/vested_transfer 101.9 99.0
pallet_vesting/force_vested_transfer 101.7 99.1
pallet_vesting/not_unlocking_merge_schedules 102.0 99.4
pallet_vesting/unlocking_merge_schedules 101.7 98.7
  • Average execution time of vanilla-fuel compared to no-fuel: 118.0%
  • Average execution time of async-fuel compared to no-fuel: 102.0%

And here's a table with top-50 slowest async-fuel benchmarks compared to no-fuel:

Benchmark results
vanilla-fuel async-fuel
pallet_contracts/seal_ecdsa_to_eth_address 112.2 112.8
pallet_election_provider_multi_phase/create_snapshot_internal 104.9 110.2
pallet_elections_phragmen/election_phragmen 131.2 109.1
pallet_staking/force_unstake 105.6 107.9
pallet_staking/force_new_era_always 103.2 107.1
pallet_staking/cancel_deferred_slash 204.0 107.1
pallet_staking/set_controller 104.1 106.8
pallet_staking/reap_stash 104.6 106.8
pallet_collective/set_members 125.7 106.5
frame_benchmarking/hashing 101.8 106.2
pallet_preimage/unrequest_preimage 106.1 106.2
pallet_contracts/seal_set_code_hash 115.0 106.1
pallet_staking/new_era 113.1 106.1
pallet_preimage/request_requested_preimage 106.1 106.0
pallet_staking/unbond 103.7 106.0
pallet_staking/force_new_era 103.4 105.9
pallet_staking/set_validator_count 101.1 105.9
pallet_preimage/unrequest_multi_referenced_preimage 100.8 105.9
pallet_staking/set_history_depth 101.6 105.9
pallet_staking/bond_extra 104.2 105.8
pallet_staking/payout_stakers_dead_controller 104.1 105.8
pallet_contracts/seal_set_storage 120.3 105.6
pallet_staking/kick 105.6 105.6
pallet_contracts/seal_weight_to_fee 127.5 105.5
pallet_contracts/seal_get_storage 122.7 105.4
frame_benchmarking/storage_write 104.0 105.4
pallet_preimage/unrequest_unnoted_preimage 104.9 105.4
pallet_staking/get_npos_voters 103.9 105.2
pallet_contracts/seal_deposit_event 118.2 105.0
pallet_staking/payout_stakers_alive_staked 103.7 105.0
pallet_scheduler/on_initialize_named_resolved 109.1 104.9
pallet_contracts/seal_caller_is_origin 162.2 104.9
frame_system/remark 161.7 104.9
pallet_contracts/seal_get_storage_per_kb 145.6 104.9
pallet_recovery/set_recovered 101.5 104.8
pallet_preimage/unnote_no_deposit_preimage 106.8 104.8
pallet_staking/set_invulnerables 104.5 104.8
pallet_contracts/upload_code 134.8 104.7
pallet_bounties/spend_funds 105.8 104.7
pallet_staking/chill_other 102.8 104.6
pallet_offences/report_offence_im_online 113.3 104.6
pallet_election_provider_multi_phase/elect_queued 123.2 104.5
pallet_staking/rebond 104.0 104.5
pallet_contracts/seal_set_storage_per_new_kb 144.2 104.5
pallet_bounties/extend_bounty_expiry 105.6 104.4
pallet_contracts/seal_block_number 136.7 104.4
pallet_contracts/seal_input 139.1 104.4
pallet_staking/set_payee 103.7 104.4
pallet_preimage/request_preimage 105.5 104.4
pallet_staking/withdraw_unbonded_kill 103.9 104.3

The pallet_election_provider_multi_phase/create_snapshot_internal results look fishy since the vanilla metering is faster here, but they're consistent:

Benchmark results
no-fuel vanilla-fuel % async-fuel %
create_snapshot_internal/v=1000;t=1000 385229 403611 105 425609 110
create_snapshot_internal/v=1020;t=1000 386115 411071 106 416076 108
create_snapshot_internal/v=1040;t=1000 390715 415703 106 426616 109
create_snapshot_internal/v=1060;t=1000 396713 410547 103 438613 111
create_snapshot_internal/v=1080;t=1000 402218 413507 103 438092 109
create_snapshot_internal/v=1100;t=1000 404522 423752 105 440237 109
create_snapshot_internal/v=1120;t=1000 416309 424162 102 424690 102
create_snapshot_internal/v=1140;t=1000 414197 435945 105 454979 110
create_snapshot_internal/v=1160;t=1000 420960 431254 102 468789 111
create_snapshot_internal/v=1180;t=1000 420599 437084 104 461451 110
create_snapshot_internal/v=1200;t=1000 426050 446236 105 473189 111
create_snapshot_internal/v=1220;t=1000 436460 448710 103 474493 109
create_snapshot_internal/v=1240;t=1000 433428 464084 107 485530 112
create_snapshot_internal/v=1260;t=1000 433322 462781 107 489235 113
create_snapshot_internal/v=1280;t=1000 448841 461471 103 483017 108
create_snapshot_internal/v=1300;t=1000 450145 469190 104 492786 109
create_snapshot_internal/v=1320;t=1000 455036 472722 104 500936 110
create_snapshot_internal/v=1340;t=1000 452960 485122 107 518291 114
create_snapshot_internal/v=1360;t=1000 467115 497160 106 522758 112
create_snapshot_internal/v=1380;t=1000 468962 498134 106 527292 112
create_snapshot_internal/v=1400;t=1000 476430 511398 107 506459 106
create_snapshot_internal/v=1420;t=1000 472539 510402 108 532531 113
create_snapshot_internal/v=1440;t=1000 481134 507420 105 525692 109
create_snapshot_internal/v=1460;t=1000 497058 530441 107 531312 107
create_snapshot_internal/v=1480;t=1000 492734 525690 107 542525 110
create_snapshot_internal/v=1500;t=1000 504099 527415 105 562342 112
create_snapshot_internal/v=1520;t=1000 510663 524811 103 570451 112
create_snapshot_internal/v=1540;t=1000 513746 536446 104 565464 110
create_snapshot_internal/v=1560;t=1000 514934 541102 105 585936 114
create_snapshot_internal/v=1580;t=1000 520691 547214 105 568892 109
create_snapshot_internal/v=1600;t=1000 526542 558256 106 594674 113
create_snapshot_internal/v=1620;t=1000 527957 566176 107 596890 113
create_snapshot_internal/v=1640;t=1000 540304 574026 106 599703 111
create_snapshot_internal/v=1660;t=1000 550302 573548 104 598240 109
create_snapshot_internal/v=1680;t=1000 555769 584313 105 603341 109
create_snapshot_internal/v=1700;t=1000 559971 583760 104 622369 111
create_snapshot_internal/v=1720;t=1000 566754 585682 103 624176 110
create_snapshot_internal/v=1740;t=1000 578811 596571 103 624200 108
create_snapshot_internal/v=1760;t=1000 577549 608488 105 625772 108
create_snapshot_internal/v=1780;t=1000 565942 604716 107 627112 111
create_snapshot_internal/v=1800;t=1000 571614 607130 106 624785 109
create_snapshot_internal/v=1820;t=1000 584092 608101 104 618703 106
create_snapshot_internal/v=1840;t=1000 594003 618093 104 639292 108
create_snapshot_internal/v=1860;t=1000 594409 622494 105 642574 108
create_snapshot_internal/v=1880;t=1000 603758 628600 104 659513 109
create_snapshot_internal/v=1900;t=1000 610615 627157 103 662842 109
create_snapshot_internal/v=1920;t=1000 609493 639443 105 679897 112
create_snapshot_internal/v=1940;t=1000 614097 641990 105 672321 109
create_snapshot_internal/v=1960;t=1000 619227 651946 105 686930 111
create_snapshot_internal/v=1980;t=1000 624038 658601 106 696231 112
create_snapshot_internal/v=2000;t=1000 630605 672549 107 704710 112
create_snapshot_internal/v=2000;t=500 580770 593338 102 636553 110
create_snapshot_internal/v=2000;t=510 577733 601421 104 670751 116
create_snapshot_internal/v=2000;t=520 585552 598193 102 635105 108
create_snapshot_internal/v=2000;t=530 587825 607186 103 643176 109
create_snapshot_internal/v=2000;t=540 586112 608276 104 641241 109
create_snapshot_internal/v=2000;t=550 581297 611329 105 642849 111
create_snapshot_internal/v=2000;t=560 586130 603410 103 656337 112
create_snapshot_internal/v=2000;t=570 586950 610747 104 659661 112
create_snapshot_internal/v=2000;t=580 589329 619572 105 632161 107
create_snapshot_internal/v=2000;t=590 580431 608961 105 643624 111
create_snapshot_internal/v=2000;t=600 584771 610999 104 646981 111
create_snapshot_internal/v=2000;t=610 596231 615348 103 645560 108
create_snapshot_internal/v=2000;t=620 593212 616565 104 654290 110
create_snapshot_internal/v=2000;t=630 593700 613758 103 659582 111
create_snapshot_internal/v=2000;t=640 595703 615166 103 649900 109
create_snapshot_internal/v=2000;t=650 592711 621712 105 662825 112
create_snapshot_internal/v=2000;t=660 596377 624050 105 651078 109
create_snapshot_internal/v=2000;t=670 607994 622300 102 668920 110
create_snapshot_internal/v=2000;t=680 600237 620529 103 668224 111
create_snapshot_internal/v=2000;t=690 601308 623390 104 654198 109
create_snapshot_internal/v=2000;t=700 602129 625426 104 653563 109
create_snapshot_internal/v=2000;t=710 602164 629359 105 671462 112
create_snapshot_internal/v=2000;t=720 603800 630520 104 665886 110
create_snapshot_internal/v=2000;t=730 606258 629109 104 672260 111
create_snapshot_internal/v=2000;t=740 612299 629299 103 662670 108
create_snapshot_internal/v=2000;t=750 609057 623899 102 661839 109
create_snapshot_internal/v=2000;t=760 609511 632055 104 657945 108
create_snapshot_internal/v=2000;t=770 609542 629498 103 664930 109
create_snapshot_internal/v=2000;t=780 610040 632089 104 658645 108
create_snapshot_internal/v=2000;t=790 610658 636819 104 669348 110
create_snapshot_internal/v=2000;t=800 613205 638132 104 681230 111
create_snapshot_internal/v=2000;t=810 610967 636884 104 671324 110
create_snapshot_internal/v=2000;t=820 611324 650102 106 675846 111
create_snapshot_internal/v=2000;t=830 610144 652297 107 678909 111
create_snapshot_internal/v=2000;t=840 611496 645565 106 682480 112
create_snapshot_internal/v=2000;t=850 613091 651158 106 687817 112
create_snapshot_internal/v=2000;t=860 615028 652459 106 677884 110
create_snapshot_internal/v=2000;t=870 614152 659858 107 684781 112
create_snapshot_internal/v=2000;t=880 619839 664198 107 691630 112
create_snapshot_internal/v=2000;t=890 621293 663148 107 697178 112
create_snapshot_internal/v=2000;t=900 622440 658493 106 689107 111
create_snapshot_internal/v=2000;t=910 614160 660552 108 692649 113
create_snapshot_internal/v=2000;t=920 623412 673900 108 685881 110
create_snapshot_internal/v=2000;t=930 621578 670550 108 685114 110
create_snapshot_internal/v=2000;t=940 625764 664827 106 693388 111
create_snapshot_internal/v=2000;t=950 625753 664474 106 703690 112
create_snapshot_internal/v=2000;t=960 628117 663998 106 710056 113
create_snapshot_internal/v=2000;t=970 627313 668223 107 698946 111
create_snapshot_internal/v=2000;t=980 629598 675251 107 707171 112
create_snapshot_internal/v=2000;t=990 634411 671821 106 698623 110

Maybe by accident this generates worse assembly under the async-fuel case?

The case of pallet_contracts/seal_ecdsa_to_eth_address is also interesting since the slowdown seems to be roughly the same in both cases when you look at the averaged figure, but per-component figures are a little weird in places:

Benchmark results
no-fuel vanilla-fuel % async-fuel %
seal_ecdsa_to_eth_address/r=0 346527 613202 177 361416 104
seal_ecdsa_to_eth_address/r=1 2500648 2919978 117 2748091 110
seal_ecdsa_to_eth_address/r=2 4637581 5196763 112 5018118 108
seal_ecdsa_to_eth_address/r=3 6783198 7508295 111 7537177 111
seal_ecdsa_to_eth_address/r=4 8920219 9818008 110 9723682 109
seal_ecdsa_to_eth_address/r=5 11069269 12076484 109 12208006 110
seal_ecdsa_to_eth_address/r=6 13225432 14384832 109 14347723 108
seal_ecdsa_to_eth_address/r=7 15350430 16711006 109 16973529 111
seal_ecdsa_to_eth_address/r=8 17580486 18944993 108 19361411 110
seal_ecdsa_to_eth_address/r=9 19660893 21247436 108 21286694 108
seal_ecdsa_to_eth_address/r=10 21790752 23552554 108 23799967 109
seal_ecdsa_to_eth_address/r=11 23930723 25954704 108 26283628 110
seal_ecdsa_to_eth_address/r=12 26076502 28167070 108 34430313 132
seal_ecdsa_to_eth_address/r=13 28257272 30444349 108 30962461 110
seal_ecdsa_to_eth_address/r=14 30363764 32778091 108 32931357 108
seal_ecdsa_to_eth_address/r=15 32494405 35062738 108 42916530 132
seal_ecdsa_to_eth_address/r=16 34624198 37328262 108 37800990 109
seal_ecdsa_to_eth_address/r=17 36823801 39683584 108 40315828 109
seal_ecdsa_to_eth_address/r=18 38934790 41909613 108 42582035 109
seal_ecdsa_to_eth_address/r=19 41082832 44241935 108 44586320 109
seal_ecdsa_to_eth_address/r=20 43198160 46661256 108 61109163 141

@athei
Copy link
Member

athei commented Jul 11, 2022

I can't explain why pallet_contracts/seal_ecdsa_to_eth_address behaves so weirdly. It is one of the rare occurrences of of in-runtime crypto code:

fn to_eth_address(&self) -> Result<[u8; 20], ()> {
	use k256::{elliptic_curve::sec1::ToEncodedPoint, PublicKey};

	PublicKey::from_sec1_bytes(self.as_slice()).map_err(drop).and_then(|pub_key| {
		// uncompress the key
		let uncompressed = pub_key.to_encoded_point(false);
		// convert to ETH address
		<[u8; 20]>::try_from(
			sp_io::hashing::keccak_256(&uncompressed.as_bytes()[1..])[12..].as_ref(),
		)
		.map_err(drop)
	})
}

The hashing is delegated to the client but k256 is compiled to wasm.

@pepyakin
Copy link
Contributor Author

Maybe by accident this generates worse assembly under the async-fuel case?

Maybe not even by an accident, but one less register available shows?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants