Skip to content

(feat) Support AMD GPU for Insights#1147

Merged
shm11C3 merged 6 commits into
developfrom
feat/insight/add-support-gpu
Feb 23, 2026
Merged

(feat) Support AMD GPU for Insights#1147
shm11C3 merged 6 commits into
developfrom
feat/insight/add-support-gpu

Conversation

@shm11C3

@shm11C3 shm11C3 commented Feb 22, 2026

Copy link
Copy Markdown
Owner

This pull request introduces cross-vendor GPU monitoring support, refactoring the GPU metrics collection and storage system to be vendor-agnostic and adding AMD and Linux GPU metrics collection. It also updates the data pipeline and UI to handle the new structure and improves data availability feedback in the insights chart.

GPU Monitoring Refactor and Vendor-Agnostic Support:

  • Replaces NVIDIA-specific GPU history fields (nv_gpu_*_histories) with generic gpu_*_histories in state and resource models, and updates all usages throughout the backend to use the new generic fields. [1] [2] [3] [4] [5] [6] [7]
  • Refactors the GPU metrics collection pipeline to aggregate per-GPU metrics (usage, temperature, memory) for both NVIDIA and AMD on Windows, and for AMD/Intel on Linux, using a new GpuSample type. [1] [2] [3]

AMD and Linux GPU Metrics Collection:

  • Implements async AMD GPU usage and temperature collection via ADL on Windows, exposing new async functions get_amd_gpu_usage_per_adapter and get_amd_gpu_temperatures_per_adapter.
  • Adds Linux GPU metrics collection for AMD and Intel using DRM/sysfs/hwmon, including vendor detection and per-card sampling, with fallback for missing VRAM metrics.

Data Pipeline and Stats Calculation Updates:

  • Updates the archive and stats calculation logic to use the new vendor-agnostic GPU histories, ensuring per-GPU stats are computed for the correct device by name. [1] [2]

Frontend Improvements:

  • Enhances the GPU insight chart to detect and display when no data is available for the selected period, using a new onDataAvailabilityChange callback and a fallback UI message. [1] [2] [3] [4]

Async Monitoring Pipeline:

  • Updates the system monitor worker and monitoring service to call the async GPU sampling function for both Windows and Linux, ensuring non-blocking and correct vendor support. [1] [2]

These changes lay the groundwork for unified GPU monitoring across vendors and platforms, improve code maintainability, and enhance the user experience when data is unavailable.

Copilot AI review requested due to automatic review settings February 22, 2026 18:43
@github-actions github-actions Bot added rust Pull requests that update Rust code frontend feature labels Feb 22, 2026
@github-actions

github-actions Bot commented Feb 22, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 90.6% (🎯 60%) 916 / 1011
🔵 Statements 89.09% (🎯 60%) 956 / 1073
🔵 Functions 84.86% (🎯 60%) 213 / 251
🔵 Branches 72.88% (🎯 60%) 258 / 354
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/features/hardware/insights/hooks/useInsightChart.ts 84.55% 67.39% 78.57% 85.47%
Generated in workflow #2322 for commit 7833276 by the Vitest Coverage Report Action

@github-actions

Copy link
Copy Markdown
Contributor

Rust Backend Coverage Report

Coverage Details
Filename                                         Regions    Missed Regions     Cover   Functions  Missed Functions  Executed       Lines      Missed Lines     Cover    Branches   Missed Branches     Cover
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
_tests/commands/background_image_test.rs              39                 0   100.00%           6                 0   100.00%          21                 0   100.00%           0                 0         -
_tests/commands/settings_test.rs                     220                 0   100.00%          18                 0   100.00%         166                 0   100.00%           0                 0         -
commands/background_image.rs                          22                 7    68.18%          11                 5    54.55%          19                 7    63.16%           0                 0         -
commands/hardware.rs                                  69                69     0.00%          22                22     0.00%          69                69     0.00%           0                 0         -
commands/settings.rs                                 526               526     0.00%          94                94     0.00%         448               448     0.00%           0                 0         -
commands/system.rs                                     6                 6     0.00%           3                 3     0.00%           5                 5     0.00%           0                 0         -
commands/ui.rs                                        17                17     0.00%           2                 2     0.00%          13                13     0.00%           0                 0         -
commands/updater.rs                                   97                97     0.00%          15                15     0.00%          66                66     0.00%           0                 0         -
enums/error.rs                                       105                 0   100.00%           8                 0   100.00%          89                 0   100.00%           0                 0         -
enums/hardware.rs                                    188                 1    99.47%          15                 0   100.00%         114                 0   100.00%           0                 0         -
enums/settings.rs                                    415                 6    98.55%          24                 0   100.00%         279                 0   100.00%           0                 0         -
infrastructure/database/db.rs                         21                21     0.00%           2                 2     0.00%          12                12     0.00%           0                 0         -
infrastructure/database/gpu_archive.rs                49                49     0.00%           4                 4     0.00%          18                18     0.00%           0                 0         -
infrastructure/database/hardware_archive.rs           41                41     0.00%           4                 4     0.00%          21                21     0.00%           0                 0         -
infrastructure/database/migration.rs                   8                 8     0.00%           1                 1     0.00%          37                37     0.00%           0                 0         -
infrastructure/database/process_stats.rs              41                41     0.00%           4                 4     0.00%          29                29     0.00%           0                 0         -
infrastructure/providers/linux/dmidecode.rs          229                15    93.45%          16                 3    81.25%         319                14    95.61%           0                 0         -
infrastructure/providers/linux/drm_sys.rs            143               143     0.00%          13                13     0.00%          87                87     0.00%           0                 0         -
infrastructure/providers/linux/hwmon.rs              119                94    21.01%           8                 6    25.00%          68                56    17.65%           0                 0         -
infrastructure/providers/linux/kernel.rs             165                22    86.67%          19                 2    89.47%         161                 8    95.03%           0                 0         -
infrastructure/providers/linux/lspci.rs               23                23     0.00%           1                 1     0.00%          12                12     0.00%           0                 0         -
infrastructure/providers/linux/net_sys.rs            171               171     0.00%          13                13     0.00%          93                93     0.00%           0                 0         -
infrastructure/providers/linux/procfs.rs             261                24    90.80%          25                 3    88.00%         222                19    91.44%           0                 0         -
infrastructure/providers/sysinfo_provider.rs          54                54     0.00%           2                 2     0.00%          45                45     0.00%           0                 0         -
lib.rs                                               205               205     0.00%           5                 5     0.00%         111               111     0.00%           0                 0         -
main.rs                                                3                 3     0.00%           1                 1     0.00%           3                 3     0.00%           0                 0         -
models/hardware.rs                                     9                 9     0.00%           1                 1     0.00%           7                 7     0.00%           0                 0         -
models/settings.rs                                   190                 0   100.00%          11                 0   100.00%         163                 0   100.00%           0                 0         -
platform/factory.rs                                   18                18     0.00%           4                 4     0.00%          15                15     0.00%           0                 0         -
platform/linux/cache.rs                               53                53     0.00%           4                 4     0.00%          38                38     0.00%           0                 0         -
platform/linux/gpu.rs                                139               139     0.00%          13                13     0.00%         102               102     0.00%           0                 0         -
platform/linux/memory.rs                              43                43     0.00%           6                 6     0.00%          41                41     0.00%           0                 0         -
platform/linux/mod.rs                                 34                34     0.00%          11                11     0.00%          70                70     0.00%           0                 0         -
platform/linux/network.rs                              4                 4     0.00%           1                 1     0.00%           4                 4     0.00%           0                 0         -
services/archive_service.rs                          417               417     0.00%          42                42     0.00%         333               333     0.00%           0                 0         -
services/background_image_service.rs                 165                96    41.82%          16                10    37.50%          93                59    36.56%           0                 0         -
services/cpu_service.rs                               32                32     0.00%           4                 4     0.00%          15                15     0.00%           0                 0         -
services/gpu_service.rs                               41                41     0.00%          12                12     0.00%          35                35     0.00%           0                 0         -
services/hardware_service.rs                          67                67     0.00%           5                 5     0.00%          43                43     0.00%           0                 0         -
services/language_service.rs                          21                 1    95.24%           3                 0   100.00%          13                 1    92.31%           0                 0         -
services/memory_service.rs                            22                22     0.00%           4                 4     0.00%          15                15     0.00%           0                 0         -
services/monitoring_service.rs                       261               261     0.00%          23                23     0.00%         150               150     0.00%           0                 0         -
services/motherboard_service.rs                       10                10     0.00%           3                 3     0.00%           7                 7     0.00%           0                 0         -
services/network_service.rs                            9                 9     0.00%           1                 1     0.00%           7                 7     0.00%           0                 0         -
services/process_service.rs                           86                86     0.00%           5                 5     0.00%          50                50     0.00%           0                 0         -
services/settings_service.rs                         246               129    47.56%          30                14    53.33%         234               129    44.87%           0                 0         -
services/system_service.rs                            22                22     0.00%           2                 2     0.00%          12                12     0.00%           0                 0         -
services/ui_service.rs                                45                45     0.00%           8                 8     0.00%          36                36     0.00%           0                 0         -
utils/color.rs                                        66                 1    98.48%           4                 0   100.00%          26                 0   100.00%           0                 0         -
utils/file.rs                                        224                 5    97.77%          14                 0   100.00%         144                 4    97.22%           0                 0         -
utils/formatter.rs                                   195                 8    95.90%          16                 0   100.00%         160                12    92.50%           0                 0         -
utils/ip.rs                                           65                 0   100.00%           5                 0   100.00%          33                 0   100.00%           0                 0         -
utils/logger.rs                                       71                71     0.00%           1                 1     0.00%          38                38     0.00%           0                 0         -
utils/rounding.rs                                     68                 0   100.00%           7                 0   100.00%          41                 0   100.00%           0                 0         -
utils/tauri.rs                                       138                 0   100.00%          17                 0   100.00%          82                 0   100.00%           0                 0         -
workers/hardware_archive.rs                           52                52     0.00%           6                 6     0.00%          36                36     0.00%           0                 0         -
workers/mod.rs                                        24                24     0.00%           2                 2     0.00%          16                16     0.00%           0                 0         -
workers/system_monitor.rs                             53                53     0.00%           4                 4     0.00%          36                36     0.00%           0                 0         -
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL                                               6127              3395    44.59%         621               391    37.04%        4622              2484    46.26%           0                 0         -

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 pull request refactors the GPU monitoring system to support AMD and Intel GPUs on both Windows and Linux, moving away from NVIDIA-only support to a vendor-agnostic architecture. The changes enable per-GPU metrics collection and archival for multiple vendors, improve data availability feedback in the insights UI, and establish a scalable foundation for cross-vendor GPU monitoring.

Changes:

  • Refactored GPU history storage from NVIDIA-specific (nv_gpu_*_histories) to vendor-agnostic (gpu_*_histories) across backend models and services
  • Implemented AMD GPU monitoring via ADL on Windows with new per-adapter async functions for usage and temperature metrics
  • Added Linux GPU metrics collection for AMD (via DRM/sysfs/hwmon) and Intel (via intel_gpu_top)
  • Updated archive service to calculate per-GPU statistics by device name instead of aggregating across all GPUs
  • Enhanced frontend InsightChart component to detect and display "no data available" messages for empty data periods

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/lang/en.json Added "noDataForPeriod" translation key for empty data message
src/lang/ja.json Added Japanese translation for "noDataForPeriod" message
src/features/hardware/insights/hooks/useInsightChart.ts Added hasData field to return value for empty data detection
src/features/hardware/insights/components/InsightChart.tsx Added no-data UI fallback, useEffect for data availability callback, and onDataAvailabilityChange prop
src-tauri/src/workers/system_monitor.rs Changed sample_gpu calls to await async invocations on Windows and Linux
src-tauri/src/services/monitoring_service.rs Introduced GpuSample type, refactored sample_gpu to async, added AMD sampling on Windows, implemented Linux GPU collection, updated update_gpu_histories to handle optional metrics
src-tauri/src/services/archive_service.rs Updated GpuMetricsCollector to use vendor-agnostic history fields and calculate per-GPU stats by name
src-tauri/src/models/hardware_archive.rs Renamed nv_gpu_* fields to gpu_* for vendor-agnostic support
src-tauri/src/models/hardware.rs Renamed nv_gpu_* fields to gpu_* in HardwareMonitorState
src-tauri/src/lib.rs Updated initialization to use renamed gpu_* history fields
src-tauri/src/infrastructure/providers/windows/adl_provider.rs Added get_amd_gpu_usage_per_adapter and get_amd_gpu_temperatures_per_adapter async functions for per-adapter metrics
Comments suppressed due to low confidence (5)

