<div dir="ltr"><div dir="ltr"><div dir="ltr">(Sorry, hit send too early)<div><br></div></div><div class="gmail_quote"><div>On Tue, Jan 15, 2019 at 12:20 PM Sam McCall <<a href="mailto:sammccall@google.com">sammccall@google.com</a>> wrote:<br></div>Hi Aras,<br><br>Nice work! Visualizing the timeline is a powerful tool, and I'd appreciate having an easy way to annotate how spans of time are spent.<br>We also have a facility in clangd[1] to record traces and output them in chrome tracing format, and I've also done some performance work with similar tools internally.<br><br>Some random thoughts:<br> - the distinction between tracing/profiling automatically (stack frames, using xray or a profiler) and manually annotating ranges is an important one - it may be possible to use XRay to combine the two.<br> - the timeline view, flame graph, and graphviz representations are independently useful, so being able to output something pprof can read is nice</div><div class="gmail_quote"> - for multi-threaded programs, being able to represent events split across or transferred between threads is important, but complicates the model</div><div class="gmail_quote"> - it's been useful to us to plug in other backends (e.g. internal cross-server tracing tools)</div><div class="gmail_quote"> - the chrome tracing format is pretty awkward to work with: bulky, odd semantics, doesn't survive truncation. It'd be nice to have something better.<br><br>The clangd implementation probably isn't general purpose enough to use for clang (particularly its approach to threading), but there might be some useful ideas in there.</div><div class="gmail_quote"><br></div><div class="gmail_quote">Cheers, Sam<br><br>[1] <a href="https://reviews.llvm.org/source/clang-tools-extra/browse/clang-tools-extra/trunk/clangd/Trace.h">https://reviews.llvm.org/source/clang-tools-extra/browse/clang-tools-extra/trunk/clangd/Trace.h</a><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br><div class="gmail_quote"><div>On Sun, Jan 13, 2019 at 1:31 PM Aras Pranckevicius via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div>Hello!</div><div><br></div><div>TL;DR: I have made a Clang/LLVM code change that adds "-ftime-trace" option, that produces Chrome Tracing format output. Would like comments on whether that is a good idea or not, or perhaps someone else is already doing this. My current (WIP) patch in github PR format is here <a href="https://github.com/aras-p/llvm-project-20170507/pull/2" target="_blank">https://github.com/aras-p/llvm-project-20170507/pull/2</a> -- with images and trace output files attached.</div><div><br></div><div>Longer version:</div><div><br></div><div>Current implementation of "-ftime-report" has several issues, particularly when I'm just a "user" of the compiler:</div><div><br></div><div>- it outputs a lot of information (almost half of it is duplicated since clang 7.0),</div><div>- a lot of that information is things that only compiler developers would know about,</div><div>- has quite large overhead, I've seen it make compile times take 1.5x longer,</div><div>- has very little information about "frontend" part (preprocessing, parsing, instantiation, C++ modules),</div><div>- the things it reports are only "summaries", i.e. "how much time it took to do work X in total". e.g. it can tell that "inlining all functions took X seconds", but in case there was just one super slow function to inline among</div><div>thousands, it will not tell which one was the slow one.</div><div><br></div><div>I have written a blog post about this (as well as lack of "good" time reporting tools in Visual Studio and gcc) recently, <a href="http://aras-p.info/blog/2019/01/12/Investigating-compile-times-and-Clang-ftime-report/" target="_blank">http://aras-p.info/blog/2019/01/12/Investigating-compile-times-and-Clang-ftime-report/</a></div><div><br></div><div>At work (Unity game engine), with codebase of similar size to whole of Clang/LLVM (2-3 million lines of code), we had really good experience in adding timeline/flamegraph visualizations to various parts of our "build system". This can tell us which .cpp files were slowest to compile in the whole build, but I also wanted similar tooling for things "inside" single .cpp file compilation.</div><div><br></div><div>Thus this attempt at adding a new time trace profiling mode.</div><div><br></div><div>I have current changes on github here, <a href="https://github.com/aras-p/llvm-project-20170507/pull/2" target="_blank">https://github.com/aras-p/llvm-project-20170507/pull/2</a> -- can do a proper "patch" thing via Phabricator if needed.</div><div><br></div><div>My current code change does not quite match Clang/LLVM code standards and probably needs some work, but the general approach seems to work. Already found one case of Clang being very slow at parsing some weird recursive macro thingamabob that we had; was causing about 5-8 seconds just to include one header file. I probably would have never found it without this type of visualization. Here it is very clear that among all the things, parsing just that one header file takes almost all the time: <a href="https://user-images.githubusercontent.com/348087/51038295-76efb780-15bb-11e9-926f-a6be1ffd03f1.png" target="_blank">https://user-images.githubusercontent.com/348087/51038295-76efb780-15bb-11e9-926f-a6be1ffd03f1.png</a></div><div><br></div><div><br></div><div>Regards,</div><div><br></div>-- <br><div class="gmail-m_-1092372215154760957gmail-m_7662815598608974125gmail_signature">Aras Pranckevičius<br>work: <a href="http://unity3d.com" target="_blank">http://unity3d.com</a><br>home: <a href="http://aras-p.info" target="_blank">http://aras-p.info</a></div></div></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>
</blockquote></div></div></div>