Skip to content

Latest commit

 

History

25 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The Loom: High-Throughput AT Protocol Archiver

πŸ”¬ Project Status: Research Validation Complete

The Loom represents a completed research experiment into the theoretical performance limits of AT Protocol data ingestion on consumer hardware. This high-velocity experiment was conducted over 4 days to rapidly prototype and validate core hypotheses. The primary hypothesisβ€”that sustained real-time firehose consumption with 5.6:1 compression and zero data loss was achievable outside enterprise infrastructureβ€”has been scientifically validated.

Key Research Findings:

  • 5,000 events/sec sustained ingestion on single worker thread
  • Infrastructure-grade performance on consumer hardware
  • Zero-drop reliability during multi-hour continuous operation
  • Complete data fidelity with cryptographic verification

The project is now in "Stable Archive" state. The codebase serves as a reference implementation and proof-of-concept for high-performance AT Protocol tooling. No further active development is planned unless specifically invited by core protocol stakeholders or the broader AT Protocol research community.


The Loom is a specialized, high-performance archiving system designed to ingest, compress, and index the entire Bluesky/AT Protocol Firehose(Jetstream) in real-time.

It prioritizes storage efficiency and write throughput, using a custom binary format (LBF) and pre-trained Zstd dictionaries to achieve compression ratios significantly higher than standard JSON storage.


πŸš€ Performance at a Glance

Metric Value
Compression Ratio 5.6-5.8:1 (JSON β†’ LBF+Zstd)
Rehydration Speed 1.7 GB/s @ 293k events/sec
Search Throughput 294 MB/s with collection filtering
CSV Export 3,809 posts/sec with full parsing
Backfill Rate 5,000 events/sec sustained (single worker)
Archive Integrity <50ms validation for 300MB archives
Hash Generation 838 MB/s SHA256 manifest creation
Schema Verification 100% field-level match (10k events tested)
Latency Zero-lag real-time consumption

Key Features

  • Zero-Copy Ingestion: Built on tokio-tungstenite and standard Rust async primitives for maximum socket throughput.
  • Loom Binary Format (LBF v5): A bespoke, schema-aware serialization format that is 20-30% smaller than MsgPack and 60-80% smaller than raw JSON. Supports 15 record types.
  • Identity Resolution: Maps string DIDs (e.g., did:plc:123...) to 32-bit integers (u32), reducing redundancy in the graph structure.
  • Full Rehydration: Archives can be fully reconstructed back to Jetstream-compatible JSONL format with zero data loss.
  • Cryptographic Integrity: SHA256 manifests for archive verification and provenance.
  • Persistent Indexing: Searchable indices (tags, languages) with sled-backed persistence.
  • Distributed Network Ready: loom-fiber witness nodes + loom-index discovery service.

Architectural Philosophy: Mechanical Sympathy

The Loom is built on the principle of Mechanical Sympathyβ€”designing software that works with hardware characteristics rather than against them. This architectural approach directly enables the infrastructure-grade performance achieved on consumer hardware.

Hardware-Aware Design Decisions:

  • Memory Layout Optimization: Custom binary format (LBF) designed for CPU cache efficiency and minimal memory fragmentation
  • Zero-Copy Streaming: Data flows through the pipeline without unnecessary copying, respecting memory bandwidth constraints
  • Compression-First Architecture: Zstd integration reduces both storage and memory pressure, allowing larger working sets to remain cache-resident
  • Async I/O Alignment: Tokio's async primitives match the underlying OS kernel's event-driven I/O model for minimal context switching overhead
  • NUMA Awareness: Single-worker design avoids cross-socket memory access penalties on multi-socket systems

This mechanical sympathy approach transforms what appears to be a "software optimization" problem into a "hardware cooperation" solution, explaining how consumer-grade equipment achieves enterprise-grade throughput.

Quick Start

1. Build

cargo build --release

2. Run the Archiver

cargo run --release --bin loom-weaver
  • Config: By default, it saves to archives/loom_{timestamp}.loom.
  • Rotation: Files rotate every 15 minutes or 2 GB, whichever comes first.

3. Verify Integrity

Map the live firehose against the internal schema to prove no fields are dropped:

cargo run --release --bin verify_live

4. Rehydrate an Archive

Convert a .loom archive back to JSONL (Jetstream-compatible format):

cargo run --release --bin rehydrate -- --file archives/loom_123.loom --output restored.jsonl

5. Generate Integrity Manifest

Create SHA256 hashes for archive verification:

./target/release/loom-hashify --file archives/loom_123.loom
./target/release/loom-hashify --verify archives/loom_123.manifest.json

CLI Tools

Tool Purpose
loom-weaver Main archiver daemon
loom-grep High-speed parallel search
loom-player Time-range playback with --since/--until
loom-export Export to CSV for data science
loom-merge Combine multiple archives into one
rehydrate Convert .loom β†’ JSONL
loom-hashify Generate/verify SHA256 manifests
verify_live Live firehose integrity testing
audit Validate archive block structure
loom-index Search index server (HTTP API)
loom-fiber Distributed witness node

Documentation

Full architectural and operational documentation is available in the docs/ directory:


Project Structure

The_Loom/
β”œβ”€β”€ crates/
β”‚   β”œβ”€β”€ loom-core/       # Shared types, LBF pack/unpack, compression
β”‚   β”œβ”€β”€ loom-weaver/     # Main archiver + CLI tools
β”‚   β”œβ”€β”€ loom-index/      # Search index HTTP service
β”‚   β”œβ”€β”€ loom-fiber/      # Distributed witness node
β”‚   └── loom-ingest/     # Ingestion utilities
β”œβ”€β”€ archives/            # .loom archive files
β”œβ”€β”€ dictionaries/        # Zstd compression dictionaries
β”œβ”€β”€ docs/                # Documentation
└── identity.fst         # DID β†’ u32 mapping

Compression Stats

Typical compression ratios observed:

  • Raw JSON β†’ LBF+Zstd: ~5.6:1 compression
  • Example: 729 MB JSONL β†’ 129 MB .loom archive

Performance Benchmarks

  • Rehydration: ~4.4 million events in ~15 seconds (~1.7 GB/s decompressed output)
  • Throughput: Processes AT Protocol firehose in real-time with minimal latency
  • Storage: Achieves consistent 5.6:1 compression on typical AT Protocol events

Testing

Run the full test suite:

cargo test --release

Getting Help


Dedication

This project is dedicated to my father.

If my parents had given up on me through the years of hardship, addiction, and the mistakes of my past, I would not be here today to write this code. I built The Loom to prove to himβ€”and to myselfβ€”that the "fuckup" he stood by is gone, and that I'm going to be okay.

Every bit of performance and every line of Rust in this repo is a thank you for not letting go.

About

A high-throughput, database-free ingestion engine for the AT Protocol (Bluesky) Firehose, engineered for consumer hardware constraints.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages