<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 30, 2016 at 4:28 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 Mar 30, 2016, at 4:25 PM, Rui Ueyama via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:</div><br><div><div dir="ltr"><div>On Wed, Mar 30, 2016 at 4:20 PM, Sean Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span> wrote:<br></div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I believe the relocation stuff that Rafael is currently working on will make this a non-issue (it will make relocation application much friendlier for the CPU).</div></blockquote><div><br></div><div>I don't think Rafael's patch would make this a non-issue. He's making scanRelocs to create data, which would reduce the number of calls to the virtual functions, but it wouldn't be reduced to zero.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>However, even in the current scheme, since the target is fixed, all the indirect call sites should be monomorphic and so there shouldn't be much branch-prediction cost (certainly nothing that would cause 1.8% performance delta for the entire link).</div></div></blockquote><div><br></div><div>Agreed. We could template functions that call TargetInfo's member functions for each target to eliminate the virtual function calls.</div></div></div></div></div></blockquote><div><br></div></span><div>Are you measuring with a build of LLD with LTO+PGO (+ICP+WholeDevirtualization...)?</div><div>We have compiler technologies to address these problems, I think we'd better leave it to them when they can handle it.</div></div></div></blockquote><div><br></div><div>I didn't measure it with them, but can it devirtualize these function calls?</div><div><br></div><div>TargetInfo is a class to handle target-specific stuff. We create an instance of its subclass at startup and call its member functions. For each linker invocation, there is only one TargetInfo instantiated, but the types of TargetInfos for two linker invocations are not guaranteed to be the same (if you are cross-linking a binary, it's different from the default.)</div><div><br></div><div>In order to devirtualize that, I think the compiler needs to deduct that we create only one TargetInfo in a program and that will never change once it is created. Is it possible?</div><div><br></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><div>--</div><div> Mehdi</div><span class=""><div><br></div><div><br></div><br><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Notice that 1.8% is smaller than the performance variation from <span style="font-size:12.8px">r263227 which is a very innocuous-looking change but caused </span><span style="font-size:12.8px">~2-3% slowdown for ScyllaDB (see the thread "LLD performance w.r.t. local symbols (and --build-id)").</span><br></div><div><div><br></div><div>-- Sean Silva</div></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Wed, Mar 30, 2016 at 3:39 PM, Rui Ueyama via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">I was wandering how much is the overhead of virtual function calls of TargetInfo member functions. TargetInfo handles platform-specific details, and we have target-specific subclasses of that class. The subclasses override functions defined in TargetInfo.<div><br><div>The TargetInfo member functions are called multiple times for each relocation. So the cost of virtual function calls may be non-neglible. That is a motication to do the following test.<div><br></div><div>As a test, I removed all TargetInfo subclasses except for x86-64, move all code from X86_64TargetInfo to TargetInfo, and remove `virtual` from TargetInfo.</div><div><br></div><div>The original LLD links itself (with debug info) in 7.499 seconds. The de-virtualized version did the same thing in 7.364 seconds. So it can improve it by 1.8%.</div><div><br></div><div>I'm just pointing out that there's room there to improve performance, and I'm not suggesting we do something for this right now. We probably shouldn't do anything for this because the current code is pretty straightforward. But I'd expect that we will eventually want do something for this in future.</div></div></div></div>
<br></div></div>_______________________________________________<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></blockquote></div><br></div>
</blockquote></div><br></div></div>
_______________________________________________<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" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br></div></blockquote></span></div><br></div></blockquote></div><br></div></div>