-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce storage cache #3118
Comments
Preliminary analysis shows that a cache hit costs 130 gas, while a cache miss is 355 gas (including the 200 gas to read from storage). Also the implementation above has to consider the special case of "unset" cache entries. |
On a related note, there is an idea from @Arachnid about netting gas costs, which would mean lower cost for storage access when an address is zero by the time a transaction is done. Found it in this thread: ethereum/EIPs#718 (comment). Not sure if it has gotten any traction but seems related. Also linking a related issue about costly writes: #2908 |
This has been implemented on EVM level now. |
Suggested by @puellavulnerata - it might be a good idea to cache storage access in memory.
A simple cache based on a conflict free hash table in memory could already provide a gigantic benefit. Storage read has been changed from 50 to 200 gas since Solidity was designed (actually memory costs were assumed to be much higher at that point, too), so this might be feasile.
Storage reads could be replaced by the following code:
Storage writes have to invalidate the cache. Furthermore, external function calls have to clear the full cache.
The text was updated successfully, but these errors were encountered: