Skip to content

[rocprofiler-compute] Default PC sampling sort to count, add --pc-sampling-rows#7763

Open
vedithal-amd wants to merge 5 commits into
rocprofiler-compute-developfrom
users/vedithal-amd/pc-sampling-rows-default-count
Open

[rocprofiler-compute] Default PC sampling sort to count, add --pc-sampling-rows#7763
vedithal-amd wants to merge 5 commits into
rocprofiler-compute-developfrom
users/vedithal-amd/pc-sampling-rows-default-count

Conversation

@vedithal-amd

Copy link
Copy Markdown
Contributor

Motivation

End users analyzing PC sampling mostly care about the top hotspots. Defaulting the sort to count surfaces the most-sampled instructions first, and a new --pc-sampling-rows option keeps the table from flooding the CLI by default while letting users widen it as needed.

Technical Details

  • Changed --pc-sampling-sorting-type default from offset to count.
  • Added --pc-sampling-rows analyze option (default 10); 0 or a negative value shows all rows.
  • Row limit is applied in the shared loader after sorting, so both CLI and Web UI honor it.

JIRA ID

AIPROFCOMP-681

Test Plan

  • Run unit tests: tests/test_argparser.py, tests/test_pc_sampling_analysis.py, tests/test_analyze_commands.py.
  • Verify analyze output: default shows top 10 by count; --pc-sampling-rows 0 shows all; --pc-sampling-sorting-type offset still sorts by offset.

Test Result

Unit tests pass locally (199 passed). Ruff clean.

Submission Checklist

…pling-rows

- Default --pc-sampling-sorting-type to count so the analysis table
  leads with the most-sampled instructions (hotspots).
- Add --pc-sampling-rows analyze option (default 10) to cap the PC
  sampling table; 0 or negative shows all rows.

Co-Authored-By: Claude Opus 4 (1M context)
@github-actions github-actions Bot added documentation Improvements or additions to documentation project: rocprofiler-compute labels Jun 24, 2026
- Validate --pc-sampling-rows as non-negative; 0 shows all rows.
- Clarify the 0-means-all behavior in help text, code comment, and docs.

Co-Authored-By: Claude Opus 4 (1M context)
- Merge the per-option PC sampling analyze tests into one function.
- Assert the negative-rejection message via a mocked stderr instead of
  capsys.

Co-Authored-By: Claude Opus 4 (1M context)
…rror

- Assert argparse raises by mocking ArgumentParser.error instead of
  capturing stderr.

Co-Authored-By: Claude Opus 4 (1M context)
- Drop the bespoke fixture and fold the num_rows cases into one
  parametrized test over the existing helper.

Co-Authored-By: Claude Opus 4 (1M context)
@vedithal-amd vedithal-amd marked this pull request as ready for review June 24, 2026 18:29
@vedithal-amd vedithal-amd requested review from a team and prbasyal-amd as code owners June 24, 2026 18:29
Copilot AI review requested due to automatic review settings June 24, 2026 18:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates rocprofiler-compute’s PC sampling analysis defaults to better surface hotspots by default, and introduces a new row-limit option to keep CLI output manageable while ensuring consistent behavior across CLI and Web UI.

Changes:

  • Defaulted --pc-sampling-sorting-type from offset to count.
  • Added --pc-sampling-rows (default 10) and applied row limiting after sorting in the shared loader.
  • Updated docs/changelog and expanded unit tests to cover the new defaults and row limiting.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
projects/rocprofiler-compute/src/utils/parser.py Adds num_rows support and applies row limiting after sorting in the shared PC sampling loader.
projects/rocprofiler-compute/src/argparser.py Changes default sorting to count and introduces --pc-sampling-rows with validation.
projects/rocprofiler-compute/tests/test_pc_sampling_analysis.py Adds coverage for num_rows limiting behavior and updates args used by non-metrics table tests.
projects/rocprofiler-compute/tests/test_argparser.py Adds coverage for default/override behavior of the new analyze options and validation of --pc-sampling-rows.
projects/rocprofiler-compute/docs/how-to/pc_sampling.rst Documents new default sorting and the new --pc-sampling-rows option.
projects/rocprofiler-compute/CHANGELOG.md Records the new option and the changed default sorting behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +477 to +479
# num_rows of 0 (or None) means show all rows; argparse rejects negatives.
if num_rows:
df_sorted = df_sorted.head(num_rows)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Technically this could be called as public method but should not be used in such cases, this should have been screened for negatives already by the argparser. Optional suggestion to add.

Comment on lines +801 to +805
default="count",
type=str,
help="\t\tSet the sorting type of pc sampling: "
"offset or count (DEFAULT: offset).",
"offset or count (DEFAULT: count).",
)
Comment on lines +112 to +115
if parsed < 0:
raise argparse.ArgumentTypeError(
f"must be a non-negative integer (0 means all), got {parsed}"
)

@cfallows-amd cfallows-amd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, please add two of the suggestions from copilot- update PR description to match implementation for negative error vs all, and the "choices" in argparser to add rigidity when specifying sort type. Marking approved since these are straightforward changes

Comment on lines +477 to +479
# num_rows of 0 (or None) means show all rows; argparse rejects negatives.
if num_rows:
df_sorted = df_sorted.head(num_rows)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Technically this could be called as public method but should not be used in such cases, this should have been screened for negatives already by the argparser. Optional suggestion to add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants