Skip to main content

HTML-aware compression for document corpora — solid-archive ratios with random access

Project description

Storetle

HTML-aware compression for document corpora — solid-archive ratios with random access.

Storetle stores large collections of HTML (web crawls, academic corpora, training datasets) in a format that is ~46% smaller than the per-record gzip WARC files the web-archiving world ships today, while still letting you pull any single document out of a multi-gigabyte archive without decompressing the rest — locally, or straight off object storage.

pip: storetle (Python, read/write)  ·  rust/: storetle-rs (Rust, read)  ·  web/: read .storetle in the browser

The honest benchmark

Two different questions, two tables. Corpus: 10 real pages (Wikipedia, arXiv abstracts, PLOS articles), 1.75 MB raw HTML, measured June 2026. Reproduce with storetle bench <folder>.

1. Among formats with random access (you can extract one doc without decompressing everything before it — this is how WARC is actually deployed):

method bytes vs deployed standard
per-record gzip -9 (standard WARC) 373,626
per-record zstd -19 325,807 −12.8%
per-record zstd -19 + trained dict 274,226 −26.6%
storetle 200,598 −46.3%

2. Against solid archives (maximum compression, no random access):

method bytes
tar + gzip -9 370,307
tar + zstd -19 220,512
tar + zstd -22 --long 220,422
tar + zstd -22 + trained dict 204,386
storetle (keeps random access) 200,598

Storetle matches solid zstd-22 while remaining randomly accessible. The margin comes from three things: HTML-aware encoding (tags/attributes become 1-byte IDs from a shared vocabulary, structure and text compressed as separate streams), a 1 MB dictionary trained on the binary encoding, and 256-document chunks that capture cross-page template redundancy.

On larger corpora measured against gzip WARC: 28.4% smaller on 3,000 live Common Crawl docs (348.6 MB), 27–82% on same-domain collections (191 pages, 20 domains) where template sharing is strongest. Round-trip verified on all of the above. Stream it yourself: python3 bench_cc.py --docs 3000.

Install

brew install zstd        # macOS   (Ubuntu: apt install libzstd-dev)
pip install storetle

No Python dependencies — stdlib plus system libzstd via ctypes (brotli fallback if zstd is missing). lxml is optional but strongly recommended for encoding speed.

CLI

storetle pack      my_crawl/ archive.storetle     # folder of .html → archive
storetle unpack    archive.storetle out/          # archive → .html files
storetle info      archive.storetle               # stats
storetle get       archive.storetle 42            # one doc to stdout, O(1)
storetle bench     my_crawl/                      # benchmark on YOUR data
storetle from-warc CC-MAIN.warc.gz archive.storetle
storetle to-warc   archive.storetle out.warc.gz
storetle train     my_corpus/ --output my.bin     # domain-specific dictionary

Python API

import storetle

with storetle.StreamWriter('archive.storetle', workers=8) as w:
    for html in crawl:
        w.append(html)

with storetle.StreamReader('archive.storetle') as r:
    print(r.doc_count)
    doc   = r[42]          # random access: decompresses one ~2MB chunk
    batch = r[100:200]
    for doc in r:          # sequential
        ...

Rust reader

A read-only Rust implementation lives in rust/ — library plus a storetle-rs CLI (ls / get / unpack), differentially tested byte-for-byte against the Python decoder.

In the browser

web/ has a zero-dependency demo page: the Rust reader compiled to WebAssembly. Drop a .storetle file onto the page and browse its documents.

How it works

  1. Parse — HTML is tokenized to a node stream (lxml fast path, pure-Python fallback).
  2. Encode — tags and attribute names become 1-byte IDs from a fixed vocabulary (130 tags, 163 attributes, 1,394 shared strings). class="flex items-center gap-4" is split into per-token vocabulary lookups. Structure and text go to separate streams.
  3. Chunk — up to 256 docs / 2 MiB are concatenated, preserving cross-document redundancy.
  4. Compress — zstd-22 with a 1 MB dictionary trained on the binary encoding (ships with the codec).
  5. Index — a footer index maps documents to chunks, so readers seek instead of scanning. Works over HTTP range requests against plain object storage.

Full byte-level spec: FORMAT.md.

Limitations — read these

  • Structural, not byte-exact. Reconstructed HTML preserves every tag, attribute, text node, comment, and script/style body, but is re-serialized (indentation and inter-tag whitespace differ). Fine for corpora and ML pipelines; wrong for byte-exact archival — if you need forensic fidelity, use WARC.
  • HTML only. from-warc keeps HTML response records and skips everything else. A raw passthrough mode for JSON/text is on the roadmap.
  • Encoding speed ~3.5 MB/s per core (Python). Parallel via workers=N. Decoding is zstd-bound and fast. A native encoder is on the roadmap.
  • Alpha. Format version 2. Validated on 150k+ Common Crawl documents, but expect rough edges.

License

MIT © 2026 Davis Brief

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

storetle-0.2.0.tar.gz (439.0 kB view details)

Uploaded Source

Built Distribution

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

storetle-0.2.0-py3-none-any.whl (441.0 kB view details)

Uploaded Python 3

File details

Details for the file storetle-0.2.0.tar.gz.

File metadata

  • Download URL: storetle-0.2.0.tar.gz
  • Upload date:
  • Size: 439.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for storetle-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e6157f932d098588b669ada610e7169278d6bb9181b9216aba81f924f127ae19
MD5 5af50949eca1a92c84144080bca29e89
BLAKE2b-256 2fff8e10d13bbbcb425b6a14fdb759a8562eac66e03f1bafc9892815e6391184

See more details on using hashes here.

Provenance

The following attestation bundles were made for storetle-0.2.0.tar.gz:

Publisher: publish.yml on adventurelands/storetle

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

File details

Details for the file storetle-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: storetle-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 441.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for storetle-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 12de1b7f4cc3649b069627306b8c29a10b6e9763623ec0b9fb19e795cd4c30b9
MD5 996cfcfd4c69460b6d266b8cc0c654c8
BLAKE2b-256 50eb4d84b0ce170c89ccf9eba0b84f80aa74ca16350d009a91c84cbb022b21b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for storetle-0.2.0-py3-none-any.whl:

Publisher: publish.yml on adventurelands/storetle

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