psud: adding led state change detection mechanism to prevent unnecessary updated to redis #714
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces improvements to the PSU daemon by preventing overwriting of values to Redis database even when no value has changed by introducing LED status change detection.
LED status change detection - Adding a
led_statusinstance variable to store the last recorded led status color and an instance methodset_led_statusto update and store the led status and return True if status changed else False. This reduces writing this value to PSU_INFO_TABLE every 3 seconds even though there was no change.Additionally, existing tests were updated to include above change changes.
test_update_led_colorUpdatesMotivation and Context
Every 3 seconds the daemon writes
led_statusfields to Redis even though there isn't much changes during the normal execution. This results in unnecessarily Redis traffic and overwriting values in the database. Instead, we can keep track of this info and update it only when it changes.Also, adding an instance variable to the
PsuStatusclass will not be a burden since the value stored will be a class variable predefined here or predefined and fetched here Hence no duplicate memory allocated but rather just be a reference to this class variable which will be stored here.How Has This Been Tested?
The changes were tested on both virtual and physical platforms.
Additional Information (Optional)