-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RSDK-9344] Use snappy for robot configuration compression #366
base: main
Are you sure you want to change the base?
[RSDK-9344] Use snappy for robot configuration compression #366
Conversation
6f0bd53
to
d315660
Compare
encoded_cfg.len(), | ||
compressed.len() | ||
); | ||
self.set_blob(NVS_ROBOT_CONFIG_KEY, compressed.into())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing to contemplate here is what it might mean if we ever wanted to change this compression algorithm, or not do compression anymore. What would be the implications for upgrade? OTA?
Ok(()) | ||
} | ||
|
||
fn get_robot_configuration(&self) -> Result<RobotConfig, Self::Error> { | ||
let robot_config = self.get_blob(NVS_ROBOT_CONFIG_KEY)?; | ||
RobotConfig::decode(&robot_config[..]).map_err(NVSStorageError::NVSValueDecodeError) | ||
let mut decompressed_robot_config = vec![]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing we could do to harden this here would be that if we fail to decompress the buffer with snappy, that we then try to just feed the raw blob RobotConfig::decode
. That'd protect against a situation where you had a non-compressed robot config in NVS, got OTA updated to a version that expected a compressed robot config, and then for some reason when you came back online were unable to reach app and the expectation would be to use the cached config.
d315660
to
c937107
Compare
snap
:App/part. size: 3,452,128/4,128,767 bytes, 83.61%
snap
:App/part. size: 3,487,808/4,128,767 bytes, 84.48%
To test, I pasted a well-known large configuration (obtained by looking at the debug expansion of a fragment) into an attribute section of a sensor. Logs say:
So a 2,775 byte savings here, which isn't nothing given our NVS size bounds. The choice of snappy was somewhat arbitrary here, in that I tried it and it worked.