Memory-Assisted Compression of Heavy-Tailed Integer Streams

Many real data streams have no natural limit on their symbol set. Network flow identifiers, click-stream item IDs and open-vocabulary tokens behave like draws from the integers, with a few very common values and a long tail of rare ones. A compressor that must learn the distribution as it goes (a universal code) pays a "learning tax": extra bits spent describing what it has inferred about the source. On an unbounded alphabet that tax can be infinite unless the distribution is known to decay fast enough. Separately, in network compression a central decoder often holds a large archive of earlier traffic from the same kind of source, while each edge encoder sees only a short new packet. Earlier work showed that this decoder-side memory can almost eliminate the learning tax, but only for small, fixed alphabets such as bytes.

This note proposes to join the two. An encoder that knows only how much memory the decoder holds, and nothing about its contents, should compress a short block from an unbounded alphabet by keeping a growing number $k$ of the most likely symbols exactly and lumping the rest into an escape symbol. It should choose $k$ jointly from the block length and the memory size, and it should describe its fitted model only up to a short "bin index" that the decoder resolves against its memory. The central claim is that memory at the decoder moves the point at which keeping more symbols stops paying off. The encoder can then keep many more symbols than single-source theory allows, and this gain exists only when a vanishing error probability is tolerated. Under a strict zero-error requirement it disappears even for well-behaved tails.

Background and the gap

Three findings frame the problem. For integer-valued sources, lossless universal compression is possible only over an envelope class: all distributions bounded symbol-by-symbol by a known decreasing function $f$ whose values sum to a finite number. Acharya et al. give tight redundancy bounds for power-law and exponential envelopes using Poisson sampling, a trick that makes symbol counts independent. Silva and Piantanida relax to almost lossless coding, where the per-symbol error rate must vanish as the block grows. Their scheme truncates the alphabet to $k_n$ symbols, escapes the tail, and runs a finite-alphabet universal code. They identify a critical growth rate $u^*_f(n)$ that separates two regimes. Below it, truncation beats lossless coding by a vanishing-ratio margin. Above it, the gain collapses. The rate is $n^{1/(\alpha-1)}$ for envelopes decaying like $i^{-\alpha}$ and $\log n$ for exponential envelopes. Their later work extends feasibility to all finite-entropy memoryless sources (Silva and Piantanida). All of this is single-terminal, and it supplies our truncation mechanism and the quantity we expect to move.

On the distributed side, Beirami and Fekri study an encoder that knows only the decoder's memory length $m$. They prove that under zero error this memory yields no reduction in learning cost. With a small error probability, partitioning the parameter space into ellipsoids around the decoder's maximum-likelihood estimate removes most of it. On 256-symbol memoryless sources, this drives redundancy from above 0.6 to about 0.05 bits per symbol. Their correlated-parameter analysis gives a learning cost of roughly $\frac{d}{2}\log(1+n/m)$ for $d$ parameters (Beirami and Fekri). The 2019 "both or nothing" result says that one-sided side information gives no gain under strict losslessness (Beirami and Fekri). These papers supply the binning mechanism and the zero-error barrier we must respect, but they assume a fixed finite parameter dimension. In our setting the dimension is itself a design choice that grows with $n$. Nothing in the file studies memory-assisted or Slepian–Wolf-style universal coding over envelope classes.

Core Claim

Combining the two results gives a cost model for a truncation level $k$. Learning the retained symbols costs about $\frac{1}{2}\log(1+n/m)$ bits each instead of $\frac{1}{2}\log n$. The tail costs a term that shrinks as $k$ grows, governed by the envelope mass beyond $k$:

$$ R_n(k, m) \;\approx\; \frac{k}{2}\log\!\left(1+\frac{n}{m}\right) \;+\; T_f(k, n), $$

Here $R_n$ is the total redundancy in bits over a block of $n$ symbols, $m$ is the decoder's memory length, and $T_f(k,n)$ is the escape-and-tail cost for envelope $f$. Minimizing over $k$ gives a memory-dependent critical sequence $u^*_f(n, m)$. It should reduce to Silva–Piantanida's $u^*_f(n)$ when $m=0$ and grow without bound as $m/n$ grows.

The first expected outcome is achievability. Choosing $k=u^*_f(n,m)$ with bin-index model description and a vanishing error probability attains $R_n$ above. The second is a converse showing that no scheme with decoder-only memory beats the single-source envelope redundancy under zero error, even for summable $f$. That would be an infinite-alphabet extension of the Beirami–Fekri barrier. The third is that the extra symbols the encoder can afford come entirely from the almost-lossless relaxation, which therefore removes both obstacles at once. These are conjectures. The equation is a heuristic obtained by substituting the Beirami–Fekri per-parameter cost into the Silva–Piantanida truncation argument. Proving or refuting the form is the main theoretical task.

Research Program

