Diego Novillo
2014-Oct-24 21:48 UTC
[LLVMdev] Recent changes in -gmlt break sample profiling
I'm not sure if this was intended, but it's going to be a problem for sample profiles. When we compile with -gmlt, the profiler expects to find the line number for all the function headers so that it can compute relative line locations for the profile. The tool that reads the ELF binary is not finding them, so it writes out absolute line numbers, which are impossible to match during the profile-use phase. The problem seems to be that we are missing DW_TAG_subprogram for all the functions in the file. Attached are the dwarf dumps of the same program. One compiled with my system's clang 3.4 and the other with today's trunk. In both compiles, I used -gline-tables-only. The trunk version is missing all the subprogram tags for the functions in the file. This breaks the sample profiler. Should I file a bug, or is -gmlt going to be like this from now on? The latter would be a problem for us. Thanks. Diego. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141024/b11ce92f/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: fnptr-clang36.bad.dwarfdump Type: application/octet-stream Size: 4212 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141024/b11ce92f/attachment.obj> -------------- next part -------------- A non-text attachment was scrubbed... Name: fnptr-clang34.good.dwarfdump Type: application/octet-stream Size: 6426 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141024/b11ce92f/attachment-0001.obj>
David Blaikie
2014-Oct-24 22:11 UTC
[LLVMdev] Recent changes in -gmlt break sample profiling
On Fri, Oct 24, 2014 at 2:48 PM, Diego Novillo <dnovillo at google.com> wrote:> I'm not sure if this was intended, but it's going to be a problem for > sample profiles. > > When we compile with -gmlt, the profiler expects to find the line number > for all the function headers so that it can compute relative line locations > for the profile. > > The tool that reads the ELF binary is not finding them, so it writes out > absolute line numbers, which are impossible to match during the profile-use > phase. > > The problem seems to be that we are missing DW_TAG_subprogram for all the > functions in the file. > > Attached are the dwarf dumps of the same program. One compiled with my > system's clang 3.4 and the other with today's trunk. In both compiles, I > used -gline-tables-only. > > The trunk version is missing all the subprogram tags for the functions in > the file. This breaks the sample profiler. > > Should I file a bug, or is -gmlt going to be like this from now on? The > latter would be a problem for us. >Open to negotiation, but this change is intentional ( for details, see the commit: http://llvm.org/viewvc/llvm-project?rev=218129&view=rev ). Even when a subprogram does have inlined subroutines, I've omited the line/file as well, to reduce -gmlt size (actually, I imagine we could even remove the top level subroutines entirely - just emitting the inlined subroutines at the top level - completely garbage DWARF, but it would be smaller & easy enough to teach symbolizers to deal with that if they don't already) To be honest, optimized -gmlt is still pretty big, but these changes do make unoptimized -gmlt essentially no cost over the line table itself, which is nice. A longer term approach to solving this is two-level-line-tables, but they would probably present a problem for the algorithm you've described too. - David> > > Thanks. Diego. > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141024/bb43b422/attachment.html>
Diego Novillo
2014-Oct-24 22:16 UTC
[LLVMdev] Recent changes in -gmlt break sample profiling
On Fri Oct 24 2014 at 6:11:21 PM David Blaikie <dblaikie at gmail.com> wrote:> On Fri, Oct 24, 2014 at 2:48 PM, Diego Novillo <dnovillo at google.com> > wrote: > >> I'm not sure if this was intended, but it's going to be a problem for >> sample profiles. >> >> When we compile with -gmlt, the profiler expects to find the line number >> for all the function headers so that it can compute relative line locations >> for the profile. >> >> The tool that reads the ELF binary is not finding them, so it writes out >> absolute line numbers, which are impossible to match during the profile-use >> phase. >> >> The problem seems to be that we are missing DW_TAG_subprogram for all the >> functions in the file. >> >> Attached are the dwarf dumps of the same program. One compiled with my >> system's clang 3.4 and the other with today's trunk. In both compiles, I >> used -gline-tables-only. >> >> The trunk version is missing all the subprogram tags for the functions in >> the file. This breaks the sample profiler. >> >> Should I file a bug, or is -gmlt going to be like this from now on? The >> latter would be a problem for us. >> > > Open to negotiation, but this change is intentional ( for details, see the > commit: http://llvm.org/viewvc/llvm-project?rev=218129&view=rev ). >Well, this breaks us. Very hard. It absolutely blocks us from using SamplePGO with LLVM. The alternative would be to make the compiler use absolute line numbers, but in the experience we've collected with GCC, this makes the profiles very brittle wrt source changes. I don't have a better idea atm. Would there be any other way to generate relative line numbers? Perhaps we could use the first line number we find with samples? The problem here is that this line will shift, depending on how the profile was obtained. Would it be possible to add these line numbers in some other way? Thanks. Diego. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20141024/d1b857c0/attachment.html>