The QMIN encoder tracks stream and dynamic table entry relationships using checkpoints. A checkpoint is a way to address a range of dynamic table entries and streams at the same time. The diagrams below describe a high-level model of the encoder state.
We will start with the encoder shortly after it began operating. Header block for Stream 5 has been encoded, with the following header fields, in order:
The next diagram shows the encoder state after two more things have occurred, in order:
In this diagram, we are skipping ahead: five header blocks have been encoded, three flushes have been issued, of which two have been acked. We can see that
Since the previous state, two first streams, Stream 5 and Stream 7, have been closed, and the flush has been acknowledged. Note that entries 66 and 67 are now available for encoding.
There are three LIVE checkpoints, each referenced by at least one stream. They cannot be marked DEAD yet.
It turns out that Stream 11 is going to live for a long time. While it is uploading 7 TB of data, Stream 9 and Stream 13 have finished. One of the LIVE checkpoints is no longer referenced by any streams.
The encoder can use a number of strategies to decide when to declare a checkpoint DEAD. Just because a LIVE checkpoint is not referenced by any streams does not mean that it should be declared DEAD: the entries it references may repeat again and so, unless there is memory pressure, the encoder should keep its checkpoints LIVE. Nevertheless, here, for illustration purposes, we declare a LIVE checkpoint DEAD.
Note how entry 65 is no longer available for encoding, as the victim checkpoint was the only one referencing it.
Once a DEAD checkpoint is not referenced by any streams, there is no reason to keep it around -- it can be immediately dropped.
Because entry 65 is no longer referenced by any checkpoint, it is evicted and the slot 65 in the dynamic table becomes available for reuse.
Stream 15 is created and its header block encoded:
Here, Stream 11 has finished and the encoder flushes again.
Note that the proof-of-concept QMIN Encoder does not make objects for streams; nor does it maintain links from checkpoints to dynamic table entries or vice versa. Instead, it uses bitmap-based lists of entry and stream IDs per checkpoint object. This approach uses less memory and is simple to implement.