Skip to content

Conversation

@vedithal-amd
Copy link
Contributor

@vedithal-amd vedithal-amd commented Jan 7, 2026

Motivation

The analysis database schema had several issues impacting performance, correctness, and data modeling:

  • Metric definitions were incorrectly tied to individual kernels, causing unnecessary duplication since metrics are workload-level concepts
  • Database generation performance degraded with large numbers of kernels due to O(n*m) iteration patterns
  • Missing kernel existence checks caused KeyError crashes when processing roofline data
  • Table names didn't clearly distinguish between metric definitions and actual values

Technical Details

Schema Refactoring

  • Restructured pc_sampling and roofline_data to reference kernel table directly instead of workload, removing redundant kernel_name fields
  • Renamed MetricMetricDefinition and ValueMetricValue for clarity
  • Moved MetricDefinition from kernel-level to workload-level (metrics shared across kernels)
  • Updated MetricValue to reference both MetricDefinition and Kernel
  • Refactored metric_view to join through new schema structure
  • Add min and max aggregation in kernel_view

Performance Optimization

  • Changed metric processing from O(n*m) to O(n) by iterating over values and creating metrics as needed
  • Added pre-computed lookup dictionaries for O(1) metric info access
  • Reuse metric objects across multiple values for same metric/kernel pair

Bug Fixes

  • Added kernel existence check before inserting roofline data to prevent KeyError exceptions

Updates

  • Updated test fixtures to use renamed tables (compute_metric_definition, compute_metric_value)
  • Regenerated schema and views diagrams
  • Updated CLI documentation with new example output

JIRA ID

AIPROFCOMP-62

Test Plan

Ensure test_analyze_rocpd test passes in tests/test_profile_general.py

Test Result

Tests pass

Submission Checklist

Copilot AI review requested due to automatic review settings January 7, 2026 18:35
@vedithal-amd vedithal-amd requested review from a team and prbasyal-amd as code owners January 7, 2026 18:35
@github-actions github-actions bot added documentation Improvements or additions to documentation project: rocprofiler-compute labels Jan 7, 2026
Copy link
Contributor

Copilot AI left a comment

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 the analysis database schema from v1.1.0 to v1.2.0 to better model the relationship between data tables and kernels. The key change is moving pc_sampling and roofline_data tables to relate directly to the kernel table instead of the workload table, which more accurately reflects the data structure where these metrics are per-kernel rather than per-workload.

Key changes:

  • Schema relationships refactored so pc_sampling and roofline_data now reference kernels instead of workloads
  • Removed redundant kernel_name fields from pc_sampling and roofline_data tables since this information is now available through the foreign key relationship
  • Updated database population logic to create kernel objects first, then link roofline and PC sampling data to them

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
projects/rocprofiler-compute/src/utils/analysis_orm.py Updated ORM schema: incremented version to 1.2.0, moved relationships from Workload to Kernel for RooflineData and PCsampling tables, removed redundant kernel_name columns
projects/rocprofiler-compute/src/rocprof_compute_analyze/analysis_db.py Refactored database population logic to create kernels from dispatch data first, then link roofline and PC sampling data to kernel objects; added error handling for missing kernels in PC sampling data

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

Copy link

Copilot AI commented Jan 8, 2026

@vedithal-amd I've opened a new pull request, #2536, to work on those changes. Once the pull request is ready, I'll request review from you.

vedithal-amd and others added 3 commits January 9, 2026 09:17
* `pc_sampling` and `roofline_data` tables should relate to `kernel` table instead of `workload` table

* Remove `kernel_name` fields in `pc_sampling` and `roofline_data` table
* Initial plan

* Add kernel existence check for roofline data to prevent KeyError

Co-authored-by: vedithal-amd <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: vedithal-amd <[email protected]>
@vedithal-amd vedithal-amd force-pushed the users/vedithal/rocprofiler-compute-analysis-db branch from a572b2f to ed45b0b Compare January 9, 2026 14:51
Reorganize the database ORM to decouple metric definitions from kernel
objects. This improves the schema design by:

- Rename Metric -> MetricDefinition and Value -> MetricValue for clarity
- Move metric definitions from kernel-level to workload-level, since
  metric definitions are shared across kernels
- Update relationships: MetricDefinition belongs to Workload,
  MetricValue
  references both MetricDefinition and Kernel
- Refactor metric_view to join through the new schema structure
- Update test fixtures to use renamed table and class names
- Update documentation with new example output using nbody workload
- Regenerate database schema and views diagrams
@vedithal-amd vedithal-amd changed the title [rocprofiler-compute] Analysis database v1.2.0 [rocprofiler-compute] Analysis Database Schema Improvements (v1.2.0) Jan 13, 2026
@vedithal-amd
Copy link
Contributor Author

@feizheng10 and @cfallows-amd could you please review these analysis database improvements

@tomk-amd
Copy link

Schema update looks good.

Copy link
Contributor

@feizheng10 feizheng10 left a comment

Choose a reason for hiding this comment

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

LG

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.

4 participants