src/features/hardware/insights/components/InsightChart.tsx:157

  • The check chartData.every((v) => v == null) at line 149 is redundant because it duplicates the hasData computation from useInsightChart (line 331: hasData = filledChartData.some((v) => v != null)). The condition at line 149 is checking if all values are null, while hasData already tracks whether any non-null values exist. Replace this check with if (!hasData) to maintain consistency and avoid duplicate logic.
  if (chartData.every((v) => v == null)) {
    return (
      <div className="flex h-full w-full items-center justify-center">
        <span className="text-muted-foreground">
          {t("pages.insights.noDataForPeriod")}
        </span>
      </div>
    );
  }

src/features/hardware/insights/hooks/useInsightChart.ts:333

  • The new hasData field returned by useInsightChart lacks test coverage. The existing tests verify labels and chartData but don't assert on the hasData boolean, which is critical for determining when to display the "no data" message in the UI. Add test cases that verify hasData is true when data exists and false when data is empty.
  const hasData = filledChartData.some((v) => v != null);

  return { labels: filledLabels, chartData: filledChartData, hasData };

src-tauri/src/services/monitoring_service.rs:168

  • The get_gpu_name_from_lspci_by_vendor_id function is called once with vendor ID "1002" (AMD), but is used for all AMD cards in the loop. If there are multiple AMD GPUs, all will receive the same name from the first match found by lspci, making them indistinguishable in the UI and history storage. Consider using card_id to query lspci for each specific card or include the card ID in the name to ensure unique identification.
        let name =
          crate::infrastructure::providers::lspci::get_gpu_name_from_lspci_by_vendor_id(
            "1002",
          )
          .unwrap_or_else(|| format!("AMD GPU (card{})", card_id));

src-tauri/src/services/monitoring_service.rs:182

  • The get_intel_gpu_usage() function does not accept a card_id parameter, so if there are multiple Intel GPUs, all cards will report the same usage value returned by intel_gpu_top. This function should be modified to accept a card_id parameter and query the specific card's usage, or multiple Intel GPUs will show identical metrics.
        let usage = drm_sys::get_intel_gpu_usage()
          .await
          .map(|u| (u * 100.0) as f32)
          .ok();

src/features/hardware/insights/components/InsightChart.tsx:100

  • The onDataAvailabilityChange callback is defined as an optional parameter but is never passed when GpuInsightChart is invoked in the parent component (Insights.tsx). This means the callback will never be triggered, making the useEffect hook that calls it ineffective. Either pass a handler from the parent component or remove the unused callback parameter and effect.
  useEffect(() => {
    onDataAvailabilityChange?.(hasData);
  }, [hasData, onDataAvailabilityChange]);

Copilot AI review requested due to automatic review settings February 23, 2026 04:30

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

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

