After Monday's release (d46bcb3ddc768b35da8d1d29f85886476f974128), I noticed that our Solidity benchmarks in CI got noticeably worse on a PR that shouldn't have a large impact on gas costs. After noticing this and being puzzled, I opened another PR with similarly minimal changes, and the benchmark had changes on the same order of magnitude. The benchmark below shows the difference (left is the newer commit using the new version of foundry and right is the old benchmark using the old version of foundry):
We've recently improved gas estimation considerably, with the --isolate flagβWill close this for now, but feel free to reopen if there's a still an issue regarding this.
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (68c3663 2024-01-11T00:37:40.946762000Z)
What command(s) is the bug in?
forge test --gas-report
Operating System
Linux
Describe the bug
After Monday's release (d46bcb3ddc768b35da8d1d29f85886476f974128), I noticed that our Solidity benchmarks in CI got noticeably worse on a PR that shouldn't have a large impact on gas costs. After noticing this and being puzzled, I opened another PR with similarly minimal changes, and the benchmark had changes on the same order of magnitude. The benchmark below shows the difference (left is the newer commit using the new version of foundry and right is the old benchmark using the old version of foundry):
Hyperdrive Gas Benchmark
addLiquidity: min
1600
gas1600
gas0%
addLiquidity: avg
66750
gas55098
gas21.1478%
addLiquidity: max
275046
gas232446
gas18.3268%
checkpoint: min
1172
gas1172
gas0%
checkpoint: avg
48038
gas47937
gas0.2107%
checkpoint: max
202123
gas202123
gas0%
closeLong: min
1580
gas1580
gas0%
closeLong: avg
27900
gas26510
gas5.2433%
closeLong: max
147816
gas139624
gas5.8672%
closeShort: min
1549
gas1549
gas0%
closeShort: avg
29995
gas28777
gas4.2325%
closeShort: max
147189
gas144389
gas1.9392%
initialize: min
1538
gas1538
gas0%
initialize: avg
214974
gas181786
gas18.2566%
initialize: max
256760
gas256760
gas0%
openLong: min
1509
gas1509
gas0%
openLong: avg
50165
gas40502
gas23.8581%
openLong: max
185904
gas162207
gas14.6091%
openShort: min
1519
gas1519
gas0%
openShort: avg
47392
gas47335
gas0.1204%
openShort: max
161536
gas161536
gas0%
redeemWithdrawalShares: min
1575
gas1575
gas0%
redeemWithdrawalShares: avg
23340
gas18465
gas26.4013%
redeemWithdrawalShares: max
105958
gas84767
gas24.9991%
removeLiquidity: min
1661
gas1661
gas0%
removeLiquidity: avg
148623
gas118880
gas25.0193%
removeLiquidity: max
323560
gas258848
gas25%