Skip to content

Add support for FreeBSD's pmcstat callgraph format#502

Merged
jlfwong merged 2 commits intojlfwong:mainfrom
ryan-moeller:pmcstat
Mar 18, 2025
Merged

Add support for FreeBSD's pmcstat callgraph format#502
jlfwong merged 2 commits intojlfwong:mainfrom
ryan-moeller:pmcstat

Conversation

@ryan-moeller
Copy link
Contributor

@ryan-moeller ryan-moeller commented Mar 16, 2025

This eliminates the need for stackcollapse-pmc.pl and its dependency on Perl to import FreeBSD callgraphs. Tracing can be done completely with tools included in the base system. For example:

# kldload hwpmc
# pmcstat -S instructions -O sample.out sleep 1
# pmcstat -R sample.out -G sample.pmcstat.graph

To get npm run jest to run on FreeBSD, I changed the shebang in scripts/test-setup.sh from /bin/bash to /bin/sh as FreeBSD does not have /bin/bash. The script uses no bash-specific features. This is done in a separate commit.

@ryan-moeller ryan-moeller force-pushed the pmcstat branch 2 times, most recently from d1494f3 to 899184b Compare March 17, 2025 02:48
@coveralls
Copy link

coveralls commented Mar 17, 2025

Coverage Status

coverage: 43.984% (+0.3%) from 43.731%
when pulling c06b1b7 on ryan-moeller:pmcstat
into 1c254dc on jlfwong:main.

} else if (fileName.startsWith('callgrind.')) {
console.log('Importing as Callgrind profile')
return importFromCallgrind(contents, fileName)
} else if (fileName.endsWith('.graph')) {
Copy link
Owner

Choose a reason for hiding this comment

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

I think, because this is a generic name, I'd rather omit this bit. The files should still import successfully because of the system below, it'll just be slightly slower as it hits tries a bunch of stuff that doesn't work. I'm nervous about this breaking imports for other profile types that just happen to have a .graph extension

If there's a more specific file pattern (like .pmc.graph or something) that works, I'd be happy to take that

Copy link
Contributor Author

@ryan-moeller ryan-moeller Mar 17, 2025

Choose a reason for hiding this comment

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

The documentation for pmcstat uses .graph as the extension on the example file name so I used that, but I have no problem removing this extension matching shortcut.

Copy link
Contributor Author

@ryan-moeller ryan-moeller Mar 17, 2025

Choose a reason for hiding this comment

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

On second thought, I might as well make up some more specific file extension as you suggested to be consistent with the other formats and provide the shortcut in case it speeds up the process of importing larger traces. I'm not sure how big a trace would have to be to notice a difference, but it won't hurt :)

I've chosen the extension ".pmcstat.graph" rather than something like "pmcstat.txt" because pmcstat can also output other text formats for various uses. And I've updated the example in the commit message to match.

@ryan-moeller ryan-moeller force-pushed the pmcstat branch 3 times, most recently from f5f5f84 to c06b1b7 Compare March 17, 2025 05:59
This eliminates the need for stackcollapse-pmc.pl and its dependency on
Perl to import FreeBSD callgraphs.  Tracing can be done completely with
tools included in the base system.  For example:

  ```
  # kldload hwpmc
  # pmcstat -S instructions -O sample.out sleep 1
  # pmcstat -R sample.out -G sample.pmcstat.graph
  ```
@jlfwong jlfwong merged commit 31974da into jlfwong:main Mar 18, 2025
6 checks passed
@jlfwong
Copy link
Owner

jlfwong commented Jul 7, 2025

@ryan-moeller Sorry for the extreme delay on this, but I just published this to npm as v1.23.0 and this change is now live on https://www.speedscope.app/

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