Comments suppressed due to low confidence (5)

src-tauri/src/services/monitoring_service.rs:184

  • The get_intel_gpu_usage() function is called for each Intel card in the loop, but it doesn't accept a card_id parameter and appears to return global Intel GPU usage (using intel_gpu_top which typically reports aggregate usage). When multiple Intel GPUs are present, each card will receive the same usage value. This should either be refactored to support per-card usage or documented as a known limitation.
      drm_sys::GpuVendor::Intel => {
        let usage = drm_sys::get_intel_gpu_usage()
          .await
          .map(|u| (u * 100.0) as f32)
          .ok();
        (format!("Intel GPU (card{})", card_id), usage, None)

src/features/hardware/insights/components/InsightChart.tsx:100

  • The onDataAvailabilityChange callback prop is defined and called when hasData changes, but it's not being passed or used by the parent component in Insights.tsx (line 458-464). The prop was added to allow the parent to respond to data availability changes, but without wiring it up in the parent, this functionality remains unused. Consider either removing this prop if it's not needed yet, or implementing the callback in the parent component to handle the no-data state appropriately.
  useEffect(() => {
    onDataAvailabilityChange?.(hasData);
  }, [hasData, onDataAvailabilityChange]);

src/features/hardware/insights/components/InsightChart.tsx:149

  • The condition chartData.every((v) => v == null) on line 149 is redundant since the hasData variable already performs this check on line 331 of useInsightChart.ts using filledChartData.some((v) => v != null). The condition here is logically equivalent but inverted. Consider using !hasData directly instead to avoid duplication and improve maintainability.
  if (chartData.every((v) => v == null)) {

src/features/hardware/insights/hooks/useInsightChart.ts:334

  • The new hasData field returned by useInsightChart is not tested. The test on line 137 validates empty data handling but doesn't check the hasData return value. Consider adding assertions for result.current.hasData in existing tests (e.g., expect(result.current.hasData).toBe(true) when data is present and expect(result.current.hasData).toBe(false) in the empty data test on line 137) to ensure the new field works correctly.
  const hasData = filledChartData.some((v) => v != null);

  return { labels: filledLabels, chartData: filledChartData, hasData };
};

src-tauri/src/services/monitoring_service.rs:169

  • The get_gpu_name_from_lspci_by_vendor_id function returns only the first matching GPU name found (line 15 returns immediately on first match). When multiple AMD GPUs are present, all AMD cards will receive the same name in the loop. This will cause incorrect GPU identification and potential data aggregation issues. Consider passing the card_id to the lspci function to match the specific card, or use a different naming strategy that includes the card ID to ensure unique names.
        let name =
          crate::infrastructure::providers::lspci::get_gpu_name_from_lspci_by_vendor_id(
            "1002",
          )
          .unwrap_or_else(|| format!("AMD GPU (card{})", card_id));

Comment thread src-tauri/src/services/monitoring_service.rs
@shm11C3 shm11C3 merged commit 3239cfb into develop Feb 23, 2026
22 checks passed
@shm11C3 shm11C3 deleted the feat/insight/add-support-gpu branch February 23, 2026 05:13
github-actions Bot pushed a commit that referenced this pull request Feb 24, 2026
- Features table: replace "GPU Insight (non-NVIDIA) ⚠️" with separate
  rows for AMD/Linux (✅) and macOS (✅)
- Insight screenshot section: update note from NVIDIA-only to reflect
  NVIDIA, AMD (Windows/Linux), and Apple GPU (macOS via IOKit) support
- FAQ: replace NVIDIA-only question with accurate multi-vendor answer
- Roadmap: mark AMD GPU (Insights) and macOS GPU Monitoring as done
- README.ja.md: apply same changes in Japanese; fix macOS OS table
  status from 🚧 to ✅

Triggered by:
- #1147 (feat) Support AMD GPU for Insights
- #1161 feat: add macOS GPU sampling functionality to monitoring service

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature frontend rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants