Skip to content

pmdalmsensors: query only the requested chip during metric fetch - #2665

Open
Ali-Nasrolahi wants to merge 1 commit into
performancecopilot:mainfrom
Ali-Nasrolahi:improve-lmsensor-fetch
Open

pmdalmsensors: query only the requested chip during metric fetch#2665
Ali-Nasrolahi wants to merge 1 commit into
performancecopilot:mainfrom
Ali-Nasrolahi:improve-lmsensor-fetch

Conversation

@Ali-Nasrolahi

Copy link
Copy Markdown

PMDA lmsensors: Reduce redundant sensor probing during metric fetches

Patch Description

This patch optimizes the lmsensors PMDA by avoiding redundant full-system sensor scans when serving metric fetch
requests. Currently, every metric fetch executes sensors -j which probes all sensor chips, even though only a
single metric value is ultimately returned. As a result, a PCP fetch involving multiple metrics repeatedly re-reads the
same hardware. This patch records the originating lm_sensors chip for each metric during PMDA initialization and uses
that information to query only the chip associated with the requested metric.

In other words, instead of executing sensors -j, we run sensors -j <chip> which reduces the amount of work that is
needed.

Additionally, the cost with current implementation grows with:

  • the number of sensor chips present,
  • the latency of individual sensor backends,
  • and the number of metrics requested by PCP clients.

Related Issue

While investigating why the PMDA was occasionally timing out, I found that one sensor backend on my system requires
roughly half a second to respond. Because the PMDA executes a full sensors -j invocation for every metric, the latency
combined across all requested metrics, which then exceeded the PMCD request timeout and causing all metrics in the
request to fail. Since only one metric value is needed for each callback, querying only the corresponding sensor chip
avoids repeatedly waiting on unrelated hardware.

For the context, my environment is Fedora 44 with PCP 7.1.5:

❯ rpm -q pcp pcp-pmda-lmsensors
pcp-7.1.5-3.fc44.x86_64
pcp-pmda-lmsensors-7.1.5-3.fc44.x86_64

Warm Regards,
Ali :)

    The lmsensors PMDA currently executes a full `sensors -j` scan for
    every metric fetch, even though only a single metric value is
    requested. Since each invocation probes all detected sensor chips,
    the same hardware is repeatedly queried while serving a single PCP
    fetch request.

    Store the original lm_sensors chip name during metric discovery and
    use it to query only the chip associated with the requested metric.
    This preserves the existing fetch semantics while avoiding redundant
    probing of unrelated hardware.

    The change reduces the amount of work performed per metric fetch and
    improves scalability on systems exposing many sensor devices or slow
    sensor backends.

Signed-off-by: Ali Nasrollahi <A.Nasrolahi01@gmail.com>
@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Repository UI (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 9599868b-f7cc-4a3b-b1a3-69ca2fc72a83

📥 Commits

Reviewing files that changed from the base of the PR and between 0c6ddfc and 49cf76b.

📒 Files selected for processing (1)
  • src/pmdas/lmsensors/pmdalmsensors.python

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved hardware sensor readings by associating each metric with its originating sensor chip.
    • Ensured sensor values are retrieved from the correct chip when multiple chips expose similar metrics.

Walkthrough

lmsensors_get now accepts an optional chip filter, records chip ownership for generated sensor names, and uses that mapping during per-metric fetches.

Changes

lm_sensors chip scoping

Layer / File(s) Summary
Track chips and filter acquisition
src/pmdas/lmsensors/pmdalmsensors.python
Adds the sensorchips mapping, supports an optional chip argument, filters sensors -j acquisition, and records each metric’s originating chip.
Fetch metrics from mapped chips
src/pmdas/lmsensors/pmdalmsensors.python
Passes the mapped chip when fetching each requested sensor instance.

Poem

A rabbit watched the sensors glow,
Chips now guide each metric’s flow.
Names remember where they start,
Fetches seek their matching part.
“Hop!” says Bun, “the readings align!” 🐇

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: fetching metrics from only the requested chip.
Description check ✅ Passed The description is directly related to the change and explains the optimization in detail.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Ali-Nasrolahi
Ali-Nasrolahi marked this pull request as ready for review July 25, 2026 04:26
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.

1 participant