<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 15, 2016 at 5:34 PM, Mehdi Amini <span dir="ltr"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Jun 15, 2016, at 4:38 PM, Xinliang David Li <<a href="mailto:davidxl@google.com" target="_blank">davidxl@google.com</a>> wrote:</div><br><div><br><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">On Wed, Jun 15, 2016 at 4:11 PM, Mehdi Amini<span> </span></span><span dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><<a href="mailto:mehdi.amini@apple.com" target="_blank">mehdi.amini@apple.com</a>></span><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important"><span> </span></span><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">wrote:</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><blockquote class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="auto"><div><br><br>Sent from my iPhone</div><span><div><br>On Jun 15, 2016, at 3:16 PM, Xinliang David Li <<a href="mailto:davidxl@google.com" target="_blank">davidxl@google.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 15, 2016 at 3:09 PM, Sean Silva<span> </span><span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span><span> </span>wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">silvas added a comment.<br><span><br>In<span> </span><a href="http://reviews.llvm.org/D21405#459242" rel="noreferrer" target="_blank">http://reviews.llvm.org/D21405#459242</a>, @mehdi_amini wrote:<br><br>> I really don't like the fact that the PGO pipeline will be different from the non-PGO pipeline (other than what is required for instrumentations). I wonder what other people will think of that.<br><br><br></span>This was one of my initial concerns too:<span> </span><a href="http://lists.llvm.org/pipermail/llvm-dev/2015-August/089058.html" rel="noreferrer" target="_blank">http://lists.llvm.org/pipermail/llvm-dev/2015-August/089058.html</a><br>Jake and I (actually mostly Jake) did some basic measurements related to this and did not find any significant difference.<br><br>Rong also did some measurements related to this in the initial RFC thread:<span> </span><a href="http://lists.llvm.org/pipermail/llvm-dev/2015-August/089425.html" rel="noreferrer" target="_blank">http://lists.llvm.org/pipermail/llvm-dev/2015-August/089425.html</a><br><br>I agree though: generally speaking, we should avoid running too many passes before instrumentation precisely because they cause divergence between the PGO and non-PGO pipelines</blockquote><div><br></div><div><br></div><div>I agree that we should limit the difference to the minimal required, but keeping two completely different compilation modes (e.g. PGO vs nonPGO, O3 vs O2 etc) pipeline identical should be a non-goal.</div></div></div></div></div></blockquote><div><br></div><div><br></div></span>Can you elaborate? I have a different intuition.</div></blockquote><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">1) Obviously O2 pipeline can be different from O1/O0.</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">2) Even between O2 and O3, different modes  have different design constraints due to differences in user expectations. For instance at O3 we can enable passes (e.g. loop transformations) that may be too expensive for O2</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">3) Passes require instrumentation certainly will have its instrumentation specific transformation pass  + dependent analysis pass + dependent pre/post clean up passes.  IR PGO falls into this category.   An existing example is memory sanitizer. If you compare msan + O2 pipeline vs O2 pipeline, it has additional post-cleanup passes. See addMemorySantiizerPasses</div></div></blockquote><div><br></div></span><div>The fact that O2 and O3 (and O0...) are different is obvious, on the other hand the fact that PGO is not orthogonal isn't to me, especially since it was until now.</div><div><br></div><div>I'm not saying that the improvements that we can get by specializing for PGO are not worth a difference, but that I see any new difference as something undesirable in general. This has a maintenance and validation cost. The existing pipelines (O2/O3, LTO) are already not well documented and validated, and here we're adding more.</div></div></div></blockquote><div><br></div><div><br></div><div>yes, I don't see us in disagreement here actually.  Nothing comes for free, so any change (e.g, diverging pipeline) needs to examined case by case to make sure the benefit outweighs the cost.   When you say "any new difference as something undesirable in general", I guess it means that in general when the default optimization pipeline gets mature, we rarely see pipeline changes able to make any visible performance differences, so it is usually not justifiable -- which I tend to agree.  Here the benefit of this change to PGO users is *huge* and it is not specific to any benchmarks but is almost universally benefiting most of the programs. I also consider the cost of using a few existing mature passes very low (compared with introducing a new pass). It may shake up the latent bugs due to the change, but that is a good thing, not burden.</div><div><br></div><div>Having said that, I agree we need do our diligence to prune the unnecessary passes there.</div><div><br></div><div>thanks,</div><div><br></div><div>David</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-- </div><div>Mehdi</div></font></span><span class=""><div><br></div><div><br></div><div><br></div><br><blockquote type="cite"><div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">thanks,</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">David</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"> </div><blockquote class="gmail_quote" style="font-family:Helvetica;font-size:12px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="auto"><div><br></div><div>Thanks,</div><div><br></div><div>Mehdi</div><span><div><br></div><div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>David</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">. Thankfully Jake and I found that on our games only pre-inlining was needed (running other optimizations before instrumentation did not help significantly for our test cases beyond the benefit of just pre-inlining).<br><br>(note: due to PR27299, a run of simplifycfg after inlining is needed. But this run of simplifycfg doesn't really affect the performance of the instrumented build at all)<br><br><br><a href="http://reviews.llvm.org/D21405" rel="noreferrer" target="_blank">http://reviews.llvm.org/D21405</a></blockquote></div></div></div></div></blockquote></div></span></div></blockquote></div></blockquote></span></div><br></div></blockquote></div><ul><li><br></li></ul></div></div>