ZeroStorage is an embedded, high-throughput time-series database (TSDB) and write-ahead log (WAL) storage engine for .NET with zero external dependencies. Implemented from scratch in pure C#, it features Facebook Gorilla lossy/lossless Delta-of-Delta timestamp compression, XOR float mantissa encoding, wide-row MultiMetricBlock columnar persistence, memory-mapped files (MMF), CRC32 integrity verification, and background tiered compaction.
-
Wide-Row Time-Series Compression (
MultiMetricBlock): Simultaneously encodes multiple metrics sharing timestamp vectors with Gorilla compression. -
Facebook Gorilla Time-Series Compression:
- Timestamp Compression: Variable-length Delta-of-Delta encoding (down to 1 bit per sample for regular time intervals).
-
Value Compression: XOR floating-point mantissa encoding with leading/trailing zero tracking (reducing typical float metrics to
$< 1.5$ bytes/sample).
-
Memory-Mapped Persistence (
MemoryMappedTimeSeriesLog): Direct kernel-level zero-copy disk mapping viaMemoryMappedFile, bypassing user-space buffering for sub-millisecond writes. - Write-Ahead Log (WAL): Append-only durability log with IEEE 802.3 CRC32 integrity checksums per record and automatic crash recovery.
- Tiered Compaction: Background compactor merging fragmented uncompressed or hot blocks into consolidated, dense cold storage blocks.
- Zero External Dependencies: Pure C# standard runtime library.
Install via the .NET CLI:
dotnet add package ZeroStorage.Coreusing ZeroStorage.Core.BitIO;
using ZeroStorage.Core.Gorilla;
using var stream = new MemoryStream();
var writer = new BitWriter(stream);
var encoder = new GorillaEncoder(writer);
long baseTimestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
// Encode stream of 1000 points
for (int i = 0; i < 1000; i++)
{
long ts = baseTimestamp + (i * 10); // 10ms intervals
double val = 25.0 + Math.Sin(i * 0.1) * 0.5;
encoder.Encode(ts, val);
}
encoder.Finish();
Console.WriteLine($"Compressed 1,000 points into: {stream.Length} bytes ({stream.Length / 1000.0:F2} bytes/point)!");using ZeroStorage.Core.Persistence;
using var tsdb = new MemoryMappedTimeSeriesLog("telemetry.tsdb", maxSizeBytes: 64 * 1024 * 1024);
// Append metric point
tsdb.Append(metricId: 42, timestamp: DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), value: 98.6);Tested on Intel Core i7-13700K with NVMe SSD (Release x64):
| Metric | Uncompressed Raw | Gorilla Compressed (ZeroStorage) | Compression Ratio |
|---|---|---|---|
| Storage per Metric Point |
|
||
| Write Throughput | In-memory bit packing | ||
| Query Decompress Speed | Direct bit-stream decode |
| Version | Release Date | Key Milestones & Highlights |
|---|---|---|
v1.1.0 |
2026-09-16 | Wide-Row Metric Compression: • Introduced MultiMetricBlock simultaneous encoding of multi-variate telemetry streams.• Zero-copy memory mapped files with CRC32 block checksums. • 18 unit tests passing (100% success rate). |
v1.0.0 |
2026-09-09 | Initial Sovereign Release: • Pure C# Facebook Gorilla Delta-of-Delta timestamp & XOR float compression. • Memory-mapped write-ahead logging (WAL) & tiered compaction. |
MIT License © 2026 Phong Võ. Part of the ZeroPlatform project.