The theoretical part has three pieces. The first is achievability. We would build the encoder as follows: truncate at $k$, compute a quantized type of the retained symbols in the style of Iri and Kosut, and send only a short hash of that type. The decoder resolves the hash by choosing the candidate type nearest its memory estimate, which is the ellipsoidal-partition idea applied at growing dimension. The encoder then sends the sequence index within the type class and Elias-codes escaped symbols, or drops them in the purely almost-lossless variant. The second piece is to analyse the hash collision probability as $k$ grows, which is where the fixed-$d$ penalty term $\mathcal{F}(d,p_e)$ of Beirami and Fekri must be redone. The third is the zero-error converse, by reduction to the single-source envelope lower bound of Acharya et al.

The algorithmic part is a working coder whose encoder is linear time in $n$, plus a decoder that searches the hash bin. This keeps the scheme constructive, unlike annealing-based universal lossy coders (Jalali and Weissman).

Baselines

The naive reference point is per-symbol Elias integer coding with no model. It tells us how much any learning buys on heavy-tailed data.

The strongest single-source competitor is Silva–Piantanida truncation with $k=u^*_f(n)$ and a finite-alphabet universal code, ignoring the decoder entirely. It is the best known envelope-class scheme. We would run it on identical blocks with the same escape coder. Beating it means lower total redundancy at matched symbol error rate whenever $m \gg n$.

The strongest distributed competitor is Beirami–Fekri DUCompM with a static truncation, at $k=256$ and $k=65{,}536$ with escape. On byte sources it reports roughly 0.05 bits per symbol versus above 0.6 for plain universal coding, at $n=512$ and $p_e=10^{-6}$ (Beirami and Fekri). For integer-alphabet versions of this baseline there is no reported result on Lacuna, so we would implement it with the same hash-bin decoder and the same $p_e$ target. Beating it means lower redundancy across a sweep of $n$ and $m$, with no regime where static $k$ wins by more than noise.

The upper reference is the shared-memory scheme UCompM, in which the encoder also sees the memory. The gap between our scheme and UCompM measures the cost of the encoder's ignorance.

The key ablation runs our coder unchanged except that $k$ follows the single-source rule $u^*_f(n)$. This isolates whether the joint choice of $k$ from both $n$ and $m$ matters.

Why not just…?

Why not just truncate to a fixed top-$K$ and run the existing finite-alphabet memory-assisted coder? This is the real threat, and it is the static-$K$ baseline above. Silva and Piantanida show that a fixed $K$ cannot make distortion vanish as $n$ grows. That is an asymptotic statement, though, and at practical block lengths a well-tuned $K$ may be nearly as good. The $n$–$m$ sweep settles this. If a single tuned $K$ matches the adaptive rule across the sweep, the contribution shrinks to the converse and the theory, and we will report that.

Why not just plug $d=k_n$ into the Beirami–Fekri bound? That substitution is exactly our heuristic. It ignores that the tail cost and the hash-collision penalty both depend on $k$, so the optimal $k$ is not the single-source one. The ablation tests whether this coupling has any practical effect.

Why not use the decoder's memory to rank symbols and let the encoder send ranks? The encoder does not know the ranking, so ranks are meaningless to it without communication. The hash-of-type construction is precisely the way to use the memory without the encoder seeing it.

Why not a neural distributed coder? Neural DSC learns conditional VQ-VAE latents for images. It uses a fixed finite codebook, requires offline training, and provides no vanishing-error guarantee, so it does not address unbounded symbol sets or short unknown sources. We do not compete with it on images.

Proposed Experiments

The synthetic experiments use i.i.d. Zipf sources with $\alpha$ between 1.1 and 2.0, a summable subrange of the skewness sweep in CounterSnake, plus geometric sources. They sweep $n$ from 256 to 32k and $m/n$ from 0 to 1000. They measure redundancy against true entropy, symbol error rate, and block decoding failure. The decisive check is whether the empirically optimal $k$ tracks the predicted $u^*_f(n,m)$ and whether, under $p_e=0$, all memory-assisted variants collapse to the single-source curve as the converse predicts.

The real-data experiments use the CAIDA IP backbone trace (25.1M items, 1.0M distinct flows) and the Kosarak click-stream (8M items, 41K distinct), both described in CounterSnake. They treat flow or item IDs as integer symbols ordered by first appearance in the memory window. An earlier time window serves as decoder memory and short later blocks are compressed. Here redundancy is measured against an oracle code fitted to the block, and we report symbol error rate.

As an external sanity check, the Beirami–Fekri 2019 study reports 1.39× to 2.32× side-information gains for 32kB packets as memory grows from 128kB to 8MB. These are byte-level Markov results, so they are context and not a direct target. The proposal succeeds if the adaptive coder beats both the single-source truncation baseline and the static-$K$ DUCompM on CAIDA and Kosarak at matched error rate, and if the ablation shows that this margin comes from the memory-aware choice of $k$.