Skip to content

Fix shared memory reading to capture all sensor data from HWiNFO#7

Open
gon3456 wants to merge 1 commit intozachstence:mainfrom
gon3456:fix-shared-memory-reading
Open

Fix shared memory reading to capture all sensor data from HWiNFO#7
gon3456 wants to merge 1 commit intozachstence:mainfrom
gon3456:fix-shared-memory-reading

Conversation

@gon3456
Copy link
Copy Markdown

@gon3456 gon3456 commented Mar 20, 2025

Problem

Some of HWiNFO's sensor data (sensors with indices 23-27) were not being retrieved. Upon examination of the debug logs, the readings associated with these sensors were reported as 0, when in fact they existed.

Cause

The cause of the problem was in the way shared memory was read. The previous code was reading headers, sensors, and readings separately, so it was not reading all the data. Particularly with the specified buffer size, some of the reading sections were missing.

Solution.

Modified HWiNFO's shared memory to read as a whole at a time:

  1. first read the header only and calculate the overall size of the shared memory
  2. read the entire shared memory at once based on the calculated size 3.
  3. extract and process the sensor and reading sections appropriately from the read byte array

This ensures that data from all sensors is retrieved correctly.

Technical Background

This problem was solved with the assistance of AI. Although I myself was new to Go and not familiar with HWiNFO's internal structure, I was able to identify the memory mapping issue by analyzing the debug logs and the hwisenssm2.h header file.

With the fix, we are now getting data correctly from sensors (PresentMon, network interface, etc.) that previously had 0 readings.

@gon3456
Copy link
Copy Markdown
Author

gon3456 commented Mar 20, 2025

As additional information, it should be noted that this problem is environment-dependent. It tends to occur especially under the following conditions

  1. environments with a large number of sensors (especially if there are more than 28 sensors)
  2. environments with a large number of readings (especially if there are more than several hundred readings)

When a problem occurs, the data in the back part of the sensor index (in this case, after index 23) is completely missing. The logs appear to show that the sensor was read successfully, but the readings associated with that sensor are reported as zero.

This occurs because the shared memory reading method is designed for environments with a small number of sensors and readings, and not enough memory space is reserved for larger systems. This correction will ensure that all sensor data is captured regardless of the environment.

Test environment:

  • CPU Intel Core i9-14900KS
  • GPU NVIDIA GeForce RTX 4090
  • Memory 64GB
  • Multiple drives and network interfaces
  • Total number of sensors: 28
  • Total number of readings: 671

@gon3456
Copy link
Copy Markdown
Author

gon3456 commented Mar 20, 2025

This fix is expected to resolve the issue reported in Issue #5.

@DanubeRS
Copy link
Copy Markdown

Built your PR branch from source, and can verify it functions well, with all the missing sensors now present in InfluxDB, including frame time stats, which I was missing.

image

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.

2 participants