advanced28 min studyLesson 297 in Engineering

A smaller file can demand a slower scan

Compare compressed transfer, decompression, value decoding, and memory movement with explicit byte domains and overlap assumptions.

On this page

What you’ll understand

  • Distinguish generic compression from column-specific value encoding.
  • Estimate serial and ideally overlapped transfer/decompression costs with consistent units.
  • Choose a codec using measured query and maintenance costs rather than compression ratio alone.

Columnar encodings reshape values before a generic codec compresses page data. Reading reverses those stages and then performs the query. Saving transfer bytes can help enormously on a slow storage path, yet a costly decompressor can dominate when data is cached or storage is fast. The useful comparison is the complete required operation under realistic resource limits. Compression ratio is one input, not the answer to whether a scan becomes faster.

Name the bytes at each stage

A dictionary or delta encoding changes how logical values are represented, while a codec such as Zstandard compresses the resulting page byte stream according to its specified framing. Generic decompression reconstructs those encoded bytes; it does not necessarily produce final Arrow arrays or application objects. Those may require further value decoding, structural reconstruction, conversion, and allocation. Record compressed bytes, decompressed encoded bytes, and fully materialized bytes separately. A claim of several gigabytes per second is uninterpretable if its denominator silently changes between these stages.

Parquet's compression and page-version rules specify exactly which portions are passed to a codec; page headers and structural sections need their own accounting. A reader must not infer that an entire row group is one opaque compressed stream. Codecs and parameters can differ in speed, ratio, memory requirements, and reader support. For Zstandard, the format contract includes frame parameters and bounded decoder requirements, not a promise of one universal throughput. Test representative page sizes, values, and hardware rather than adopting a historical speed ranking as a permanent property of a codec name.

R=UC,Tserial≈CBs+UD+Tvalues+TqueryR=\frac{U}{C},\qquad T_{\rm serial}\approx\frac{C}{B_s}+\frac{U}{D}+T_{\rm values}+T_{\rm query}
C is compressed page-data bytes, U the bytes after generic decompression but before further value decoding, B_s compressed-input storage bytes per second, and D decompressed-output bytes per second. The serialized model has no overlap; T_values and T_query are seconds for later stages.↔ Scroll wide equations horizontally.

Overlap is a resource assumption, not a free subtraction

A pipeline can overlap transfer of one page with decompression or query work on another, approaching a throughput determined by the slowest independent stage. That ideal needs enough work, buffers, and genuinely available resources. Two stages competing for the same CPU cores or memory bandwidth cannot both claim their isolated maximum throughput. Startup, tail drainage, small requests, and dependent dictionary loads also matter. Measure the full steady-state pipeline and its peak live memory rather than subtracting costs merely because an API is asynchronous.

For a serialized comparison that otherwise changes nothing, compression helps only if saved transfer time exceeds its extra decode time. The crossover changes when storage bandwidth, cache residency, CPU availability, or query work changes. A training input pipeline may favor a faster decoder to keep accelerators supplied; a cold archive scanned rarely may value reduced storage and transfer differently. Writing and compaction costs also belong in lifecycle evaluation. Preserve lossless semantics and exact result checks while varying parameters so a faster lossy or incompatible representation is not mistaken for an equivalent optimization.

Tideal pipeline≳max⁡(CBs,UD,Tvalues,Tquery),D>Bs1−1/R (R>1)T_{\rm ideal\ pipeline}\gtrsim\max\left(\frac{C}{B_s},\frac{U}{D},T_{\rm values},T_{\rm query}\right),\qquad D>\frac{B_s}{1-1/R}\ (R>1)
The maximum is an optimistic large-work lower-bound model with independent fully overlapped stages. The separate inequality is the serialized transfer-plus-decompression crossover against transferring U uncompressed bytes, excluding unchanged later work; all rates use the stated byte domains.↔ Scroll wide equations horizontally.

Benchmark the query and the lifecycle

Use the same data, row order, page boundaries, projected fields, predicates, concurrency, and cache conditions when comparing codecs. Report compression time, compressed size, decompression CPU, final query latency, memory, and errors. A file that is much smaller after an expensive rewrite may not repay that rewrite over its actual lifetime. Include difficult data such as high-entropy strings and changing distributions, because easy repeated samples can exaggerate savings. If projected scans touch only a subset of pages, compare that workload rather than claiming a full-file ratio predicts every query.

