Skip to content

feat(rocprofiler-compute): Ingest code-object ISA into analysis DB#8395

Open
vedithal-amd wants to merge 8 commits into
users/vedithal-amd/pc-sampling-normalized-db-schemafrom
users/vedithal-amd/pc-sampling-code-obj-info-ingest
Open

feat(rocprofiler-compute): Ingest code-object ISA into analysis DB#8395
vedithal-amd wants to merge 8 commits into
users/vedithal-amd/pc-sampling-normalized-db-schemafrom
users/vedithal-amd/pc-sampling-code-obj-info-ingest

Conversation

@vedithal-amd

@vedithal-amd vedithal-amd commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Motivation

Add the full per-code-object disassembly emitted by the native PC sampling collector to the analysis database, including instructions that were never PC-sampled. This gives the DB complete ISA context alongside the sampled counts landed in the normalized schema PR. Stacked on #8334; no schema change and no user-visible output change.

Technical Details

  • New src/pc_sampling/code_object_analysis.py: a pure parser (code-object disassembly dict -> per-object instruction records) plus a thin discovery loader that finds the per-process disassembly artifacts under a workload.
  • Reconcile disassembly instructions to the offset the PC-sampling rows use, measured from the code object's load address: code_object_offset = virtual_address - load_base (the disassembly's own offset is into the ELF file, a different axis).
  • Skip any offset already inserted so no duplicate instruction lines are added; ISA-only lines are stored with kernel_uuid NULL. Per-kernel attribution of code-object ISA is deferred to the native kernel-mapping work.
  • Code objects with no known load_base are skipped (the offset cannot be derived).
  • Relocate pc_sampling_analysis.py from src/utils to the src/pc_sampling package (mechanical, no behavior change).
  • Reconcile the ENABLE_COVERAGE test list, which was missing several registered Python tests.

JIRA ID

JIRA ID: AIPROFCOMP-540

Test Plan

  • Parser unit tests against a sample workload's disassembly artifact (per-object grouping, symbol-instruction flattening, field capture) and discovery-loader tests (pid parse, malformed JSON, missing pid prefix).
  • DB unit tests: ISA-only lines added with kernel NULL, an already-sampled offset inserts no duplicate row, store creation for a code object present only in the disassembly artifact, and skip-on-null-load_base.
  • End-to-end analyze --output-format db on the PC-sampling workload, asserting sampled lines are kernel-attributed with a sample state, ISA-only lines are not, and no (code object, offset) is duplicated.

Test Result

Python unit tests pass; ruff clean.

Submission Checklist

  • Look over the contributing guidelines

…sampling

Relocate pc_sampling_analysis.py from src/utils to the src/pc_sampling
package so PC-sampling analysis code lives alongside pc_sampling_profile.
Update importers and CMake test wiring; no behavior change.

Co-Authored-By: Claude Opus 4
Backfill the analysis DB instruction_line table with the full per-object
disassembly from <pid>_code_obj_info.json, including instructions that were
never sampled. Reconcile disassembly instructions to ps-space offsets via
virtual address (code_object_offset = virtual_address - load_base) and skip
any offset already sampled so no duplicate ISA is inserted.

- New src/pc_sampling/code_object_analysis.py: pure parser plus a thin
  discovery loader for the code-object artifacts.
- Un-sampled lines are stored with kernel_uuid NULL; per-kernel attribution
  of code-object ISA is deferred to the native kernel-mapping work.
- Code objects with no known load_base are skipped (no ps-space offset).
- No schema change and no user-visible output change (ISA lands only in the
  raw table, not the pc_sampling view or CLI).

Co-Authored-By: Claude Opus 4
Refresh the PC-sampling fixture with a matched ps_file + code_obj_info pair
from one run, with enough samples to exercise both sampled-row population and
full-ISA backfill. Rename the arch dir to MI300X_A1 to match the captured
hardware.

- Enhance the db-output analyze test to assert backfilled ISA lines are
  un-attributed (kernel NULL) with no sample state, sampled lines stay
  kernel-attributed, and no (code object, offset) is duplicated.
- Rewrite the code_object_analysis parser tests to build inline mock payloads
  instead of reading a workload artifact.

Co-Authored-By: Claude Opus 4
…ed tests

The ENABLE_COVERAGE report's ALL_TEST_NAMES omitted 18 registered Python
tests, so generate_coverage_report did not depend on them and could run
before they finished. Add the missing entries (analysis DB/ORM, code-object
and PC-sampling analysis, profile multiplexing/attach/multi-rank, tty, and
others) so the report depends on the full Python test suite.

Conditionally-registered tests (test_import_guard, test_profile_multi_rank)
are listed as plain DEPENDS entries; CTest ignores dependency names that are
not registered in the current configuration.

Co-Authored-By: Claude Opus 4
Reformat the fixture ps_file_results.json and code_obj_info.json to indented
multi-line so diffs and manual inspection are readable.

Co-Authored-By: Claude Opus 4
Drop the CodeObjectStoreCatalog handoff: add_code_object_isa is now
self-sufficient, deriving existing stores and offsets from the workload's
in-memory ORM graph instead of a state object passed from add_pc_sampling_data.

