google / ml-compiler-opt

Infrastructure for Machine Learning Guided Optimization (MLGO) in LLVM.
Apache License 2.0
629 stars 93 forks source link

Oz with flto performance #310

Closed Colibrow closed 1 year ago

Colibrow commented 1 year ago

Hi @mtrofin , I've been away from this project for a long time. How about the current model's performance in Oz+flto situation, more specifically in Android with arm architecture? I recently tried the llvm released model, tested in my demo project with -mllvm,-enable-ml-inliner=release(both in cflags and ldflags) but the output is a little bigger than the one that just added Oz+flto.

mtrofin commented 1 year ago

The current model is the same we published a while ago: trained on x86_64, before any lto. The model is there as reference. Also these models work more based on statistical properties, meaning they learn (during training) which decisions ended up getting a good result, but there is no embedded understanding as to why.

An important role is of the distribution of the values of its features. That is captured during training. If the corpus used at training is representative to your scenario, "stuff works well", if not, less so - basically if things look similar to what it's seen at training, great.

So training your own model should work well for your source code, even as it evolves (unless it drastically changes such that it stops resembling what you trained it on)

Btw, side q, full lto or thinlto? Doesn't change the above, just that we never did full lto (we do thin - there's corpus collection support and everything)