Skip to content

Stats tracer timer work #14695

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from

Conversation

graydon
Copy link
Contributor

@graydon graydon commented Feb 17, 2018

This is a bit of a grab bag of cleanup work in the timers-and-stats-tracers subsystem.

  • Minimizes call-site-complexity of using a FrontendStatsTracer (to just a single RAII decl).
  • Simplifies the layering-preservation machinery from 9334779.
  • Replaces the RecursiveSharedTimer type with a dynamic map of recursion-preventing SharedTimers built from FrontendStatsTracer names, active iff the UnifiedStatsReporter is active (i.e. when the user passes -stats-output-dir, regardless of full tracing).
  • Replaces the spurious SharedTimers that were confusing users in -debug-time-compilation with FrontendStatsTracers.
  • Adds support for tracing ProtocolConformances (as Doug requested).
  • Adds support for tracing unnamed Decls by using their DescriptiveKindName.
  • Permits negative counters and deltas.

If you can detect a theme here, it's to try to consolidate tracing and timing infrastructure: unless you are doing something special, just drop a FrontendStatsTracer in your code and you'll get recursion-safe timers when we're just collecting time (via -stats-output-dir) and full tracing when we're doing that (via -trace-stats-events).

I'll also be following up shortly with a thing that builds flamegraph-format stacked profiles from the tracers.

@graydon
Copy link
Contributor Author

graydon commented Feb 17, 2018

@swift-ci please test

@graydon graydon mentioned this pull request Feb 18, 2018
return;
const ProtocolConformance *C =
static_cast<const ProtocolConformance *>(Entity);
OS << "<conformance ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conformances already have a printName method that probably covers this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fixed.

static_cast<const ProtocolConformance *>(Entity);
if (auto const *DC = C->getDeclContext()) {
if (auto const *D = DC->getAsDeclOrDeclExtensionContext())
D->getSourceRange().print(OS, *SM, false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you want the range here, just the location. (Arguably if you have a NormalProtocolConformance you could get an even better location, which is where the conformance is written. But not all conformances are NormalProtocolConformances.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I know the method is named traceLoc but so far I've been actually tracing all of the ranges. Maybe I should rename it? Or maybe ranges are overkill?

(Will use the normalProtocolConformance decl site when available, in any case)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be reasonable for some of the other things, but for conformances you'll end up using the entire range of the extension or decl that declares conformance, or maybe just the class that inherits from a conforming decl. That doesn't seem useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok (I think I initially went with ranges because of exprs, but shrug it's pretty much just a hint for the reader anyway).


public:

void BeginTimer(StringRef Name) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: lowercase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, llvm-Caps-ism got the better of me.

@graydon
Copy link
Contributor Author

graydon commented Feb 21, 2018

continuing in #14703

@graydon graydon closed this Feb 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants