psud: Optimize Redis updates by conditionally writing static fields #717
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 optimizations for Redis database operations through conditional field updates for the psud.
Conditional field Updates -
PsuStatusclass already has methods and stores vital information needed to detect when any PSU info fields change. We use this to our benefit to only write those fields which frequently change like thetemp,voltage,current,power, etc while only occasionally writing fields which rarely change during daemon run likemodel number,serial number,revision,presence,status,is_replaceableandthreshold levelsAdditionally, existing tests were updated to include above change changes and to mock the
FieldValuePairsconstructor.test_power_thresholdUpdates_construct_expected_fvpUpdates - Helps accurately create theexpected_fvpobjects based on conditional field inclusion logic to help verify the Redis payload field.Motivation and Context
Why Conditional field Updates :
Every 3 seconds the daemon writes full PSU info to Redis even though much of the information rarely changes like the
model number,serial number,revision,presence,status,is_replaceableandthreshold levelswhich is adding to unnecessary traffic to Redis. Rather we can write these fields only when a presence change is detected while always writing the frequently changing fields liketemp,voltage,current,power, etc to ensure updated info stays in Redis.No additional changes is required as all info needed for detecting change in already part of PsuStatus object.
Overall benefit :
Before, roughly 18 fields written to Redis every 3 seconds per PSU
After roughly 8-9 frequently-changing fields + conditional fields only when changed
Estimated Reduction of approximately 45-50% reduction in Redis write payload volume under steady state
How Has This Been Tested?
The changes were tested locally on both virtual and physical platforms.
Additional Information (Optional)