This is an archive of the discontinued LLVM Phabricator instance.

[Timer] Add the timer option -sort-timers to enable/disable report sorting
ClosedPublic

Authored by Paul-C-Anagnostopoulos on Nov 25 2020, 6:09 PM.

Details

Summary

This little patch adds the SortByWallClock() function to the TimerGroup class. You can use this function to suppress the usual sorting of the timer reports in wall clock order. I find that order confusing, since the timers move around in the report depending on their percentage of the total wall clock time. Without the sort, the timers appear in the order they were created, which is good for timing sequential phases.

I added one more timer to DAGISelEmitter so I could do a thorough test. The unsorted report looks like:

===-------------------------------------------------------------------------===
                             TableGen Phase Timing
===-------------------------------------------------------------------------===
  Total Execution Time: 128.5448 seconds (128.6254 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
  15.3505 ( 12.0%)   0.0156 ( 14.3%)  15.3661 ( 12.0%)  15.3869 ( 12.0%)  Parse, build records
  37.8926 ( 29.5%)   0.0468 ( 42.9%)  37.9394 ( 29.5%)  37.9292 ( 29.5%)  Parse patterns
   2.2464 (  1.7%)   0.0000 (  0.0%)   2.2464 (  1.7%)   2.2571 (  1.8%)  Sort patterns
  68.9056 ( 53.6%)   0.0312 ( 28.6%)  68.9368 ( 53.6%)  68.9859 ( 53.6%)  Convert to matchers
   1.0764 (  0.8%)   0.0000 (  0.0%)   1.0764 (  0.8%)   1.0841 (  0.8%)  Optimize matchers
   2.9640 (  2.3%)   0.0156 ( 14.3%)   2.9796 (  2.3%)   2.9772 (  2.3%)  Emit matcher table
   0.0000 (  0.0%)   0.0000 (  0.0%)   0.0000 (  0.0%)   0.0050 (  0.0%)  Write output
  128.4356 (100.0%)   0.1092 (100.0%)  128.5448 (100.0%)  128.6254 (100.0%)  Total

Diff Detail

Event Timeline

Paul-C-Anagnostopoulos requested review of this revision.Nov 25 2020, 6:09 PM
Paul-C-Anagnostopoulos edited the summary of this revision. (Show Details)

Huh interesting. I'd recommend making this a cl::opt flag so any client of timers can get it. Timer.cpp already has a bunch of these flags (e.g. TrackSpace) so I'd just add one more

I still haven't gotten used to the fact that any old compilation unit can define command line options. Great idea!

Paul-C-Anagnostopoulos retitled this revision from [Timer] [TableGen] Add a function to TimerGroup to suppress report sorting to [Timer] Add the timer option -sort-timers to enable/disable report sorting.

I eliminated the new function and replaced it with the new option -sort-timers. Nice!

I will auto-LGTM this on Monday.

lattner accepted this revision.Nov 28 2020, 8:36 AM

LGTM, thanks Paul

This revision is now accepted and ready to land.Nov 28 2020, 8:36 AM