views:

61

answers:

3

In the chapter Filters (scroll down ~50%) in an article about the Remote Call Framework are mentioned 2 ways of compression:

  • ZLib stateless compression
  • ZLib stateful compression

What is the difference between those? Is it ZLib-related or are these common compression methods?

While searching I could only find stateful and stateless webservices. Aren't the attributes stateless/ful meant to describe the compression-method?

+1  A: 

From Transport Layer Security Protocol Compression Methods:

Compression methods used with TLS can be either stateful (the compressor maintains it's state through all compressed records) or stateless (the compressor compresses each record independently), but there seems to be little known benefit in using a stateless compression method within TLS.

Some compression methods have the ability to maintain history
information when compressing and decompressing packet payloads. The
compression history allows a higher compression ratio to be achieved on a stream as compared to per-packet compression, but maintaining a
history across packets implies that a packet might contain data needed to completely decompress data contained in a different packet. History maintenance thus requires both a reliable link and sequenced packet delivery. Since TLS and lower-layer protocols provide reliable, sequenced packet delivery, compression history information MAY be maintained and exploited if supported by the compression method.

Jakub Konecki
So stateful compression leads to higher compression-ratio when the used method supports history?
MOnsDaR
I would think so, but probably, as stated in the linked document, the increase isn't that large...
Jakub Konecki
+1  A: 

In general, stateless describes any process that does not have a memory of past events, and stateful describes any process that does have such a memory (and uses it to make decisions.)

In compression, then, stateless means whatever chunk of data it sees, it compresses, without depending on previous inputs. It's faster but usually compresses less; stateful compression looks at previous data to decide how to compress current data, it's slower but compresses much better.

Vinko Vrsalovic
+1  A: 

Zlib is a compression algorithm that's adaptive. All compression algorithms work because the data they work on isn't entirely random. Instead, their input data has a non-uniform distribution that can be exploited. Take English text as a simple example. The letter e is far more common than the letter q. Zlib will detect this, and use less bits for the letter e.

Now, when you send a lot lot of short text messages, and you know they're all in English, you should use Zlib statefull compression. It would keep that low-bit representation of the letter e across all messages. But if there are messages in Chinese, Japanese, French, etc intermixed, stateful compression is no longer that smart. There will be few letters e in a Japanese text. Stateless compression would check for each message which letters are common. A wellknown example of ZLib stateless compression is the PNG file format, which keeps no state between 2 distinct images.

MSalters