argotorg / argotorg/solidity

Improve default optimizer steps sequence in `via-ir`

Open
#14,406 15 comments 0 reactions 0 assignees View on GitHub
must have optimizer performance :racehorse: viair
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

The default optimizer sequence we have at the moment is quite large, and thus causes bloating in compilation times.
```
libsolidity/interface/OptimiserSettings.h
```
```cpp
static char constexpr DefaultYulOptimiserSteps[] =
"dhfoDgvulfnTUtnIf" // None of these can make stack problems worse
"["
"xa[r]EscLM" // Turn into SSA and simplify
"cCTUtTOntnfDIul" // Perform structural simplification
"Lcul" // Simplify again
"Vcul [j]" // Reverse SSA

// should have good "compilability" property here.

"Tpeul" // Run functional expression inliner
"xa[rul]" // Prune a bit more in SSA
"xa[r]cL" // Turn into SSA again and simplify
"gvif" // Run full inliner
"CTUca[r]LSsTFOtfDnca[r]Iulc" // SSA plus simplify
"]"
"jmul[jul] VcTOcul jmul"; // Make source short and pretty
```

The outcome should hopefully be a shorter sequence, that achieves the same level of optimization, while reducing the compile times (in the context of the optimizer pipeline). Special attention should be paid to steps that destroy the SSA form of its input (better suited for optimizing), and thus cause subsequent steps to perform poorly.

Contributor guide

Open the contributing guide

Research direction

Start in libsolidity/interface/OptimiserSettings.h and inspect DefaultYulOptimiserSteps. Compare the existing steps with alternatives that preserve SSA where possible, then measure the optimizer pipeline's compilation time and optimization results. Done means a shorter sequence that achieves the same optimization level while reducing compile times.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
compilers, performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.