<div dir="ltr"><div>These numbers were collected on Rafael's clang-fsds test case (however, I removed -O3 and --gc-sections) with a command like:<br></div><div>```</div><div>sudo perf record --event=cache-misses --call-graph=dwarf -- /home/sean/pg/llvm/release/bin/ld.lld @response.txt -o /tmp/t --no-threads</div><div>```</div><div><br></div><div>And then</div><div>```</div><div>sudo perf report --no-children --sort dso,srcfile<br></div><div>```</div><div><br></div><div>One annoying thing about these numbers from perf is that they don't sum to 100% usually; so just treat the numbers as relative to each other. Overall I'm not very happy with perf. I don't fully trust its output.</div><div>Also, keep in mind that clang-fsds doesn't have debug info, so the heavy string handling costs don't show up in this profile.</div><div><br></div><div><br></div><div><br></div><div>--event=cycles</div><div>This is the perf default and correlates with overall runtime. One interesting thing this shows is that LLD is currently quite bottlenecked on the kernel.</div><div><a href="https://reviews.llvm.org/P7944">https://reviews.llvm.org/P7944</a><br><div><br></div><div>These other metrics are harder to improve. Improving these metrics will require macro-scale optimizations to our data structures and IO. This means that we should be aware of them so that we avoid going into a local minimum of performance.</div><div><br></div><div>--event=cache-misses</div><div>I believe these are L2 misses. getOffset shows up here quite a bit.</div><div>One useful purpose for this metric is that since L2 is core-private (my CPU is an i7-6700HQ, but this will apply to all recent big intel cores), it won't contend with other cores for the L3 cache. So misses here are where cores start to feel each other's presence.</div><div><a href="https://reviews.llvm.org/P7943">https://reviews.llvm.org/P7943</a><br></div><div><br></div></div><div>--event=LLC-load-misses</div><div>These are misses in last level cache (LLC). I.e. times that we have to go to DRAM (SLOOOW).</div><div>The getVA codepath show up strongly and we see the memcpy into the output. We may want to consider a nontemporal memcpy to at least avoid polluting the cache.</div><div>These misses contend on the DRAM bus (although currently it may be underutilized and so adding more parallelism will help to keep it busy, but only up to a point).</div><div><a href="https://reviews.llvm.org/P7947">https://reviews.llvm.org/P7947</a></div><div><br></div><div>--event=dTLB-load-misses</div><div>These are dTLB misses for loads (on my machine, it corresponds to any time that the hardware page table walker kicks in: <a href="https://github.com/torvalds/linux/blob/f92b7604149a55cb601fc0b52911b1e11f0f2514/arch/x86/events/intel/core.c#L434">https://github.com/torvalds/linux/blob/f92b7604149a55cb601fc0b52911b1e11f0f2514/arch/x86/events/intel/core.c#L434</a>).</div><div>Here we also see the getVA codepath (which is basically doing a random lookup into a huge hash table, so it will DTLB miss) and the memcpy into the output.</div><div><a href="https://reviews.llvm.org/P7945">https://reviews.llvm.org/P7945</a><br></div><div><br></div><div>--event=minor-faults</div><div>This metric essentially shows where new pages of memory are touched and have to be either allocated by the kernel or it has to do a page table fixup.</div><div>Here we see the memcpy into the output is a huge part. Also obviously lots of minor faults as malloc allocates memory from the kernel.</div><div><a href="https://reviews.llvm.org/P7946">https://reviews.llvm.org/P7946</a><br></div><div><br></div><div><br></div><div>-- Sean Silva</div></div>