<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Oct 21, 2016 at 11:17 AM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thank you for the update. It's interesting.<div><br></div><div>I think clang is too small to use as a test for the feature. It can easily fit in in-memory cache, so the accesses to the file won't actually go to the disks. Even if it hits a disk, it's still probably too small. You want to test it with a latency-sensitive (i.e. user-facing) huge apps, such as Firefox or Chromium.</div><div><br></div><div>Do you have an SSD to test this feature? I think we are interested in performance numbers on SSDs.</div></div></blockquote><div><br></div><div>Correction. I talked about this with Sriraman offline. He said that a mechanism to reorder sections is useful to reduce TLB misses because we could layout hot functions close to each other. It doesn't have to be --section-ordering-file, but it seems that we need some mechanism to reorder sections even on all-SSD systems.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5"><div class="gmail_extra"><div class="gmail_quote">On Fri, Oct 21, 2016 at 9:12 AM, George Rimar <span dir="ltr"><<a href="mailto:grimar@accesssoftek.com" target="_blank">grimar@accesssoftek.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">grimar added a comment.<br>
<br>
Short update: I was able to use gcc to extract section ordering files. For start I generated order list for clang launch without any arguments.<br>
I used gcc from svn://<a href="http://gcc.gnu.org/svn/gcc/branches/google/gcc-4_9" rel="noreferrer" target="_blank">gcc.gnu.org/svn/gcc/bran<wbr>ches/google/gcc-4_9</a>.<br>
For doing these next steps were performed:<br>
<br>
1. Build llvm with:<br>
<br>
-DCMAKE_BUILD_TYPE=Release -DLLVM_PARALLEL_COMPILE_JOBS=8 -DLLVM_ENABLE_THREADS=true -DCMAKE_CXX_FLAGS="-fPIC -std=c++11 -ffunction-sections -fdata-sections -fprofile-generate=/home/umb/L<wbr>LVM/gcda" -DCMAKE_C_FLAGS="-fPIC -ffunction-sections -fdata-sections -fprofile-generate=/home/umb/L<wbr>LVM/gcda" -DCMAKE_C_COMPILER=/home/umb/g<wbr>cc49google/bin/gcc -DCMAKE_CXX_COMPILER=/home/umb<wbr>/gcc49google/bin/g++<br>
<br>
2. Run binary in the way we are interested in. It was ./clang w/o arguments in my case (.gcda files should be produced after that).<br>
<br>
3. Now rebuild llvm with -fprofile-use and use of .gcda files we obtained earlier. Use gold linker.<br>
<br>
-DCMAKE_BUILD_TYPE=Release -DLLVM_PARALLEL_COMPILE_JOBS=8 -DLLVM_ENABLE_THREADS=true -DCMAKE_CXX_FLAGS="-B/usr/loca<wbr>l/bin -fPIC -std=c++11 -ffunction-sections -fdata-sections -fprofile-dir=/home/umb/LLVM/g<wbr>cda -fprofile-use -freorder-functions=callgraph -Wl,--plugin-opt,file=/home/um<wbr>b/LLVM/order.txt" -DCMAKE_C_FLAGS="-B/usr/local/<wbr>bin -fPIC -ffunction-sections -fdata-sections -fprofile-dir=/home/umb/LLVM/g<wbr>cda -fprofile-use -freorder-functions=callgraph -Wl,--plugin-opt,file=/home/um<wbr>b/LLVM/order.txt" -DCMAKE_C_COMPILER=/home/umb/g<wbr>cc49google/bin/gcc -DCMAKE_CXX_COMPILER=/home/umb<wbr>/gcc49google/bin/g++<br>
<br>
4. Remove order.txt and relink clang, that will create order.txt containing sections order for its executable.<br>
<br>
I shared it here: <a href="https://drive.google.com/file/d/0B_OWr6ld9gUmd1hnV1k4Z25NQVk/view?usp=sharing" rel="noreferrer" target="_blank">https://drive.google.com/file/<wbr>d/0B_OWr6ld9gUmd1hnV1k4Z25NQVk<wbr>/view?usp=sharing</a><br>
It is 18 megabytes in size.<br>
<br>
Order list file contains next sections:<br>
.text.unlikely.*<br>
.text.exit.*<br>
.text.startup.*<br>
.text.hot.*<br>
<br>
BTW, both gold and ld recognize suzh sections by name and use names as hint for sorting (no matter was order file used or not).<br>
I did not check how it works, but that is what I saw in bfd/gold source code.<br>
Do we want to implement the same for compatibility ?<br>
<br>
Finally, now when I have such file I am going to write a tool or script to prepare it to be used as linker input ordering file (looks it contains excessive data, I'll check) and run some tests.<br>
First one will be estimate clang launch time with sections ordered and without. I am thinking about other possible ones, may be compile simple helloworld ?<br>
<br>
<br>
<a href="https://reviews.llvm.org/D25766" rel="noreferrer" target="_blank">https://reviews.llvm.org/D2576<wbr>6</a><br>
<br>
<br>
<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>