Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Optimize gas charges #55

Open
vaivaswatha opened this issue Oct 6, 2020 · 2 comments
Open

Optimize gas charges #55

vaivaswatha opened this issue Oct 6, 2020 · 2 comments
Labels
gas optimization code optimization - run time improvements

Comments

@vaivaswatha
Copy link
Contributor

With #39 , we'll have gas_charge AST nodes, explicitly charging gas. Each such charge leads to a computation (comparison, conditional branch and a subtraction) at the LLVM-IR level (#54). However, these charges can potentially be combined into a single computation. For example, expressions leading to a straight line sequence (until a branch) with all static charges can be combined into one static charge.

Such opportunities to combine gas charges must be explored and optimized.

@vaivaswatha vaivaswatha added the optimization code optimization - run time improvements label Oct 6, 2020
@vaivaswatha vaivaswatha added the gas label Jan 4, 2021
@vaivaswatha
Copy link
Contributor Author

Another pattern to look for: When computing SizeOf a literal, if the literal's type guarantees a size statically, then replace that. This can help DCE do better. (such as eliminate dead loads since the only reason not-to is not knowing how much to charge).

@vaivaswatha
Copy link
Contributor Author

With #87, more thought is needed on performing this optimization. For example:

gas_charge 10
let a = builtin div x y in
gas_charge 20
...

Cannot be replaced by a leading gas_charge 30 because a possible exception at the div will then impact the "gas remaining" (i.e., it'll be different than if the interpreter executed the code).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
gas optimization code optimization - run time improvements
Projects
None yet
Development

No branches or pull requests

1 participant