astarte-platform / astarte

Core Astarte Repository
https://docs.astarte-platform.org/
Apache License 2.0
240 stars 46 forks source link

Purge properties must be compressed using deflate #996

Open sorru94 opened 2 weeks ago

sorru94 commented 2 weeks ago

When dealing with properties the purge properties message is essential for the correct state synchronization of a device with an Astarte instance. The current specification requires the purge properties message payload to be compressed using deflate. This to minimize the size of the payload and increase the efficiency of the Astarte protocol. However, when dealing with resource-constrained embedded devices the overhead required to compress the payload might surpass the gained benefits. Let's take as an example the Astarte device SDK for Zephyr. With a simple application taking care of transmitting some datastreams and setting some properties. Excluding the compression the RAM heap usage never exceeds 6K Bytes. If we instead include the compression of the purge properties message the used RAM heap rumps up to over 14K Bytes. Furthermore, the purge properties message is not always transmitted or received when connecting to Astarte.

Some suggestions to improve this It would be awesome for a device to have the choice of compression or non-compression of the purge properties message. One first suggestion would be to encode the purge properties state in an empty cache message. The empty cache message payload is currently hardcoded to "1". However, this is of little utility as already receiving an empty cache message is unequivocal. The payload could be used to encode a choice in the purge properties compression.