This is an archive of the discontinued LLVM Phabricator instance.

Add -debug-info-for-profiling to emit more debug info for sample pgo profile collection
ClosedPublic

Authored by danielcdh on Oct 10 2016, 8:35 AM.

Details

Summary

SamplePGO binaries built with -gmlt to collect profile. The current -gmlt debug info is limited, and we need some additional info:

  • start line of all subprograms
  • linkage name of all subprograms
  • standalone subprograms (functions that has neither inlined nor been inlined)

This patch adds these information to the -gmlt binary. The impact on speccpu2006 binary size (size increase comparing with -g0 binary, also includes data for -g binary, which does not change with this patch):

-gmlt(orig) -gmlt(patched) -g

433.milc 4.68% 5.40% 19.73%
444.namd 8.45% 8.93% 45.99%
447.dealII 97.43% 115.21% 374.89%
450.soplex 27.75% 31.88% 126.04%
453.povray 21.81% 26.16% 92.03%
470.lbm 0.60% 0.67% 1.96%
482.sphinx3 5.77% 6.47% 26.17%
400.perlbench 17.81% 19.43% 73.08%
401.bzip2 3.73% 3.92% 12.18%
403.gcc 31.75% 34.48% 122.75%
429.mcf 0.78% 0.88% 3.89%
445.gobmk 6.08% 7.92% 42.27%
456.hmmer 10.36% 11.25% 35.23%
458.sjeng 5.08% 5.42% 14.36%
462.libquantum 1.71% 1.96% 6.36%
464.h264ref 15.61% 16.56% 43.92%
471.omnetpp 11.93% 15.84% 60.09%
473.astar 3.11% 3.69% 14.18%
483.xalancbmk 56.29% 81.63% 353.22%
geomean 15.60% 18.30% 57.81%

Debug info size change for -gmlt binary with this patch:

433.milc 13.46%
444.namd 5.35%
447.dealII 18.21%
450.soplex 14.68%
453.povray 19.65%
470.lbm 6.03%
482.sphinx3 11.21%
400.perlbench 8.91%
401.bzip2 4.41%
403.gcc 8.56%
429.mcf 8.24%
445.gobmk 29.47%
456.hmmer 8.19%
458.sjeng 6.05%
462.libquantum 11.23%
464.h264ref 5.93%
471.omnetpp 31.89%
473.astar 16.20%
483.xalancbmk 44.62%
geomean 16.83%

Event Timeline

danielcdh updated this revision to Diff 74132.Oct 10 2016, 8:35 AM
danielcdh retitled this revision from to Generate more debug info in -gmlt.
danielcdh updated this object.
danielcdh added reviewers: dblaikie, echristo, davidxl.
danielcdh added a subscriber: llvm-commits.

I was under the impression that gmlt consumers would use the ELF symbol table to derive the mangled name of the subprogram, which also tells you its starting address. The line table gives you the source position. Do you need the subprogram DIEs for something else?

danielcdh updated this revision to Diff 79769.Nov 30 2016, 9:49 AM

guard the debug info change under -fprofile-debug.

echristo edited edge metadata.Dec 5 2016, 6:33 PM

With Minimal and the ProfileDebug it seems that the function can be rearranged to make the logic a bit more clear. Also needs comments describing what we're looking for as far as profile debug. (The clang flag also needs documentation come to think of it.)

Can you look into Minimal plus profile debugging and see what we can unify here? Also coverage analysis I imagine.

Thanks!

-eric

danielcdh updated this revision to Diff 80447.Dec 6 2016, 10:44 AM
danielcdh edited edge metadata.

add some comments

With Minimal and the ProfileDebug it seems that the function can be rearranged to make the logic a bit more clear. Also needs comments describing what we're looking for as far as profile debug. (The clang flag also needs documentation come to think of it.)

Added some comment in the new version. For the clang flag documentation, do you mean the changes in include/clang/Driver/Options.td ? Or could you point to which file I should update to change the documentation? Thanks

