Skip to main content

WarpCompress: adaptive, parallel (de)compression in pure Python with RAW/ZERO/LZ4/Snappy/Zstd per chunk, hybrid Zstd, and batched I/O.

Project description

🚀 WarpCompress

Massive-file-ready (100GB+), parallel, lossless compressor/decompressor with mmap scatter–gather I/O, zero-copy Zstd decode, and an adaptive throughput mode.

CI Python License Platform

⚡️ Why WarpCompress?

  • Fast: C-extension codecs + multi-threading + zero-copy Zstd decompress_into()
  • Scalable: mmap chunking and scatter–gather decompression → constant RAM, even for 100GB
  • Practical: Integrity footer (BLAKE3/xxhash), --verbose per-chunk timings, and an auto throughput mode

✨ Features

  • Format v2 writer: stores both compressed sizes and original per-chunk sizes → true parallel scatter–gather decompression
  • Backward-compatible reader: v1 files stream sequentially (still constant RAM)
  • Throughput mode (--level throughput): adapts chunk size, thread counts, and zstd threads by input size/cores
  • Integrity footer: --checksum {none,blake3,xxh64,blake2b}
  • Verbose profiling: --verbose prints per-chunk throughput

🔧 Install

pip install -e .[hashes]
# Base deps: lz4, zstandard, python-snappy, brotli
# Extras:    blake3, xxhash

## 🏁 Quick Start
# Compress for max wall-clock speed (throughput plan) + BLAKE3 footer
warp-compress compress input.bin out.warp --level throughput --checksum blake3 --verbose

# Decompress (parallel scatter-gather for v2; streamed for v1)
warp-compress decompress out.warp restored.bin --verbose

## 🧪 Benchmarks

Average of 3 runs per size (from tests/benchmark_vs_zlib.py):

| Size (MB) | zlib compress | zlib decompress | warpcompress compress | warpcompress decompress |
| --------: | ------------: | --------------: | --------------------: | ----------------------: |
|        10 |      0.2353 s |        0.0070 s |          **0.0158 s** |                0.0187 s |
|        50 |      1.5433 s |        0.0492 s |          **0.0853 s** |                0.1027 s |
|       100 |      2.4197 s |        0.1284 s |          **0.1872 s** |                0.2025 s |
|       200 |      6.2520 s |        0.2508 s |          **0.6333 s** |                0.7307 s |

Notes

WarpCompress outpaces zlib on compression across sizes.

zlib can decode small inputs faster; WarpCompress narrows the gap as size grows.

For decode-heavy workloads, try compressing with LZ4 or Zstd-1..3 for even faster reads.

## 🧠 How it works (visuals)

Parallel Compression (high level)

flowchart LR
  A[Input file (mmap)] --> B[Chunk views]
  B -->|Thread pool| C1[Codec compress]
  B -->|Thread pool| C2[Codec compress]
  B -->|Thread pool| C3[Codec compress]
  C1 --> D[Collect compressed chunks]
  C2 --> D
  C3 --> D
  D --> E[Write v2 header (sizes + orig chunk sizes)]
  E --> F[Write chunks + optional footer]

Parallel Scatter–Gather Decompression (v2)
sequenceDiagram
  participant IN as .warp (mmap)
  participant POOL as Thread Pool
  participant OUT as Output mmap

  IN->>POOL: Read per-chunk compressed sizes
  POOL->>POOL: Compute output offsets (prefix sums of decomp sizes)
  loop chunks
    POOL->>IN: Slice compressed chunk view
    alt Zstd (zero-copy)
      POOL->>OUT: decompress_into( OUT[start:end], IN[chunk] )
    else Others
      POOL->>POOL: out = decompress(IN[chunk])
      POOL->>OUT: OUT[start:end] = out
    end
  end

🧰 CLI Reference
warp-compress compress [-h] [--threads N] [--chunk-size BYTES]
                      [--zstd-level N] [--zstd-threads N]
                      [--brotli-quality N] [--verbose]
                      [--level {auto,fastest,max,throughput}]
                      [--checksum {none,blake3,xxh64,blake2b}]
                      input_file output_file

warp-compress decompress [-h] [--threads N] [--chunk-size BYTES]
                        [--zstd-level N] [--zstd-threads N]
                        [--brotli-quality N] [--verbose]
                        input_file output_file
🧩 File Format (v2)

[MAGIC u32='WARP'] [VER u8=2] [ALGO u8] [ORIG_SIZE u64] [NUM_CHUNKS u32]
[COMP_SIZE_0 u64] ... [COMP_SIZE_N-1 u64]
[DECOMP_SIZE_0 u64] ... [DECOMP_SIZE_N-1 u64]
[CHUNK_0 bytes] ... [CHUNK_N-1 bytes]
# optional trailer:
[TRAILER_MAGIC u32='WFT1'] [HASH_ALGO u8] [SUM_LEN u16] [SUM bytes]

- v2 stores both compressed sizes and expected decompressed sizes  enables per-chunk offset precompute and zero-copy Zstd decompress_into().

🧑‍💻 Development

# Setup
python -m venv .venv && source .venv/bin/activate
pip install -e .[hashes]
pip install -U pytest

# Run tests
pytest -q

# Benchmark against zlib
PYTHONPATH=src python tests/benchmark_vs_zlib.py --sizes 10 50 100 200 --runs 3

Repo pointers

- Core engine: src/warpcompress/core.py

- CLI entrypoint: src/warpcompress/cli.py

- Tests & benchmark: tests/

🐛 Troubleshooting

ImportError: zstandard/lz4/snappy/brotli: run pip install -e .[hashes] again (base + extras)

Slow HDD or network FS? Use bigger chunks (e.g., --chunk-size 16_777_216) and --level throughput

Low-RAM machine? WarpCompress uses constant RAM; if paging occurs, try fewer threads (--threads 4)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

warpcompress-0.7.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

warpcompress-0.7.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file warpcompress-0.7.0.tar.gz.

File metadata

  • Download URL: warpcompress-0.7.0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for warpcompress-0.7.0.tar.gz
Algorithm Hash digest
SHA256 e60c016d5a80ecf00c9b70ab58a793b68b28656acca589f8fe2ef18a88b76742
MD5 337f89e5dbc93dec053a8a8b28b9649c
BLAKE2b-256 11d096b01b88e0e3f1c31aab9e50943efff244bd2ac5f2186c3b534f14d04e02

See more details on using hashes here.

Provenance

The following attestation bundles were made for warpcompress-0.7.0.tar.gz:

Publisher: publish-pypi.yml on shakeeb1532/warpcompress

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file warpcompress-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: warpcompress-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for warpcompress-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 087944f9127e14dcdaa8334e4aa2b197f59a43d49c290573ebdadfe1c64c1b36
MD5 4af1ef0c166cce359c4d385bac057778
BLAKE2b-256 58665f56804ca019405f817f69968ae20376d88fba3c1cf1fa532cb365a3c023

See more details on using hashes here.

Provenance

The following attestation bundles were made for warpcompress-0.7.0-py3-none-any.whl:

Publisher: publish-pypi.yml on shakeeb1532/warpcompress

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page