commit | 162a1bd4b598d06d893049bf66ef7cd03640f62e | [log] [tgz] |
---|---|---|
author | George Liu <liuxiwei@ieisystem.com> | Fri Jul 25 16:20:58 2025 +0800 |
committer | George Liu <liuxiwei@ieisystem.com> | Fri Jul 25 16:40:38 2025 +0800 |
tree | 2d23b525f1f18b0f049f455940bc2d3111f7b794 | |
parent | 6f128345845e973856cd3a67c14d99cde0711278 [diff] |
Avoid redundant virtual sensor updates on unchanged values This patch fixes a potential memory growth issue caused by handling PropertyChanged signals without checking whether the new value differs from the previous one. Previously, the virtual sensor's `updateVirtualSensor()` method was called unconditionally whenever a "Value" property change signal was received. If a large number of D-Bus PropertyChanged signals were forged or triggered in rapid succession with the same value (e.g., during stress testing), this could result in frequent unnecessary updates, which in turn caused increased memory usage in both the sensor process and the dbus-broker. With this change, the handler now compares the new value with the current stored value and only invokes `updateVirtualSensor()` when there is a real change. This mitigates unnecessary CPU and memory load in high signal traffic scenarios. Change-Id: I345188fa9e361b2cc972cdbb40c911be89a5d661 Signed-off-by: George Liu <liuxiwei@ieisystem.com>
phosphor-virtual-sensor reads the configuration file virtual_sensor_config.json
from one of three locations:
/var/lib/phosphor-virtual-sensor
/usr/share/phosphor-virtual-sensor
By default the repository will install a sample config into (3).
There are two types of data in this file.
See virtual_sensor_config.json
in this repository for an example. Sensors added this way can use any expression that is accepted by exprtk.
For example:
{ "Desc": { "Config": "D-Bus" } }
Sensors added this way can only use a set of restricted calculations. Currently supported types are Average
, Maximum
, Minimum
, Sum
and ModifiedMedian
.
The virtual sensor configuration information needs to be added into the relevant hardware configuration file in entity-manager. This method of adding a virtual sensor allows a recipe that builds for different hardware configurations to have different virtual sensors for each configuration.
The virtual sensor configuration in entity manager follows a different format to the JSON in virtual_sensor_config.json
(specified in entity-manager/schemas/VirtualSensor.json).