Can you look into Minimal plus profile debugging and see what we can unify here? Also coverage analysis I imagine.

I'm not quite sure if I understand correctly. My understanding was that Minimal and ProfileDebug are orthogonal?

Thanks,
Dehao

Thanks!

-eric

danielcdh updated this revision to Diff 81608.Dec 15 2016, 10:12 AM

update option name

Ping....

Thanks
Dehao

dblaikie edited edge metadata.Jan 9 2017, 11:42 AM

Hmm - maybe this shouldn't be a TargetOptions flag?

Should this be module flag (passed through metadata) so that with LTO object files individual preferences are respected? (some may request this extra info, some may not)

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
1187–1190

Out of date comment (refers to previous possible name for the flag)

lib/CodeGen/AsmPrinter/DwarfUnit.cpp
1181–1186

Another out of date comment

1181–1187

Can this "DebugInfoForProfiling" check be floated up to the caller? (rename the 'Minimal' flag parameter to something more descriptive for the behavior change that applies to both debug-info-for-profiling and otherwise?)

danielcdh marked 2 inline comments as done.Jan 9 2017, 1:47 PM

Hmm - maybe this shouldn't be a TargetOptions flag?

Should this be module flag (passed through metadata) so that with LTO object files individual preferences are respected? (some may request this extra info, some may not)

I think this should be a binary attribute because it will change the discriminator algorithm to encode the duplication factor. This should be consistent across all modules.

lib/CodeGen/AsmPrinter/DwarfUnit.cpp
1181–1187

Changed Minimal to SkipSPAttributes because there is no need to output additional attributes when DebugInfoForProfiling (thus cannot float it to caller). Does it sound OK?

danielcdh updated this revision to Diff 83685.Jan 9 2017, 1:47 PM
danielcdh edited edge metadata.

update

dblaikie added inline comments.Jan 9 2017, 1:52 PM
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
1181–1187

Good name - but I meant remove the testing of DebugInfoForProfiling here, but check it at the call sites?

Or perhaps that doesn't work out - multiple call sites, etc & you want to apply it in more cases. It's a while since I wrote this.

If that's the case (that it doesn't make sense to put this on one or two call sites) - could perhaps collapse it at the start of the function with something like:

SkipSPAttributes |= Asm->TM.Options.DebugInfoForProfiling;
1197–1199

DebugInfoForProfiling shouldn't be checked here?

danielcdh added inline comments.Jan 9 2017, 2:05 PM
lib/CodeGen/AsmPrinter/DwarfUnit.cpp
1181–1187

It's not about multiple-callsites, but rather the behavior is different between: "SkipSPAttributes = true" and "SkipSPAttributes = false, DebugInfoForProfiling=true" (as noted in the next comment).

I've refactored the code a little bit to make it more clear.

1197–1199

Right, it should not be checked here because even with -fdebug-info-for-profiling, we don't need the extra debug info which is emitted after this return.

Test coverage would be good - add a flag to llc to test this functionality?

danielcdh updated this revision to Diff 83712.Jan 9 2017, 3:00 PM

add unittest

a flag and a unittest are added.

Thanks,
Dehao

dblaikie accepted this revision.Jan 9 2017, 3:09 PM
dblaikie edited edge metadata.

Looks good to me - but might want to hold off committing this and the clang side and poke @echristo about it. Sounded like he wanted to talk through some of the design here.

This revision is now accepted and ready to land.Jan 9 2017, 3:09 PM
danielcdh retitled this revision from Generate more debug info in -gmlt to Add -debug-info-for-profiling to emit more debug info for sample pgo profile collection.Jan 9 2017, 3:18 PM
danielcdh edited edge metadata.
echristo accepted this revision.Jan 18 2017, 4:30 PM

I'm not a fan of the TargetOptions method, but it seems to work as a first step and we can figure out the rest later.

Thanks for your patience.

-eric

Thanks for the reviews!

danielcdh closed this revision.Jan 18 2017, 4:55 PM