Skip to main content

Fast, parallel, lossless compression with mmap scatter–gather 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.1.5.tar.gz (15.2 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.1.5-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for warpcompress-0.1.5.tar.gz
Algorithm Hash digest
SHA256 9f53b9f81bff9981f9c38da55764c138a37aa3fbc55d781ac31d590f9dd55899
MD5 227ccb388fc03767a991cec871dbf7b4
BLAKE2b-256 5500e113f51347d65ec946d6d551e7a965da888f0bbf186e8f35f9e063261f21

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: warpcompress-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 13.4 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.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9242e45066f2bf3fde4e3213d166f2f7b1de8ece286f3e68bb5c4cca9ed604d2
MD5 165023ecd15939406a4308fe85dc33b6
BLAKE2b-256 4f9c01f909f06f216b4e3f2e6ab630aa2af9f2aa5e771bb9dcf5199f2b680f4e

See more details on using hashes here.

Provenance

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