- add_pc_sampling_data returns nothing and knows nothing about ISA ingestion.
- Share instruction-line construction; split the sample-state and its child
  counts into _add_sample_state.
- Switch the code-object tests to common.get_output_dir/clean_output_dir with
  try/finally so cleanup runs on failure.

Co-Authored-By: Claude Opus 4
…naming

Fold _add_sample_state and _add_disassembly_lines into their callers so the
sampled-row and ISA passes read top to bottom without indirection. Decouple the
ISA pass from PC-sampling: it derives existing code objects and offsets from the
workload's in-memory ORM graph, no state object passed between passes.

- Name the reused-store map existing_code_objects; drop the "backfill" and
  "catalog" terminology from code and tests.
- Explain why an instruction is skipped when its code object has no load_base.

Co-Authored-By: Claude Opus 4
@vedithal-amd vedithal-amd marked this pull request as ready for review July 10, 2026 09:08
@vedithal-amd vedithal-amd requested a review from a team as a code owner July 10, 2026 09:08
Copilot AI review requested due to automatic review settings July 10, 2026 09:08
@vedithal-amd vedithal-amd changed the title [rocprofiler-compute] Ingest code-object ISA into analysis DB feat(rocprofiler-compute): Ingest code-object ISA into analysis DB Jul 10, 2026

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 extends rocprofiler-compute’s PC-sampling DB ingestion to also store the full per-code-object disassembly (ISA) into the analysis database, so the DB contains complete instruction context beyond just sampled PCs. It introduces a code-object disassembly loader/parser, integrates ISA ingestion into the DB pipeline, relocates PC-sampling analysis utilities into the pc_sampling package, and updates/expands tests plus associated workload fixtures.

Changes:

  • Add a code-object disassembly parser/loader and ingest ISA-only instruction lines into the analysis DB (kernel attribution deferred; ISA-only lines have kernel_uuid NULL).
  • Move PC-sampling analysis utilities into src/pc_sampling/pc_sampling_analysis.py and update imports/callers.
  • Update workloads and tests (new unit tests, refreshed PC-sampling-only workload artifacts, and coverage test list fixes).

Reviewed changes

Copilot reviewed 15 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
projects/rocprofiler-compute/tests/workloads/vcopy_pc_sampling_only/MI300X_A1/sysinfo.csv Adds updated MI300X_A1 workload sysinfo fixture for PC-sampling-only testing.
projects/rocprofiler-compute/tests/workloads/vcopy_pc_sampling_only/MI300X_A1/profiling_config.yaml Updates workload config to reflect PC-sampling-only run settings used by refreshed fixtures.
projects/rocprofiler-compute/tests/workloads/vcopy_pc_sampling_only/MI300X_A1/log.txt Adds updated run log fixture showing code object info artifact emission.
projects/rocprofiler-compute/tests/workloads/vcopy_pc_sampling_only/MI300A_A1/sysinfo.csv Removes older MI300A_A1 sysinfo fixture as part of workload refresh.
projects/rocprofiler-compute/tests/workloads/vcopy_pc_sampling_only/MI300A_A1/ps_file_results.json Removes older MI300A_A1 PC-sampling results fixture.
projects/rocprofiler-compute/tests/workloads/vcopy_pc_sampling_only/MI300A_A1/pmc_dispatch_info.csv Removes older MI300A_A1 dispatch info fixture.
projects/rocprofiler-compute/tests/workloads/vcopy_pc_sampling_only/MI300A_A1/log.txt Removes older MI300A_A1 run log fixture.
projects/rocprofiler-compute/tests/test_pc_sampling_analysis.py Updates imports for relocated module and extends DB E2E assertions to cover ISA-only lines and de-duplication.
projects/rocprofiler-compute/tests/test_code_object_analysis.py Adds unit tests for code-object disassembly parsing and recursive discovery/loader behavior.
projects/rocprofiler-compute/tests/test_categories.yaml Registers the new test in test category groupings (including coverage-enabled sets).
projects/rocprofiler-compute/tests/test_analyze_commands.py Updates imports to the relocated PC-sampling analysis module.
projects/rocprofiler-compute/tests/test_analysis_db.py Adds DB unit tests for ISA ingestion behavior (unsampled lines, dedup, store creation, skip-on-null-load_base).
projects/rocprofiler-compute/src/utils/parser.py Switches PC-sampling imports to the relocated pc_sampling.pc_sampling_analysis module.
projects/rocprofiler-compute/src/rocprof_compute_analyze/analysis_db.py Integrates ISA ingestion (add_code_object_isa) into DB analysis and uses the new loader/parser.
projects/rocprofiler-compute/src/pc_sampling/pc_sampling_analysis.py Adds/relocates PC-sampling normalization/aggregation/enrichment helpers used by DB ingestion and tests.
projects/rocprofiler-compute/src/pc_sampling/code_object_analysis.py Introduces code-object ISA parsing and recursive discovery loader for *_code_obj_info.json artifacts.
projects/rocprofiler-compute/CMakeLists.txt Adds the new test target and reconciles the ENABLE_COVERAGE test dependency list.

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

Document that ISA offsets for non-surviving pids are wrong because load_base
comes only from the single clobbered ps_file, pending the multi-process
results-file fix.

Co-Authored-By: Claude Opus 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants