Improve compilation speed
Here is an overview of the compilation times for EBR for the different phases when compiled with -runcompiletimefunctions -stacktraces -inline -localOptimizations -measure.
parse files: 5592ms
Typecheck program: 6296ms
Translate program to Im: 1347ms
to intermediate lang: 1347ms
Run compiletime functions: 1180ms
Transform program to Jass: 46558ms
translate classes: 409ms
add stack traces: 12706ms
inlining: 1025ms
inline functions: 987ms
eliminate tuples: 1197ms
remove func refs: 14ms
remove cyclic functions: 1228ms
flatten: 190ms
local optimizations: 29150ms
Constant and Copy Propagated: 1295ms
Useless function calls removed: 592ms
Globals Inlined: 417ms
Branches merged: 7114ms
Simple Rewrites: 2668ms
Temp variables merged: 2981ms
Local variables merged: 12214ms
null setting: 281ms
translate to jass: 256ms
Print Jass: 104ms
Run PJass: 708ms
It looks like "add stack traces" , " Local variables merged", "Temp variables merged", "Branches merged" would be good targets to make faster.
I think it would be nice if we could setup a test suite of some wurst resources (stdlib, fdef. ebr. itt) and then let jenkins compile it with master and the opt-branch so we can directly see and validate changes made.
Current state:
parse files: 5324ms
Typecheck program: 7020ms
Translate program to Im: 1585ms
to intermediate lang: 1585ms
Run compiletime functions: 1232ms
Transform program to Jass: 25817ms
Eliminate generics: 152ms
translate classes: 314ms
add stack traces: 504ms
inlining: 1307ms
eliminate tuples: 506ms
remove func refs: 18ms
remove cyclic functions: 318ms
flatten: 68ms
local optimizations: 22105ms
Constant and Copy Propagated: 1221ms
Useless function calls removed: 738ms
Globals Inlined: 352ms
Branches merged: 303ms
Simple Rewrites: 1441ms
Temp variables merged: 2162ms
Local variables merged: 14466ms
null setting: 226ms
translate to jass: 286ms
Print Jass: 147ms
Run PJass: 179ms
Probably also helped that some debug checks are disabled by default now.
should display sum after the value so we can see where the times differ. Typecheck seems to take 1000ms longer almost e.g. I will run this also and post results.
Snowball Fight old:
#############################
Run times:
parse files: 1767ms
Typecheck program: 2654ms
Translate program to Im: 804ms
to intermediate lang: 804ms
Run compiletime functions: 1076ms
Transform program to Jass: 4971ms
Eliminate generics: 82ms
translate classes: 223ms
add stack traces: 267ms
inlining: 361ms
eliminate tuples: 135ms
remove func refs: 8ms
remove cyclic functions: 80ms
flatten: 18ms
local optimizations: 3665ms
Constant and Copy Propagated: 232ms
Useless function calls removed: 134ms
Globals Inlined: 101ms
Branches merged: 44ms
Simple Rewrites: 284ms
Temp variables merged: 388ms
Local variables merged: 2142ms
null setting: 46ms
translate to jass: 76ms
Print Jass: 59ms
Run PJass: 258ms
new:
#############################
Run times:
parse files: 1776ms
Typecheck program: 2588ms
Translate program to Im: 865ms
to intermediate lang: 865ms
Run compiletime functions: 971ms
Transform program to Jass: 5076ms
Eliminate generics: 87ms
translate classes: 254ms
add stack traces: 244ms
inlining: 360ms
eliminate tuples: 130ms
remove func refs: 9ms
remove cyclic functions: 75ms
flatten: 19ms
local optimizations: 3760ms
Constant and Copy Propagated: 243ms
Useless function calls removed: 135ms
Globals Inlined: 100ms
Branches merged: 49ms
Simple Rewrites: 312ms
Temp variables merged: 403ms
Local variables merged: 2129ms
null setting: 48ms
translate to jass: 82ms
Print Jass: 76ms
Run PJass: 263ms
I think the JVM would need to be warmed up and have enough heap to not cause any garbage collection during build to produce useful results.
Right now without opimizations I get heavy fluctuations of up to 1000ms in most tasks, e.g. Transform program to Jass and Run compiletime functions (900 vs 1600).
Several performance improvements have been done, builds are now much faster. If you still have specific performance bottlenecks open a separate ticket with measurements and reproduction map/project.