No compression option
I'm working on a multi client publish/subscribe IoT targeted application based on MQTT, planning to compress payloads using ztsd. My largest data payloads are in the 200-500kb range, with some really small heartbeat type messages. For the heart beat messages, its nor worth compressing, so I send as-is and at the client side check to see if its a valid zstd payload looking at the return value of ZSTD_findDecompressedSize(). I was wondering if there is a way to send the data with no compression, and if so what the compressionLevel for it would be. It would be fine to add a few bytes overheard for the zstd frame, if it would save me CPU cycles due to no compression.
Zstd won't attempt to compress data smaller than 7 bytes. I wouldn't expect compression of tiny data (say < 50 bytes) to eat up many CPU cycles, so long as you are reusing the ZSTD_CCtx*. If you aren't reusing the CCtx, then allocating and initializing the CCtx will be most of the cost, so I don't think you'd even see the compression in the profile.
You could try setting the compression level to ZSTD_minCLevel(), which will be in effect no compression, but I wouldn't expect too much CPU gains for very small data, only for large data.
Thanks I will reuse the CCtx and set the compression level to ZSTD_minCLevel()
Does level=0 mean there is some compression ? This is a bit unexpected, since, conventionally level=0 (should?) mean(s) no compression.
Does
level=0mean there is some compression ? This is a bit unexpected, since, conventionallylevel=0(should?) mean(s) no compression.
level 0 means "default level".
A lot of parameters have this convention that 0 means "default".