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.5.tar.gz (16.1 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.5-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: warpcompress-0.7.5.tar.gz
  • Upload date:
  • Size: 16.1 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.5.tar.gz
Algorithm Hash digest
SHA256 dde4bf11a2c2025faeb1fb3692038800ebf69d9828fdb11fd2134fa71579b90c
MD5 4eb15aac05fd7529993b8053bcd4bce1
BLAKE2b-256 3cdecfcd83af07b694725db2cb017b9e9e0fb3ed13852c8d02b8f08b3390de5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for warpcompress-0.7.5.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.5-py3-none-any.whl.

File metadata

  • Download URL: warpcompress-0.7.5-py3-none-any.whl
  • Upload date:
  • Size: 14.5 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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 522656326d7b015103ed17a399383d7d03c8f45ab54bea900888cd8a1093269d
MD5 a060b1e60facae0fcf6ed5772cdfb373
BLAKE2b-256 25d4241d8009edc251c818f304f61f04041246f4544b1a17d60d37f45781f83f

See more details on using hashes here.

Provenance

The following attestation bundles were made for warpcompress-0.7.5-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