v1.8.0 — passthrough, and a cost table that admits it is not linear
decompress: 'passthrough'
Asks for gzip as usual and hands the coded body back with its Content-Encoding and
Content-Length intact. On a 4 MB body through a proxy, measured end to end: 118 ms decoding
against 82.5 ms passing through — 30% — with 2.76× fewer wire bytes at the same time.
It is not a variation on decompress: false. That one also drops gzip from Accept-Encoding, so
the origin sends plaintext and the wire grows 2.76×: it loses on both sides.
It only helps a caller who never needs the plaintext. If you parse the body, the decode is work
you owe and passthrough merely moves it downstream. It is not a general optimisation.
The cost table is replaced
Same origin, same corpus, same proxy, current build, repetitions differenced so the connection
cancels:
| Body | per request, pooled | per decompressed MB |
|---|---|---|
| 1 KB | 0.5 ms | — |
| 16 KB | 3.5 ms | 224 |
| 64 KB | 7.5 ms | 120 |
| 256 KB | 20.5 ms | 82 |
| 1 MB | 51.5 ms | 51 |
| 4 MB | 104 ms | 26 |
The per-MB column is new and it is the point. It falls 8.6× end to end, so there is no per-MB
rate for this package. A least-squares line is 9.17 + 24.86 × MB, which predicts 9.17 ms for a
1 KB body against a measured 0.5 — wrong by 18×. Interpolate within the table; do not extrapolate
from a rate.
The reason is that V8 tiers up inside a single request: a 4 MB body pays interpreted execution
for its first megabyte and runs the rest optimised. 51.5 + 3 × 17.5 = 104 fits.
A "when not to use this package" section
The docs priced the package without ever saying when the answer is not to use it.
A billion 4 MB requests is ~$2,385 of Workers CPU. That load is ~386 req/s and 4.5 Gbps, which three
dedicated boxes carry for ~$600 — servers are ~4× cheaper for large bodies. Two things flip it:
egress, which Workers does not bill and which can dwarf everything elsewhere; and body size, under
~128 KB where Workers wins on price and gives away geography and operations.
If you can run Node, run Node — undici with a ProxyAgent does this over native TLS at a
tenth of the CPU, and then this package is unnecessary. It exists because a V8 isolate cannot, not
because it is a better way.
1251 offline tests pass.