<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Sep 4, 2015 at 11:03 PM, Sean Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></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"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Fri, Sep 4, 2015 at 10:11 PM, Xinliang David Li <span dir="ltr"><<a href="mailto:davidxl@google.com" target="_blank">davidxl@google.com</a>></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"><div><div>On Fri, Sep 4, 2015 at 9:11 PM, Sean Silva <<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>> wrote:<br>
><br>
><br>
> On Fri, Sep 4, 2015 at 5:42 PM, Xinliang David Li <<a href="mailto:davidxl@google.com" target="_blank">davidxl@google.com</a>><br>
> wrote:<br>
>><br>
>> On Fri, Sep 4, 2015 at 5:21 PM, Sean Silva <<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>> wrote:<br>
>> ><br>
>> ><br>
>> > On Fri, Sep 4, 2015 at 3:57 PM, Xinliang David Li <<a href="mailto:davidxl@google.com" target="_blank">davidxl@google.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >> ><br>
>> >> > I think it is reasonable to simply replace the key we currently use<br>
>> >> > with<br>
>> >> > MD5(key) for getting a size reduction.  In practice for my use cases,<br>
>> >> > I<br>
>> >> > have<br>
>> >> > not observed any of the issues you mentioned under "Large size of<br>
>> >> > overhead<br>
>> >> > can limit the usability of PGO greatly", but I can understand that<br>
>> >> > some<br>
>> >> > of<br>
>> >> > these issues could become problems in Google's use case. I would<br>
>> >> > personally<br>
>> >> > prefer to keep the existing behavior as the default (see below), and<br>
>> >> > have<br>
>> >> > MD5(key) as an option.<br>
>> >><br>
>> >> The problem is that this requires profile format changes.<br>
>> ><br>
>> ><br>
>> > Why? AFAIK the "function name" is just an arbitrary string. Using s or<br>
>> > MD5(s) shouldn't matter. Of course, the user will need to pass<br>
>> > consistent<br>
>> > flags to clang.<br>
>><br>
>> The raw format for 64bit target can be made 'unchanged', but not for<br>
>> the 32bit raw format -- the nameptr field is only 32bit.<br>
>><br>
>> The indexed format can not be made the same --  The ondisk profile<br>
>> record layout totally changes. The key field changes from a blob of<br>
>> chars into an 64bit integer.<br>
><br>
><br>
> An MD5 sum cannot be represented as a blob of chars?<br>
<br>
</div></div>yes -- it is fixed length (8byte) blob which may include null byte in<br>
the middle.<br></blockquote><div><br></div></div></div><div>For reference, MD5 sum is 16 bytes (128-bit): <a href="https://en.wikipedia.org/wiki/MD5" target="_blank">https://en.wikipedia.org/wiki/MD5</a></div><span class=""><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">
<span><br>
><br>
> Or to say it another way, suppose that Itanium mangling required as a final<br>
> step to replace the string with its md5 sum in hex. Therefore all symbol<br>
> names are "small". My understanding is that this is effectively all your<br>
> patch is doing.<br>
<br>
</span>The key type before the change is StringRef, while the after the key<br>
type is uint64_t. Are you suggesting treating uint64_t md5 sum key as<br>
a string of 8 bytes or storing md5 has in text form which will double<br>
the size?<br></blockquote><div><br></div></span><div>How much does this change the benefit? If most of the benefit is avoiding extraordinarily long mangled names then it may be sufficient.</div><div><br></div><div>With IR-level instrumentation like Rong is pursuing the size may be reduced sufficiently that we do not need the optimization proposed in this thread. For example, Rong found >2x size reduction</div></div></div></div></blockquote><div><br></div><div>To clarify, I mean the size of the PGO data, not the binary size. Column (2) in section 3.5 of Rong's RFC to be precise.</div><div><br></div><div>-- Sean Silva</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"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> on Google's C++ benchmarks, which I assume are representative of the extremely large Google binaries that are causing the problems addressed by your proposal in this thread. The measurements you mention for Clang in this thread provide similar size reductions, so Rong's approach may be sufficient (especially because functions with extremely large mangled names tend to be small inline functions in header-only template libraries).</div><div><br></div><div>Of the points you mention in "Large size of overhead can limit the usability of PGO greatly", many of the issues are hard limits that prevent the use of PGO. Do you have a lower bound on how much the size of the PGO data must be reduced in order to overcome the hard limits?</div><div><br></div><div>Obviously LLVM must be able to support the extremely large binaries in your configuration (otherwise what use is LLVM as a compiler ;) My questions are primarily aimed at establishing which tradeoffs are acceptable for supporting this (both for LLVM and for you guys).</div><div><br></div><div>Btw, for us, the issue of PGO data size is not completely immaterial but is very different from your use case. For us, the primary issue is the additional memory use at run time, since PS4 games usually use "all" available memory. We had a problem with UBSan where the large amount of memory required for storing the UBSan diagnostic data at runtime required the game programmers to manually change their memory map to make room. +Filipe, do you remember how much memory UBSan was using that caused a problem?</div><span class=""><font color="#888888"><div><br></div><div>-- Sean Silva</div></font></span><div><div class="h5"><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">
<br>
In the raw format, md5 sum key can be an embedded field in the<br>
prf_data variable instead of as different var referenced by prf_data.<br>
<span><br>
><br>
> If this is not the case, you should show your current patch so that we can<br>
> discuss things concretely.<br>
<br>
</span>It is not. See above about the difference.<br>
<div><div><br>
><br>
>><br>
>> ><br>
>> ><br>
>> >><br>
>> >> It will be<br>
>> >> very messy to support multiple formats in instr-codegen and<br>
>> >> instr-runtime.  For compatibility concerns, the reader is taught to<br>
>> >> support previous format, but the changes there are isolated (also<br>
>> >> expected to be removed in the future).<br>
>> >><br>
>> >> ><br>
>> >> > My primary concern is that if the function name are not kept at all<br>
>> >> > stages,<br>
>> >> > then it becomes difficult to analyze the profile data in a standalone<br>
>> >> > way.<br>
>> >> > Many times, I have used `llvm-profdata show -all-functions<br>
>> >> > foo.profdata`<br>
>> >> > on<br>
>> >> > the resulting profile data and then imported that data into<br>
>> >> > Mathematica<br>
>> >> > for<br>
>> >> > analysis.<br>
>> >><br>
>> >> This is certainly a very valid use case.<br>
>> >><br>
>> >> >My understanding of your proposal is that `llvm-profdata show<br>
>> >> > -all-functions foo.profdata` will not show the actual function names<br>
>> >> > but<br>
>> >> > instead MD5 hashes,<br>
>> >><br>
>> >> Yes.<br>
>> >><br>
>> >> To support your use case, there are two solutions:<br>
>> >><br>
>> >> 1) user can add -fcoverage-mapping option in the build<br>
>> >> 2) introduce a new option -fprofile-instr-names that force the<br>
>> >> emission of the name sections in the .o file. This is similar to 1),<br>
>> >> but no covmap section is needed.<br>
>> >><br>
>> >> llvm-profdata tool  will be taught to read the name section and attach<br>
>> >> function names to the profile records.<br>
>> ><br>
>> ><br>
>> > Needing to pass the executable to llvm-profdata would cause deployment<br>
>> > issues for my customers in practice.<br>
>><br>
>> Why? The deployment needs to pass the profile data anyway right?<br>
><br>
><br>
> Yes, but not the executable.<br>
><br>
> The PGO training run is likely being run by a gameplay tester<br>
> (non-programmer). In general the binary will not be lying around as a loose<br>
> file anywhere, it will be part of a full package of the binary+assets (think<br>
> like what will end up on a bluray disc). A game's binary *completely<br>
> useless* without the assets, so except locally on a programmer's machine<br>
> while they iterate/debug, there is no reason for a binary to ever exist as a<br>
> standalone file.<br>
><br>
> I'm not saying that needing the binary is insurmountable in any particular<br>
> scenario. Just that it will cause a strict increase in the number of issues<br>
> to deploying PGO.<br>
<br>
</div></div> Your concern is acknowledged.<br>
<span><br>
><br>
> These are much bigger "compatibility concerns" for me than for newer<br>
> toolchains to accept the old format. For a change in format I can easily<br>
> tell my users to replace an exe with a newer one and that is all they need<br>
> to do and it takes 10 seconds, guaranteed. A workflow change is potentially<br>
> a massive disruption and guaranteed to take more than 10 seconds to fix<br>
> (perhaps hours or days).<br>
<br>
</span>ok.<br>
<span><br>
><br>
><br>
>><br>
>>   This<br>
>> is no different from llvm-cov usage model.<br>
><br>
><br>
> In practice, getting the performance of PGO is a higher priority for my<br>
> users, so we should not assume that llvm-cov is being used.<br>
<br>
</span>Glad to hear that :)<br>
<br>
thanks,<br>
<br>
David<br>
<div><div><br>
><br>
> -- Sean Silva<br>
><br>
>><br>
>><br>
>> David<br>
>><br>
>><br>
>><br>
>> ><br>
>> >><br>
>> >><br>
>> >> Note that with 1) or 2), the user can still benefit from the reduced<br>
>> >> profile size.<br>
>> ><br>
>> ><br>
>> > Let me reiterate that the size of the profile is not a problem I have<br>
>> > observed in practice (nor have I heard of this being a problem in<br>
>> > practice<br>
>> > until this thread). Therefore I'm skeptical of any changes to our<br>
>> > default<br>
>> > behavior or any new requirements that are not opt-in.<br>
>> ><br>
>> > -- Sean Silva<br>
>> ><br>
>> >><br>
>> >><br>
>> >> thanks,<br>
>> >><br>
>> >> David<br>
>> >><br>
>> >><br>
>> >><br>
>> >><br>
>> >> >which will make it more difficult for me to do this kind<br>
>> >> > of analysis (would require using nm on the original binary, hashing<br>
>> >> > everything, etc.).<br>
>> >> ><br>
>> >> > btw, feel free to attach the patch even if it in a rough state. It<br>
>> >> > can<br>
>> >> > still<br>
>> >> > help to clarify the proposal and be a good talking point.<br>
>> >> > Fine-grained<br>
>> >> > patch<br>
>> >> > review for caring about the rough parts will happen on llvm-commits;<br>
>> >> > the<br>
>> >> > rough parts will not distract the discussion here on llvm-dev.<br>
>> >> ><br>
>> >> > -- Sean Silva<br>
>> >> ><br>
>> >> >><br>
>> >> >><br>
>> >> >> thanks,<br>
>> >> >><br>
>> >> >> David<br>
>> >> >> _______________________________________________<br>
>> >> >> LLVM Developers mailing list<br>
>> >> >> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>> >> >> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
>> >> ><br>
>> >> ><br>
>> ><br>
>> ><br>
><br>
><br>
</div></div></blockquote></div></div></div><br></div></div>
</blockquote></div><br></div></div>