<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Sep 2, 2015 at 12:10 PM, Ivan Baev <span dir="ltr"><<a href="mailto:ibaev@codeaurora.org" target="_blank">ibaev@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">> On Tue, Sep 1, 2015 at 7:21 PM, Ivan Baev via llvm-dev <<br>
> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
>> > Date: Tue, 1 Sep 2015 14:21:16 -0700<br>
>> > From: Rong Xu via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>><br>
>> > Cc: llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>>, David Li <<a href="mailto:davidxl@google.com">davidxl@google.com</a>><br>
>> Subject: Re: [llvm-dev] RFC: PGO Late instrumentation for LLVM<br>
>> >>>> *(2) Performance impact of context sensitivity*<br>
>> >>>> LLVM does not use the profile information fully in the back-end<br>
>> optimizations, for instance, inlining does not fully use the profile<br>
counts<br>
>> >>>> -- it only marks hot/cold function attribute based on function<br>
>> entry<br>
>> counts. To evaluate the impact of profile context sensitivity, GCC is<br>
used<br>
>> >>>> in the experiment. Note that GCC PGO improves clang performance a<br>
>> lot<br>
>> more<br>
>> >>>> than clang PGO.<br>
>> >>>> First we summarize the methodology used in the experiment: 0)<br>
build clang with GCC O2 without early inlining and measure<br>
>> clang's<br>
>> >>>> performance. GCC early inlining (einline) is similar to pre-inline<br>
>> used by<br>
>> >>>> late instrumentation.<br>
>> >>>> 1) build clang with GCC O2 with early inlining and measure<br>
performance.<br>
>> >>>> The performance difference of 1) and 0) is denoted as E which<br>
>> measures<br>
>> >>>> the contribution of early inlining.<br>
>> >>>> 2) build clang with GCC O2 + PGO without early inlining.<br>
>> >>>> 3) build clang with GCC O2 + PGO with early inlining.<br>
>> >>>> The performance difference of 3) and 2) is denoted as EC. It<br>
constitutes<br>
>> >>>> roughly two parts a) early inlining contribution b) context<br>
>> sensitive<br>
>> profiling enabled with early inlining.<br>
>> >>>> The contribution of context sensitive profiling can be estimated<br>
by<br>
>> EC<br>
>> >>>> -<br>
>> >>>> E above.<br>
>> -------------------------------------------------------------------------------<br>
Config                        wall_time_for_use  speedup_vs_(0)<br>
>> >>>>  speedup_vs_(1)<br>
>> >>>> (0) base w/o einline             84.946            1.000<br>
>> 0.934<br>
>> >>>> (1) base O2                      79.310            1.071<br>
>> 1.000<br>
>> >>>> (2) profile-arcs w/o einline     63.518            1.337<br>
>> 1.249<br>
>> >>>> (3) profile-arcs                 48.364            1.756<br>
>> 1.640<br>
>> >>>> We see the following:<br>
>> >>>> 1) GCC PGO with early inlining improves clang performance by 64.0%<br>
>> (v.s.<br>
>> >>>> base O2 w/ early inline).<br>
>> >>>> 2) GCC PGO w/o early inlining improves clang performance by 33.7%<br>
>> (v.s.<br>
>> >>>> base O2 w/o early inline).<br>
>> >>>> 3) Early inlining performance contribution is about 7.1%.<br>
>> >>>> 4) Profile context sensitivity contribution is estimated to be<br>
>> 22.2%<br>
>> (i.e. 64.0% -33.7% - 7.1%), which is pretty significant.<br>
>> Rong,<br>
>> Sorry for the late response. Just wanted to clarify my understanding of<br>
data in (2) Performance impact of context sensitivity.<br>
>> On clang as an application:<br>
>> 3) Early inlining contribution is about 7.1%,<br>
> This is the effect of pre-inlining without profile guidance.<br>
>> 2) PGO w/o early inlining contribution is about 33.7%,<br>
>> 4) so the additional combined effect of 2 and 3 is about 22.2%,<br>
correct?<br>
> Not combined effect -- but remaining effect (by excluding 2 and 3)<br>
>> In other words, just avoiding inlining small/simple callees and<br>
updating<br>
>> their profile counts in the call graph by the main inliner - all<br>
through<br>
>> the use of early inlining - improves clang performance by 22.2%.<br>
> Not sure what you mean here. 22% is the estimate of the effect of CS<br>
profile due to clones of profile counters during instrumentation<br>
(through<br>
> pre-inlining). Profile update with inlining always exist including in<br>
2).<br>
<br>
</div></div>If we compare times for:<br>
(2) profile-arcs w/o einline - 63.518 secs, v.s.<br>
(3) profile-arcs - 48.364 secs,<br>
we get about 31.3% improvement due to early inline with PGO.<br>
<br>
If we compare times for:<br>
(0) base w/o einline - 84.946, v.s.<br>
(1) base O2 - 79.310.<br>
we get about 7.1% improvement due to early inline without PGO.<br>
<br>
What can we attribute the difference of 24.2% (31.3 - 7.1) to?<br>
31.3% is the total contribution of early inline with PGO.<br>
Is 24.2% the context-sensitivity part of it, meaning that the profile<br>
counts in the call graph are more precise duing the inlining process,<br>
inlining decisions are better, etc.?<br></blockquote><div><br></div><div>yes -- that is it.</div><div><br></div><div>David</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
Ivan<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
</font></span></blockquote></div><br></div></div>