<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Jun 3, 2016 at 9:24 PM, Vedant Kumar <span dir="ltr"><<a href="mailto:vsk@apple.com" target="_blank">vsk@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">vsk added a comment.<br>
<br>
In <a href="http://reviews.llvm.org/D20993#449092" rel="noreferrer" target="_blank">http://reviews.llvm.org/D20993#449092</a>, @MatzeB wrote:<br>
<br>
> This adds a bigger bunch of code to lit, I wonder if it is necessary:<br>
><br>
> - I assume the necessity for the logic inside lit is just the fact that the profile data overwrites each other after running a command. Is setting LLVM_PROFILE_FILE with a '%p' placeholder not enough to avoid this?<br>
<br>
<br>
Using PID substitution gets close to solving the problem of having overwritten profiles, but not all the way. On 32-bit systems PID wraparound would pose a real problem. In this patch I include the hash of the test command to minimize loss of profiles.<br>
<br>
> The final profile data merging can always be done outside of llvm-lit afterwards.<br>
<br>
<br>
On a practical level, I don't think this is possible. Raw profiles are too large. Turning off the cleanup step and running check-llvm produces over half a terrabyte of data. There are a few ways to address this without touching lit:<br>
<br>
1. Reduce the size of raw profiles. This would make the compiler runtime larger and more complex.<br>
2. Run a monitor process that does the merging/cleanup. I don't think that approach has any advantages compared to modifying lit.<br>
<br>
Alternatively, we could do in-place raw profile merging in the compiler runtime. I don't think that's preferable because we'd have to introduce a lot of complexity to compiler-rt (e.g portable mandatory file locking).<br>
<br></blockquote><div><br></div><div>Portable file locking should not be a concern. Most unix like platforms support file locking with fcntl. On Windows, createFile API can be used.</div><div><br></div><div>The RFC about this a while ago has lots of performance data on various types of file systems.  There will be other legit use cases for in-process merging support as well.</div><div><br></div><div>David</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
> Or are there other reasons why you need to intercept the opt/llc/etc. calls?<br>
<br>
<br>
Intercepting the calls makes it possible to generate 'unique' hashes for the profiles, see my comment above.<br>
<br>
> - The lit tests don't strike me as the most typical llvm usage (they are often designed to test corner cases of the compiler), wouldn't it be better to gather profiles by compiling the llvm test-suite or something similar?<br>
<br>
<br>
It's true that the profiles gathered from check-llvm aren't ideal for PGO. But, they are perfect for measuring code coverage of the llvm codebase. Moreover because lit is portable, other projects can use these changes to gather coverage reports with their tests.<br>
<br>
(IIRC the test-suite also uses lit?)<br>
<br>
<br>
<a href="http://reviews.llvm.org/D20993" rel="noreferrer" target="_blank">http://reviews.llvm.org/D20993</a><br>
<br>
<br>
<br>
</blockquote></div><br></div></div>