digitalmars.D - LDC with Profile-Guided Optimization (PGO)
- Johan Engelen (44/53) Dec 15 2015 Hi all,
- Johan Engelen (4/11) Dec 22 2015 Would it help if binaries are available?
- CraigDillabaugh (5/18) Dec 22 2015 Maybe many folks reading your post don't know what PGO is?
- Mattcoder (4/5) Dec 22 2015 https://en.m.wikipedia.org/wiki/Profile-guided_optimization
- Mattcoder (3/5) Dec 22 2015 Definitely!
- Johan Engelen (8/13) Jan 05 2016 Sorry for false hope :(. I wouldn't even know where to upload
- Etienne Cimon (7/20) Dec 31 2015 Sorry I don't read the forums often. This is definitely going to
- welkam (3/6) Jan 05 2016 Reducing steps will always help. I am interested, but not to the
Hi all, I have been working on adding profile-guided optimization (PGO) to LDC [1][2][3]. At this point, I'd like to hear your input and hope you can help with testing! Unfortunately, to try it out, you will need to build LDC with LLVM3.7 yourself. PGO should work on OS X, Linux, and Windows. A first implementation is mostly complete now: it can generate an executable that will output profile data, and it can use profile data during a second compilation pass (and it will tell LLVM about branch frequencies). LDC does not do any PGO optimizations (yet): LLVM should do that. It works like PGO with Clang, with the fprofile-instr-generate and fprofile-instr-use cmdline options [4]:ldc2 -fprofile-instr-generate=test.profraw -run test.d llvm-profdata merge test.profraw -output test.profdata ldc2 -profile-instr-use=test.profdata test.d -of=testYou should now have the executable "test" with an amazing performance boost ;-) You can inspect the generated code using LDC's -output-ll switch. Functions should be annotated with call frequencies, and most branches should be annotated with branch_weights metadata. For example:... !12 = !{!"function_entry_count", i64 234}for "void for_loop()" that is called 234 times, andbr i1 %3, label %if, label %else, !prof !17 ... !17 = !{!"branch_weights", i32 5, i32 3}for "if (condition) {...} else {...}" The branch_weights have an offset of 1, so the above means that the condition was true 4 times, and false 2 times. If a certain piece of code is never executed, no metadata is added (i.e. you won't see {!"branch_weights", i32 1, i32 1}). Some branches are intentionally not instrumented/annotated if they lead to terminating code (e.g. array boundschecks and auto-generated nullptr checks on this at class method entry). I hope you will be able to test and comment on the work. I am very interested in hearing about performance gains(/losses/no-change) for your programs. I am curious to learn for what kinds of code it makes a difference in practice. Thanks! Johan (future work will probably include coverage analysis (llvm-cov) and support for sampling-based profiles, which should fit naturally with the current implementation) [1] http://wiki.dlang.org/LDC_LLVM_profiling_instrumentation [2] https://github.com/JohanEngelen/ldc/tree/pgo (warning: I will rebase soon) [3] https://github.com/ldc-developers/ldc/pull/1219 [4] http://clang.llvm.org/docs/UsersManual.html#profiling-with-instrumentation
Dec 15 2015
On Tuesday, 15 December 2015 at 23:05:38 UTC, Johan Engelen wrote:Hi all, I have been working on adding profile-guided optimization (PGO) to LDC [1][2][3]. At this point, I'd like to hear your input and hope you can help with testing! Unfortunately, to try it out, you will need to build LDC with LLVM3.7 yourself. PGO should work on OS X, Linux, and Windows.Would it help if binaries are available? Or is general interest low? -Johan
Dec 22 2015
On Tuesday, 22 December 2015 at 14:49:51 UTC, Johan Engelen wrote:On Tuesday, 15 December 2015 at 23:05:38 UTC, Johan Engelen wrote:Maybe many folks reading your post don't know what PGO is? Perhaps you need to do a bit of a sales job to convince folks that it is pretty cool, and worth trying out. CraigHi all, I have been working on adding profile-guided optimization (PGO) to LDC [1][2][3]. At this point, I'd like to hear your input and hope you can help with testing! Unfortunately, to try it out, you will need to build LDC with LLVM3.7 yourself. PGO should work on OS X, Linux, and Windows.Would it help if binaries are available? Or is general interest low? -Johan
Dec 22 2015
On Tuesday, 22 December 2015 at 17:09:21 UTC, CraigDillabaugh wrote:Maybe many folks reading your post don't know what PGO is?https://en.m.wikipedia.org/wiki/Profile-guided_optimization Matt.
Dec 22 2015
On Tuesday, 22 December 2015 at 14:49:51 UTC, Johan Engelen wrote:On Tuesday, 15 December 2015 at 23:05:38 UTC, Johan Engelen Would it help if binaries are available?Definitely! Matt.
Dec 22 2015
On Tuesday, 22 December 2015 at 17:36:30 UTC, Mattcoder wrote:On Tuesday, 22 December 2015 at 14:49:51 UTC, Johan Engelen wrote:Sorry for false hope :(. I wouldn't even know where to upload them... I hope to have PGO in LDC master soon. It's working, just need some code cleanup. Once merged into master, you can play with it in nightly builds. For windows, successfull builds of master with LLVM3.7 (needed for PGO) are uploaded to github: http://wiki.dlang.org/Latest_pre-built_LDC_for_Win64On Tuesday, 15 December 2015 at 23:05:38 UTC, Johan Engelen Would it help if binaries are available?Definitely!
Jan 05 2016
On Tuesday, 22 December 2015 at 14:49:51 UTC, Johan Engelen wrote:On Tuesday, 15 December 2015 at 23:05:38 UTC, Johan Engelen wrote:Sorry I don't read the forums often. This is definitely going to be a game changer for me, I need PGO to help with Botan performance issues and I'm going to be developing an embedded server on Intel Edison with vibe.d/botan/http2 soon, this compiler could make quite the difference. I'll be testing it one I get my prototype!Hi all, I have been working on adding profile-guided optimization (PGO) to LDC [1][2][3]. At this point, I'd like to hear your input and hope you can help with testing! Unfortunately, to try it out, you will need to build LDC with LLVM3.7 yourself. PGO should work on OS X, Linux, and Windows.Would it help if binaries are available? Or is general interest low? -Johan
Dec 31 2015
On Tuesday, 22 December 2015 at 14:49:51 UTC, Johan Engelen wrote:Would it help if binaries are available? Or is general interest low? -JohanReducing steps will always help. I am interested, but not to the point of figuring out how to compile newest LDC myself.
Jan 05 2016