diem / diem/move

Questions on instruction gas cost

Open
#154 8 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
378
Forks
137
PR merge metrics
No merged PRs in 30d

Description

A few questions around how we chose the gas cost for some of the instructions.
In this table:
https://github.com/diem/move/blob/0747a72af49e7116ae2b54625668d8536ee086d8/language/move-vm/types/src/gas_schedule.rs#L293

1. `MoveTo` writes new data into the storage, while `MoveFrom` removes data from storage. However, `MoveFrom` (459) is significantly more expensive than `MoveTo` (13). Why is `MoveTo` so cheap? What's the rationale behind this choice? Isn't `MoveFrom` considered as data deletion and should be encouraged instead of punished?
2. Why is `MoveFromGeneric` (13) significantly cheaper than `MoveFrom` (459)?
3. Why is `ImmBorrowGlobal` (23) more expensive than `MutBorrowGlobal` (21)? Should mutable borrows be more expensive since we expect mutations?
4. We don't seem to distinguish the cost between global storage accesses and stack memory accesses. For instance, when we compute the cost of `WriteRef`, we don't really look at whether the reference is pointing to the stack or to a global storage. This makes the cost of global storage accesses (both reads and writes) way too cheap than it should be. Is this intentional?
5. When we compute the gas cost for a native function call (https://github.com/diem/move/blob/b4162e11ebcd6e33571f12737120309ab835fdfe/language/move-vm/types/src/natives/function.rs#L114-L117), we are first adding the computation cost and memory cost, and then multiply the sum with the memory size. Shouldn't we only multiple the memory cost with memory size? Is this a bug?

cc @tzakian

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.