Skip to content

Conversation

@janaknat
Copy link
Contributor

Currently, Aperf collects data from a set of pre-configured PMU events. The user has no way of collecting custom PMU events.

This PR includes two changes.

  1. Move the pre-configured PMU events to a JSON file format.
  2. Create a subtool aperf custom-pmu which will allow the user to create/modify a custom PMU file which can then be passed in to aperf record. This file will replace the default for that platform.
  • The user has the option to:
    • create a custom PMU file from scratch
    • modify (add, delete) existing pre-defined defaults
    • update (add, delete) a custom PMU file

The uploaded aperf run had only 4 events collected. The aperf custom-pmu tool was used to modify the existing config.

aperf_report_custompmu.tar.gz

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Move to using JSON to hold the event details for Perf Stat. This makes
it easier to modify the files without the need for interacting with the
Rust compiler.

This is also in preparation for allowing the user to specify a custom
PMU config file.
@janaknat janaknat requested a review from a team as a code owner December 26, 2024 19:54
@janaknat
Copy link
Contributor Author

We might want to consider carrying the custom PMU file , that a user may provide, in the run data.

@@ -0,0 +1,20 @@
[
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest you have a CI job that validates each and every one of the .json configs in src/data/*.json. Don't have to collect any valid data, just make sure the files parse.

Probably worth providing a way for aperf to load the file and say "all good" without even trying to collect.

@lrbison
Copy link
Contributor

lrbison commented Jan 7, 2025

We might want to consider carrying the custom PMU file , that a user may provide, in the run data.

This is a good idea. We should probably put the used PMU config in the run data any time PMU data is collected (regardless of custom or not). rationale: PMU config can change between versions.

Allow the user to specify a custom PMU file to be used during aperf
record. This custom PMU file must be in the expected format.

To aid in the creation of the custom PMU file, add a sub-command.

'aperf custom-pmu' - an interactive sub-command to create custom PMU.
This allows the user to create a file from scratch or modify an existing
PMU config aperf already knows about. The custom file generated can be
used by specifying '--pmu-config' with 'aperf record'.

Additionally, a pmu-config file can be verified by specifying --verify
along with --pmu-file with 'aperf custom-pmu'.
@janaknat
Copy link
Contributor Author

We might want to consider carrying the custom PMU file , that a user may provide, in the run data.

This is a good idea. We should probably put the used PMU config in the run data any time PMU data is collected (regardless of custom or not). rationale: PMU config can change between versions.

We are now storing the PMU config used by aperf in the recorded data. This occurs irrespective of if the PMU config is user supplied or default.

Copy link
Contributor

@lrbison lrbison left a comment

Choose a reason for hiding this comment

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

some small nits, but LGTM. Thanks for addressing the others.

{
"perf_type": "RAW",
"name": "Cycles",
"config": 17
Copy link
Contributor

Choose a reason for hiding this comment

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

I just realized that all these numbers are in decimal because JSON doesn't support hex integers directly.

Unfortunately pretty much every PMU document ever will list counters in hex. This makes inspecting or editing these counters very painful because anything over than 0x20 becomes difficult to convert in my head.

What if we make config a string and then instead of "config": 17 we could write "config": "0x11".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. That's an improvement we can consider.

"name": "stall_backend_pkc",
"nrs": [
{
"perf_type": "RAW",
Copy link
Contributor

Choose a reason for hiding this comment

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

Best I can tell, "perf_type": "RAW" can be inferred by the presence of the "config" field. Everything is either raw or has nrs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

RAW here indicates CPU. We're looking to add support for other types of PMUs too which the perf_type will hold.

@janaknat janaknat merged commit c890920 into aws:main Jan 27, 2025
6 checks passed
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