The roofline instrument demonstrates a separate memory-versus-floating-point ceiling after decoding. Reset, set both I=4 FLOP/byte and memory B=50 GB/s, predict 200 GFLOP/s, then Play or Step. Reset and set both I=32 and B=50, predict the fixed 1,000 GFLOP/s compute cap rather than 1,600, then inspect. Playback traces the selected ceiling; it does not run a codec or measure integer decode throughput. The analogy is that removing one resource limit can expose another, while actual compression choices need the stage-specific measurements above.

Compare two hypothetical codec choices

A selected scan contains 12 decimal GB of uncompressed encoded page bytes. Storage delivers compressed input at 2 GB/s. Codec A has ratio three and decompression output rate 6 GB/s. Codec B has ratio six and output rate 1 GB/s. Ignore all later work and overlap.

  1. Without generic compression, transferring 12 GB takes 12/2 = 6 seconds under the stated storage rate.

  2. Codec A transfers 12/3 = 4 GB in two seconds and decompresses 12 GB in two seconds, totaling four serialized seconds.

  3. Codec B transfers 2 GB in one second but takes twelve seconds to decompress, totaling thirteen seconds. Its smaller file is slower in this workload; ideal pipeline assumptions would change totals but still leave its decompression bottleneck.

The result

Codec A wins this particular serialized comparison at four seconds, while the stronger-ratio Codec B loses at thirteen. These are synthetic rates, not product benchmarks.

Explore the model

Interactive lab

Interactive lab · roofline

Saving bytes can expose another ceiling

Reset, set both I=4 FLOP/byte and memory B=50 decimal GB/s, predict 200 GFLOP/s, then Play or Step. Reset and re-enter I=32 and B=50 to predict the fixed 1,000 GFLOP/s compute cap. Playback only traces the roof; this post-decode floating-point model is not a codec, disk-bandwidth, or integer-decoder benchmark.

Saving bytes can expose another ceilingSynthetic roofline ceiling min(1000, B·I), in GFLOP/s, with B in decimal GB/s and I in FLOP/byte. Playback traces the roof without changing the selected kernel. This upper-bound model is not a measured throughput prediction, hardware comparison or price model. Current readings: Attainable ceiling: 640 GFLOP/s; Ridge intensity: 12.5 FLOP/byte; Ceiling regime: Memory-bound ceiling. All parameters are adjustable with the labeled controls below.Hypothetical roofline upper bound: 640 GFLOP per second at operational intensity 8 FLOP per byte and bandwidth 80 gigabytes per second.0.1110641101001000Operational intensity · FLOP/byte · log scaleCeiling · GFLOP/s · log scalePeak: 1000
Attainable ceiling / kernelBandwidth roof / traceCompute ceiling
Attainable ceiling
640 GFLOP/s
Ridge intensity
12.5 FLOP/byte
Ceiling regime
Memory-bound ceiling
t = 0 s

Synthetic roofline ceiling min(1000, B·I), in GFLOP/s, with B in decimal GB/s and I in FLOP/byte. Playback traces the roof without changing the selected kernel. This upper-bound model is not a measured throughput prediction, hardware comparison or price model. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forCompare resource-specific stages: fewer compressed bytes and faster end-to-end execution are related but distinct outcomes.

Check your understanding

A codec halves compressed input bytes but greatly increases decompression CPU while storage is already fast. Which evaluation is best justified?

Try it yourself

A scan has 8 GB of uncompressed encoded bytes, ratio four, storage rate 1 GB/s, and decompression output rate 2 GB/s. Estimate serialized transfer-plus-decompression time and the ideal independent-stage pipeline lower bound.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Compute compressed input size first, and keep transfer and output byte rates separate.

Compare with the solution

Compressed input is 8/4 = 2 GB, so transfer takes two seconds and decompression takes 8/2 = four seconds. The serialized total is six seconds. A fully overlapped independent two-stage ideal has a lower bound of max(2,4) = four seconds, excluding startup, drainage, and later decoding/query work; real stages may share resources.

Take it with you

  • Generic decompression and value decoding have different inputs, outputs, and costs.
  • Overlapped-pipeline estimates require independent resources and sufficient buffered work.
  • Choose codec settings from measured lifecycle and query costs with exact semantic checks.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.