Why we should not be using in-memory cache in the runtime (in most cases) #3995
Replies: 3 comments 4 replies
-
To clarify, I am not saying we should deprioritize other tasks like adding diagnostics. However, if it turns out that after switching to Wasmer 1.0 and removing in-memory cache for contract compilation our new |
Beta Was this translation helpful? Give feedback.
-
Related work status:
|
Beta Was this translation helpful? Give feedback.
-
I want to mention a couple things here:
|
Beta Was this translation helpful? Give feedback.
-
Current state
Currently, Contract Runtime team is working on the following changes:
function_call_cost
cannot be larger than the current one, since we cannot be increasing the gas costs on our blockchain, or otherwise we can accidentally break some contracts. Therefore if the new cost turns out to be larger, then we need to work on optimizing loading of Wasm modules until it does not;Also, while we are working on these changes, we have temporary added in-memory cache for contract compilations. This allows us to hide the problem that
function_call_cost
is underestimating the time it takes to load the contract, which leads to the slow-down of block production when we have full blocks.Proposal
Once these changes are implemented we should remove any in-memory cache for compiled contracts. We need to do it because of the two fundamental runtime rules:
5*10^14
/(function_call_cost. send_not_sir+function_call_cost.execution).It seems attractive to increase execution speed of certain contracts by either adding a LRU cache or having some Wasm contracts (like EVM) white-listed to be permanently in cache. This however, does not decrease our fees, and therefore it does not increase TPS. This however unfortunately hides any issues that we might potentially have if we have underestimated the costs of certain operations and assigned fees that are too low. The reason why we have noticed that
function_call_cost
is too low, is because we did not have in-memory cache and it slowed down our network. With in-memory cache the network might not have been slowed down, but it still would've been vulnerable to cold-cache attacks.Beta Was this translation helpful? Give feedback.
All reactions