Zstandard (ZSTD) is a compression option for trading storage efficiency against compression speed. It appears in both in-memory experiments and columnar Parquet storage, where smaller representations can also reduce storage and cache pressure. section 6.2.3 section 8.2.2
The measured and practical trade-offs are:
- Compared with LZ4 through Blosc, Zstandard takes longer to compress but produces a substantially smaller representation. section 6.2.3
- A benchmark compresses the same representation in 919 ms at 366 KB with Zstandard, versus 527 ms at 5,204 KB with LZ4. section 6.2.3
- Applied to every column in the example Parquet file, ZSTD reduces storage from 110 MB with Snappy to 82 MB. section 8.2.2
Selecting Zstandard in Blosc
Use Blosc's array-packing interface with cname='zstd' to benchmark or create a Zstandard-compressed representation, then compare its timing and byte length with cname='lz4'. section 6.2.3
Writing ZSTD-compressed Parquet
Pass compression="ZSTD" to pq.write_table when writing a Parquet table to apply Zstandard compression across its columns. section 8.2.2
%timeit rep_lz4 = blosc.pack_array(rep_tile_arr, cname='lz4') #1 rep_lz4 = blosc.pack_array(rep_tile_arr, cname='lz4') %timeit rep_std = blosc.pack_array(rep_tile_arr, cname='zstd') #2 rep_std = blosc.pack_array(rep_tile_arr, cname='zstd') print(len(rep_lz4) // 1024) print(len(rep_std) // 1024)
Inspect the runnable comparison that times Blosc packing with LZ4 and Zstandard and prints both compressed sizes. section 6.2.3
