<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Title" content="">
<meta name="Keywords" content="">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.msoIns
        {mso-style-type:export-only;
        mso-style-name:"";
        text-decoration:underline;
        color:teal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">I can try to get some more measurements. How is LLD performance generally evaluated? Do you use any particular profiling tools? (I'm running my link on Linux.)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">Rui Ueyama <ruiu@google.com><br>
<b>Date: </b>Tuesday, September 12, 2017 at 5:39 PM<br>
<b>To: </b>Shoaib Meenai <smeenai@fb.com><br>
<b>Cc: </b>Rafael Avila de Espindola <rafael.espindola@gmail.com>, Dmitry Mikulin <dmitry.mikulin@sony.com>, "llvm-commits@lists.llvm.org" <llvm-commits@lists.llvm.org><br>
<b>Subject: </b>Re: [lld] r312796 - Currently lld creates a single section to collect all commons. There is no way<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">Yeah, benchmark is tricky. If your CPU is cold at beginning, the first few runs could be faster than the following runs of the same program because of Intel Turbo Boost, for example.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">If there's still 2% difference, I'd like to know if it's caused by this patch. I didn't expect that this patch would slow down the linker by a few percent. I believe this patch is negligible in terms of linker performance, unless your program
 is using tons of common symbols.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Tue, Sep 12, 2017 at 5:30 PM, Shoaib Meenai <<a href="mailto:smeenai@fb.com" target="_blank">smeenai@fb.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">I can't reproduce the slowdown anymore :( I'm measuring by running the link in<br>
question 16 times with `time` and taking the average of the total time<br>
reported. Yesterday, I was consistently seeing the 20% slowdown I mentioned.<br>
Today that difference has dropped to 2%. Perhaps my runs yesterday got unlucky<br>
with CPU load from other processes or something similar.<br>
<br>
Sorry for the false alarm. I'll still try to switch my library to using<br>
-fno-common though, just for general cleanliness. Thanks for all the replies!<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
On 9/12/17, 2:51 PM, "Rafael Avila de Espindola" <<a href="mailto:rafael.espindola@gmail.com">rafael.espindola@gmail.com</a>> wrote:<br>
<br>
    Shoaib Meenai <<a href="mailto:smeenai@fb.com">smeenai@fb.com</a>> writes:<br>
<br>
    > It's written in C, and it has 325 common symbols.<br>
    ><br>
    > I only read up on common symbols today, so please correct me if my<br>
    > understanding is off. From what I've read, you'll end up with a common symbol<br>
    > in your object file if you have an uninitialized non-static global variable,<br>
    > e.g. (in the global scope):<br>
    ><br>
    > int x;<br>
    ><br>
    > If you mark the variable static, or if you explicitly zero-initialize it,<br>
    > it'll end up in bss instead of COMMON. You can also use -fno-common to force<br>
    > the use of bss, and C++ does so by default.<br>
    ><br>
    > I understand that COMMON symbols were originally devised to deal with people<br>
    > writing `int x` instead of `extern int x` in headers. My library doesn't have<br>
    > that problem; the `int x` form is used only in source files, and the intent is<br>
    > to define a variable and have it be automatically zero-initialized. I was<br>
    > hoping that if a variable was preceded by an extern declaration, e.g.<br>
    ><br>
    > extern int x;<br>
    > ...<br>
    > int x;<br>
    ><br>
    > the compiler would place it in bss instead of COMMON, but that doesn't appear<br>
    > to be the case.<br>
    ><br>
    > I'll try compiling my sources with -fno-common. This definitely seems like<br>
    > something a lot of libraries could run into though, since it looks like all<br>
    > you need to trigger it is an uninitialized global variable.<br>
<br>
    Your understanding is correct. As Rui points out, allocating 325<br>
    sections cannot be directly slowing down lld so much.<br>
<br>
    My first guess would be that by making DefinedCommon larger the patch<br>
    could have increased the size of Symbol, but that was not the case since<br>
    SharedSymbol was still bigger.<br>
<br>
    How stable is the benchmark across lld versions? What time do you get<br>
    with top of tree?<br>
<br>
    Cheers,<br>
    Rafael<br>
<br>
<o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>