Open ekpyron opened 1 year ago
I disabled the CSE optimization and ran the benchmark_diff.py
script which generated the table below.
The relevant section is ir-optimize-evm+yul
. I left the other ones, because they can be useful to compare the impact of the CSE alone without the yul optimizations taking place before, like in ir-optimize-evm-only
.
Unfortunately, the increase in gas cost is significant in some tests, with ens
deployment cost increase standing out at 2.93%
ir-no-optimize
project | bytecode_size | deployment_gas | method_gas |
---|---|---|---|
brink | 0% |
||
colony | 0% |
||
elementfi | 0% |
||
ens | 0% |
||
perpetual-pools | 0% |
-0% |
+0.03% ❌ |
uniswap | 0% |
-0% |
+0% |
yield_liquidator | 0% |
+0% |
0% |
zeppelin |
ir-optimize-evm+yul
project | bytecode_size | deployment_gas | method_gas |
---|---|---|---|
brink | +0.96% ❌ |
||
colony | 0% |
||
elementfi | +1.18% ❌ |
||
ens | +1.05% ❌ |
+2.93% ❌ |
+0.05% ❌ |
perpetual-pools | +0.92% ❌ |
+0.86% ❌ |
+0.09% ❌ |
uniswap | +1.36% ❌ |
+1.28% ❌ |
+1.42% ❌ |
yield_liquidator | +1.1% ❌ |
+1.14% ❌ |
+0.03% ❌ |
zeppelin | +1.62% ❌ |
+1.6% ❌ |
+0.05% ❌ |
ir-optimize-evm-only
project | bytecode_size | deployment_gas | method_gas |
---|---|---|---|
brink | +15.73% ❌ |
||
colony | 0% |
||
elementfi | +9.84% ❌ |
||
ens | +13.43% ❌ |
+11.33% ❌ |
+1.56% ❌ |
perpetual-pools | +11.85% ❌ |
+10.42% ❌ |
+3.62% ❌ |
uniswap | +10.42% ❌ |
+10.29% ❌ |
+9.38% ❌ |
yield_liquidator | +13.24% ❌ |
+12.68% ❌ |
+1.33% ❌ |
zeppelin | +12.54% ❌ |
legacy-no-optimize
project | bytecode_size | deployment_gas | method_gas |
---|---|---|---|
brink | 0% |
||
colony | 0% |
||
elementfi | 0% |
||
ens | 0% |
||
perpetual-pools | 0% |
-0% |
-0.01% ✅ |
uniswap | 0% |
0% |
+0% |
yield_liquidator | 0% |
0% |
+0% |
zeppelin | 0% |
+0% |
-0.04% ✅ |
legacy-optimize-evm+yul
project | bytecode_size | deployment_gas | method_gas |
---|---|---|---|
brink | 0% |
||
colony | 0% |
||
elementfi | 0% |
||
ens | 0% |
0% |
0% |
perpetual-pools | 0% |
+0% |
+0.01% ❌ |
uniswap | 0% |
-0% |
-0% |
yield_liquidator | 0% |
+0% |
0% |
zeppelin | 0% |
-0% |
+0.17% ❌ |
legacy-optimize-evm-only
project | bytecode_size | deployment_gas | method_gas |
---|---|---|---|
brink | 0% |
||
colony | 0% |
||
elementfi | 0% |
||
ens | 0% |
+0% |
0% |
perpetual-pools | 0% |
+0% |
-0.02% ✅ |
uniswap | 0% |
-0% |
+0% |
yield_liquidator | 0% |
-0% |
+0% |
zeppelin | 0% |
-0% |
+0.06% ❌ |
!V
= version mismatch
!B
= no value in the "before" version
!A
= no value in the "after" version
!T
= one or both values were not numeric and could not be compared
-0
= very small negative value rounded to zero
+0
= very small positive value rounded to zero
This is the output of gas_diff.py
.
We're currently running the full libevmasm optimizer after the Yul optimizer, including complex parts like
libevmasm
'sCommonSubexpressionEliminator
.There is multiple reasons for this being suboptimal:
However, disabling the libevmasm CSE currently still induces gas and/or code size regressions. Conversely, libevmasm CSE can also apparently actually hurt gas costs. The range seems to be around +/- 1% runtime gas or deployment cost.
So what we should do is: