Skip to content
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

Support different display granularities in flame graph view. #896

Merged
merged 3 commits into from
Sep 27, 2024

Conversation

ghemawat
Copy link
Contributor

Previously, flame-graph view could only display filefunctions granularity. We can now support all the available granularities.

This allows the user to supply a granularity either via a command-line flag (e.g., --files), or as a URL parameter (e.g., ?g=files).

Details

  • Made the default initial granularity "" so that we can stick with the default flame-graph granularity of "filefunctions" while also allowing overrides.
  • Use different computation of the list of shorter display names for file names (strip off leading path components instead of package prefixes).
  • Similarly compute color based on directory name instead of package name.
  • Include line number and column number in displayed names if the granularity includes line numbers.

Previously, flame-graph view could only display filefunctions
granularity. We can now support all the available granularities.

This allows the user to supply a granularity either via a command-line
flag (e.g., --files), or as a URL parameter (e.g., ?g=files).

Details
* Made the default initial granularity "" so that we can stick with
  the default flame-graph granularity of "filefunctions" while also
  allowing overrides.
* Use different computation of the list of shorter display names
  for file names (strip off leading path components instead of package
  prefixes).
* Similarly compute color based on directory name instead of package name.
* Include line number and column number in displayed names if the
  granularity includes line numbers.
@codecov-commenter
Copy link

codecov-commenter commented Sep 25, 2024

Codecov Report

Attention: Patch coverage is 82.75862% with 10 lines in your changes missing coverage. Please review.

Project coverage is 67.41%. Comparing base (0ed6a68) to head (124e426).
Report is 39 commits behind head on main.

Files with missing lines Patch % Lines
internal/report/stacks.go 84.09% 5 Missing and 2 partials ⚠️
internal/driver/interactive.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #896      +/-   ##
==========================================
+ Coverage   66.86%   67.41%   +0.54%     
==========================================
  Files          44       44              
  Lines        9824     9851      +27     
==========================================
+ Hits         6569     6641      +72     
+ Misses       2794     2762      -32     
+ Partials      461      448      -13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -68,7 +68,7 @@ func defaultConfig() config {
Trim: true,
DivideBy: 1.0,
Sort: "flat",
Granularity: "functions",
Copy link
Collaborator

Choose a reason for hiding this comment

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

One potentially unintended consequence of this change is that the default is now unclear in the output of the "o" command in the interactive shell.

Before:

$ pprof profile.pb.gz
...
(pprof) o
...
  granularity               = functions            //: [addresses | filefunctions | files | functions | lines]
...

With the change:

$ go run pprof.go profile.pb.gz
...
(pprof) o
...
  granularity               =                      //: [addresses | filefunctions | files | functions | lines]
...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this is reasonable given that the change proposes having different default granularities for different views.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or maybe we should at least show a string like "default" here? Showing empty string just looks a bit odd.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We now show:

  granularity               = (default)            //: [addresses | filefunctions | files | functions | lines]

}

for _, c := range []testCase{
test("empty", "", "."),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is "." expected here? I'm worried a little we'll show this dot in the UI when the profile does not have filenames (e.g. binary had symbols but no debug info).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is an artifact of the implementation leaking through.

I can fix this in a subsequent change. Any suggestions for a better thing to display. Maybe "?" if neither func/file is available?

Copy link
Collaborator

Choose a reason for hiding this comment

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

At a minimum I'd probably just leave it empty for now. I.e. just not turn empty strings into the dot. For the "?" - maybe, not sure, would need to look at it first. I believe we also use "unknown" and "" placeholders in some places, if we'd want to start using "?" I think three different ones might be too many :)

@aalexand aalexand merged commit d43a673 into google:main Sep 27, 2024
31 checks passed
@ghemawat ghemawat deleted the granularity branch September 27, 2024 20:51
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.

3 participants