Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create sanity benchmark checks for all the arithmetic op codes (#1419)
FuelLabs/fuel-core#1386 This PR adds benchmark tests for all the arithmetic op codes. The actual purpose being running those tests to see if the costs actually line up for all the codes. These tests work by starting a vm with a set amount of gas, and running an "infinite" loop of each op code until the vm runs out of gas. This is timed and the time is reported. After running these, I've found a number of divergent op codes that could possibly require updated gas costs: ``` block target estimation/wddv opcode time: [4.0950 ms 4.1181 ms 4.1411 ms] block target estimation/wdmd opcode time: [3.3510 ms 3.3710 ms 3.3931 ms] block target estimation/wdam opcode time: [3.4912 ms 3.5138 ms 3.5363 ms] block target estimation/wdmm opcode time: [3.4505 ms 3.4686 ms 3.4868 ms] block target estimation/wqdv opcode time: [3.2404 ms 3.2590 ms 3.2796 ms] block target estimation/wqmd opcode time: [4.1508 ms 4.1716 ms 4.1928 ms] block target estimation/wqam opcode time: [3.6933 ms 3.7081 ms 3.7230 ms] block target estimation/wqmm opcode time: [5.2120 ms 5.2395 ms 5.2667 ms] ``` So, that's `wddv`, `wdmd`, `wdam`, `wdmm`, `wqdv`, `wqmd`, `wqam`, `wqmm`. Whereas all the other op codes take close to 2ms to run out of gas, implying that these divergent op codes could be priced higher. These "wide" op codes all share similar setup, and not all of the "wide" op codes fail the test, so it's _probably_ not the setup that is causing these specific op code benchmarks to fail. *** Here are all of the results: ``` lock target estimation/add opcode time: [2.1024 ms 2.1142 ms 2.1259 ms] block target estimation/addi opcode time: [2.1066 ms 2.1208 ms 2.1369 ms] block target estimation/aloc opcode time: [1.8966 ms 1.9104 ms 1.9252 ms] block target estimation/and opcode time: [2.0765 ms 2.0877 ms 2.0990 ms] block target estimation/andi opcode time: [2.1647 ms 2.1797 ms 2.1963 ms] block target estimation/div opcode time: [2.1176 ms 2.1303 ms 2.1440 ms] block target estimation/divi opcode time: [2.1445 ms 2.1572 ms 2.1711 ms] block target estimation/eq opcode time: [2.0585 ms 2.0721 ms 2.0859 ms] block target estimation/exp opcode time: [2.0829 ms 2.0931 ms 2.1031 ms] block target estimation/expi opcode time: [2.1114 ms 2.1218 ms 2.1323 ms] block target estimation/gt opcode time: [2.0068 ms 2.0176 ms 2.0287 ms] block target estimation/gtf opcode time: [2.2672 ms 2.2765 ms 2.2859 ms] block target estimation/lt opcode time: [1.9848 ms 1.9959 ms 2.0070 ms] block target estimation/mlog opcode time: [2.0176 ms 2.0278 ms 2.0380 ms] block target estimation/mod opcode time: [1.9694 ms 1.9819 ms 1.9943 ms] block target estimation/modi opcode time: [1.9519 ms 1.9640 ms 1.9760 ms] block target estimation/move opcode time: [1.8479 ms 1.8600 ms 1.8716 ms] block target estimation/movi opcode time: [1.9531 ms 1.9645 ms 1.9758 ms] block target estimation/mroo opcode time: [2.4029 ms 2.4151 ms 2.4272 ms] block target estimation/mul opcode time: [2.0221 ms 2.0335 ms 2.0446 ms] block target estimation/muli opcode time: [1.9674 ms 1.9781 ms 1.9897 ms] block target estimation/noop opcode time: [1.8149 ms 1.8389 ms 1.8631 ms] block target estimation/not opcode time: [1.8706 ms 1.8861 ms 1.9008 ms] block target estimation/or opcode time: [2.0889 ms 2.0994 ms 2.1111 ms] block target estimation/ori opcode time: [2.1002 ms 2.1106 ms 2.1208 ms] block target estimation/sll opcode time: [2.1776 ms 2.1864 ms 2.1956 ms] block target estimation/slli opcode time: [2.0932 ms 2.1038 ms 2.1153 ms] block target estimation/srl opcode time: [2.0355 ms 2.0453 ms 2.0555 ms] block target estimation/srli opcode time: [2.0444 ms 2.0509 ms 2.0578 ms] block target estimation/sub opcode time: [2.1181 ms 2.1269 ms 2.1358 ms] block target estimation/subi opcode time: [1.9773 ms 1.9905 ms 2.0050 ms] block target estimation/xor opcode time: [2.0735 ms 2.0837 ms 2.0937 ms] block target estimation/xori opcode time: [2.0139 ms 2.0246 ms 2.0354 ms] block target estimation/wdcm opcode time: [2.2144 ms 2.2272 ms 2.2406 ms] block target estimation/wdop opcode time: [2.5049 ms 2.5220 ms 2.5395 ms] block target estimation/wdml opcode time: [2.6808 ms 2.6963 ms 2.7130 ms] block target estimation/wddv opcode time: [4.2766 ms 4.3064 ms 4.3368 ms] block target estimation/wdmd opcode time: [3.5144 ms 3.5451 ms 3.5798 ms] block target estimation/wdam opcode time: [3.7095 ms 3.7397 ms 3.7760 ms] block target estimation/wdmm opcode time: [3.6330 ms 3.6595 ms 3.6915 ms] block target estimation/wqcm opcode time: [2.4236 ms 2.4410 ms 2.4597 ms] block target estimation/wqop opcode time: [2.7717 ms 2.7920 ms 2.8154 ms] block target estimation/wqml opcode time: [2.9315 ms 2.9631 ms 2.9986 ms] block target estimation/wqdv opcode time: [3.4322 ms 3.4572 ms 3.4846 ms] block target estimation/wqmd opcode time: [4.4126 ms 4.4383 ms 4.4669 ms] block target estimation/wqam opcode time: [3.8279 ms 3.8610 ms 3.8986 ms] block target estimation/wqmm opcode time: [5.8005 ms 5.8658 ms 5.9469 ms] ``` --------- Co-authored-by: Brandon Vrooman <brandon.vrooman@gmail.com> Co-authored-by: xgreenx <xgreenx9999@gmail.com>
- Loading branch information