<html xmlns:v="urn:schemas-microsoft-com:vml" 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="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@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;}
@font-face
{font-family:"\@宋体";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",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:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Hi Ruijie,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I have a question. How does HotColdSplitting pass differ from PartialInlining pass that can also make use of PGO information? I added support a few years ago
in PartialInlining to outline cold blocks/regions, ensuring only hot/warm regions get inlined into the caller.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Is the difference simply that HotColdSplitting will not inline hot code into the caller? If so, I think there’s some synergy between the two passes and should
consider refactoring so we don’t have duplication. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Graham Yiu<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Compiler Software Engineer<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Toronto Heterogeneous Compiler Lab<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Huawei Technologies Canada<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> llvm-dev [mailto:llvm-dev-bounces@lists.llvm.org]
<b>On Behalf Of </b>Ruijie Fang via llvm-dev<br>
<b>Sent:</b> June-04-20 2:09 PM<br>
<b>To:</b> Snehasish Kumar <snehasishk@google.com><br>
<b>Cc:</b> llvm-dev <llvm-dev@lists.llvm.org>; Sebastian Pop <sebpop@gmail.com>; aditya kumar <hiraditya@gmail.com><br>
<b>Subject:</b> Re: [llvm-dev] Improve hot cold splitting to aggressively outline small blocks<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Hi Snehasish,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I will attempt a reply here, and Aditya can add more on this, as I'm a complete newcomer to PGO.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Yes, I think the objective is that we can take advantage of the PGO information in one way or the other to optimize for performance --- for instance, previous papers [1] [2] on HCS have all taken the profiling-based approach to optimize
for icache misses. The bottom line is PGO certainly provides helpful information on identifying hot functions to optimize, and we would like to account for that information (at least, not cause significant performance regressions).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Ruijie<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">[1]: <a href="http://pages.cs.wisc.edu/~fischer/cs701.f05/code.positioning.pdf">
http://pages.cs.wisc.edu/~fischer/cs701.f05/code.positioning.pdf</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">[2]: <a href="https://www.cs.cmu.edu/afs/cs/academic/class/15745-s07/www/papers/p80-cohn.pdf">
https://www.cs.cmu.edu/afs/cs/academic/class/15745-s07/www/papers/p80-cohn.pdf</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Ruijie Fang<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Email: <a href="mailto:ruijief@princeton.edu" target="_blank">
ruijief@princeton.edu</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Tue, Jun 2, 2020 at 3:45 PM Snehasish Kumar <<a href="mailto:snehasishk@google.com">snehasishk@google.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal">Hi Ruijie, Aditya<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">This is really interesting work! Since you mention that the baseline is a PGO optimized build, can you elaborate on the motivation? Is it because PGO instrumentation leads to additional early stage code changes which may increase the opportunity?
Perhaps Context Sensitive PGO can be useful here (see <a href="https://reviews.llvm.org/D54175" target="_blank">https://reviews.llvm.org/D54175</a>). It introduces an additional round of profiling which should provide more precise information on cold blocks. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Tue, Jun 2, 2020 at 12:30 PM Ruijie Fang <<a href="mailto:ruijief@princeton.edu" target="_blank">ruijief@princeton.edu</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal">Hello Tobias,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thank you for the suggestion! Aditya also mentioned this. I will look into it.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Best regards,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Ruijie<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Ruijie Fang<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Email: <a href="mailto:ruijief@princeton.edu" target="_blank">
ruijief@princeton.edu</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Tue, Jun 2, 2020 at 12:48 PM Tobias Hieta <<a href="mailto:tobias@plexapp.com" target="_blank">tobias@plexapp.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<p class="MsoNormal">Hello Ruijie,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">One other workload that would be interesting to test might be clang itself. Building clang with PGO information is a common trick for improving compiler performance and it's well supported in the build system. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks for working on this. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Tobias. <o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Tue, Jun 2, 2020, 18:16 Ruijie Fang via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal">Hi Teresa,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thank you for your reply! I discussed this with Aditya and Rodrigo today about this. We will always have PGO turned on for our benchmark, (i.e. we assume the profiling information is always available). In terms of the workload we supply
to PGO: For postgresql, I suggested we use the "pgbench" benchmark, a TPC-B-based SQL benchmark for postgres, to supply profiling information for PGO. We can use other workloads/benchmarks should you have any other suggestions about this.
<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thank you,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Ruijie<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Ruijie Fang<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Email: <a href="mailto:ruijief@princeton.edu" target="_blank">
ruijief@princeton.edu</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Mon, Jun 1, 2020 at 11:28 AM Teresa Johnson <<a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Sun, May 31, 2020 at 11:37 PM Ruijie Fang <<a href="mailto:ruijief@princeton.edu" target="_blank">ruijief@princeton.edu</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">Hello,<br>
I am Ruijie Fang, a GSoC student working on "Improve hot cold<br>
splitting to aggressively outline small blocks." Over the course of<br>
last week, I met with my mentor and co-mentor, Aditya Kumar, and<br>
Rodrigo Rocha, and we made a preliminary plan on improving the<br>
existing hot/cold splitting pass in LLVM through identifying patterns<br>
of cold blocks in real-world workloads via block frequency information<br>
(We have settled to use the PostgreSQL codebase as a workload first,<br>
although if time permits, we will also target other large codebases).<br>
<br>
Our project will involve identifying new cold block patterns via<br>
static analysis in our workload, implementing detection of these<br>
patterns into the existing hot/cold splitting pass, and then<br>
benchmarking hot/cold splitting in our workload to see if there are<br>
improvements. Our eventual goal is to improve the ability of hot/cold<br>
analysis to detect cold blocks in these real-world workloads.<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Hi Ruijie,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks for the info!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I skimmed the doc (suggest including it inline in the thread). It wasn't clear to me if the main goal is to improve PGO based HCS or non-PGO based HCS. It sounds like you are going to be focusing on non-PGO based HCS given the comments
about static analysis and detection of throws, asserts etc. A couple of suggestions. I'd focus first on ensuring best performance possible given PGO information (the last time I tried HCS with PGO it wasn't improving performance for one of our large apps).
Second, for the non-PGO case, rather than building in the detection of likely cold blocks into HCS itself, it would be better to drive static generation of some kind of profile metadata for likely cold blocks (a la __builtin_expect). This will be more general
and allow passes other than HCS to benefit.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Teresa<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal"><br>
Our plan is attached at<br>
<a href="https://docs.google.com/document/d/1rGLcFpfVXnF7aS31dWnowd2y_BjJnRA-hj3cUt6MqZ8/edit?usp=sharing" target="_blank">https://docs.google.com/document/d/1rGLcFpfVXnF7aS31dWnowd2y_BjJnRA-hj3cUt6MqZ8/edit?usp=sharing</a>.<br>
<br>
Any feedback, input, or suggestion is welcome and highly appreciated!<br>
<br>
Best regards,<br>
Ruijie<br>
<br>
Ruijie Fang<br>
Email: <a href="mailto:ruijief@princeton.edu" target="_blank">ruijief@princeton.edu</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<div>
<div>
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td nowrap="" style="border:none;border-top:solid #D50F25 1.5pt;padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:#555555">Teresa Johnson |<o:p></o:p></span></p>
</td>
<td nowrap="" style="border:none;border-top:solid #3369E8 1.5pt;padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:#555555"> Software Engineer |<o:p></o:p></span></p>
</td>
<td nowrap="" style="border:none;border-top:solid #009939 1.5pt;padding:0cm 0cm 0cm 0cm">
<p class="MsoNormal"><span style="font-family:"Arial",sans-serif;color:#555555"> <a href="mailto:tejohnson@google.com" target="_blank">tejohnson@google.com</a> |<o:p></o:p></span></p>
</td>
<td nowrap="" style="border:none;border-top:solid #EEB211 1.5pt;padding:0cm 0cm 0cm 0cm">
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal">_______________________________________________<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="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></p>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
</body>
</html>