You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure if this is a bug, or extreme edge behavior of the optimizer so I'm seeking advice here. I have a hash function implemented here. With low runs the cost of executing is roughly doubled. For example, the cost of an addmod operation goes from 22 gas to 52 gas (including assigment to stack).
I understand that low runs indicates to optimize for deployment cost instead of call cost, but is increasing the call cost this much expected behavior? It's not a huge problem because the library will deployed at a global location with the runs value set to 2**32-1, but it may confuse developers that consume the hash function as a package in a development environment.
Environment
Compiler version: 0.7.4, 0.8.4, 0.8.17
Target EVM version (as per compiler settings): Merge
Framework/IDE (e.g. Truffle or Remix): Remix, Hardhat
EVM execution environment / backend / blockchain client: hardhat/remix vm
Operating system: OSX
Steps to Reproduce
I have a repository here reproducing the behavior. Specifically disabling the optimizer cuts the cost of executing the function by 2x (same with increasing runs to 2**32-1).
If you clone this repo run
npm i
npm t
and it will print info about costs. Change the hardhat.config.js file to disable the optimizer and run again and you'll see a different output.
Thanks
The text was updated successfully, but these errors were encountered:
@vimwitch I think this is more of a question/discussion for the language forum. As you noted
[...] low runs indicates to optimize for deployment cost instead of call cost [...]
Your repo uses 200 for the runs parameter, which is very low and thus, in my opinion, would justify the optimizer not caring about the addmod cost.
For example, if you use a value of 2**13 for the runs parameter, then the cost goes to 22.
I am closing this for now, but, please feel free to reply if you think this really is an issue.
Description
I'm not sure if this is a bug, or extreme edge behavior of the optimizer so I'm seeking advice here. I have a hash function implemented here. With low runs the cost of executing is roughly doubled. For example, the cost of an
addmod
operation goes from 22 gas to 52 gas (including assigment to stack).I understand that low runs indicates to optimize for deployment cost instead of call cost, but is increasing the call cost this much expected behavior? It's not a huge problem because the library will deployed at a global location with the runs value set to 2**32-1, but it may confuse developers that consume the hash function as a package in a development environment.
Environment
Steps to Reproduce
I have a repository here reproducing the behavior. Specifically disabling the optimizer cuts the cost of executing the function by 2x (same with increasing runs to 2**32-1).
If you clone this repo run
and it will print info about costs. Change the
hardhat.config.js
file to disable the optimizer and run again and you'll see a different output.Thanks
The text was updated successfully, but these errors were encountered: