-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Update benchmarks for storage related opcode #1239
Comments
I think only TRO (in the external context) would be optimized here, since CALL and TR must always interact with contract balances. |
Yeah, but in some cases, we interact with the storage only once, in some two times=) We can optimize it to charge per interaction during execution instead of one time at the beginning |
@xgreenx Any ideas how to get a db with fn fill_contract_storage(db: &mut VmDatabase, contract: &ContractId) -> io::Result<()> {
for k in 0u64..100_000_000 {
let mut key = Bytes32::zeroed();
key.as_mut()[..8].copy_from_slice(&k.to_be_bytes());
db.merkle_contract_state_insert(contract, &key, &key)?;
}
Ok(())
} |
Yeah, it is definitely the slowest way of doing that. You can find a If it still takes much time to setup, you can decrease this value to But we need to set up this contract one time and use it in all benchmarks. To remove impact from the RocksDB cache, we can use each iteration random storage key from a pre-defined seed. |
Using I'm not sure if we can simply use 10M values and multiply, since the slowdown might not be linear. In any case, I'm going to change the benchmarks to use 10M values first. |
|
Closes #1239. Closes #1255. --------- Co-authored-by: Green Baneling <[email protected]> Co-authored-by: Brandon Vrooman <[email protected]>
The source: #1230 (review)
Based on the benchmarks from #1230, it is clear that SMT and database with many entries slowdowns storage interaction significantly.
We need to update our benchmarks for opcodes:
SCWQ
,SWW
,SWWQ
,TR
,TRO
,CALL
,SMO
,BURN
,MINT
.These opcodes modify (insert or remove) state/balances and update SMT. The gas cost should include the worst scenario when the contract has
100_000_000
entries in the storage.The opcodes like
CALL
,TR
, andTRO
updates the SMT only in the contract context, so we can optimize the gas charging. But it will make our gas cost model more complex, so it is okay for now to charge more than we need. We can always optimize it later.The text was updated successfully, but these errors were encountered: