Glacier.Chrono 1.0.0

dotnet add package Glacier.Chrono --version 1.0.0
                    
NuGet\Install-Package Glacier.Chrono -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Glacier.Chrono" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Glacier.Chrono" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Glacier.Chrono" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Glacier.Chrono --version 1.0.0
                    
#r "nuget: Glacier.Chrono, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Glacier.Chrono@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Glacier.Chrono&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Glacier.Chrono&version=1.0.0
                    
Install as a Cake Tool

Glacier.Chrono: Zero-Allocation Time-Series Compression Engine

Build Status Target Framework License Zero-Allocation

Glacier.Chrono is an embedded, in-process time-series database engine designed for extreme write-throughput and zero-allocation query execution in .NET 10.

By bypassing heavy ORMs, database servers, and external system dependencies, Glacier.Chrono delivers timeseries compression ratios of 90%+ using standard time-series compression algorithms (inspired by Facebook Gorilla and TimescaleDB) running entirely in-process in C#.


๐Ÿš€ Key Features

  • Zero-Allocation Ingest & Compression: The hot paths for write ingestion, column transpositions, and bit-level compressions perform zero allocations on the managed heap.
  • CPU Register-Buffered Bit-Packing: Utilizes a highly-optimized 64-bit register accumulator for reading and writing bits, avoiding slow bit-by-bit looping and resulting in a 19x performance speedup.
  • Hybrid Row-to-Columnar Pivot: Collects telemetry row-wise in a lock-free ring buffer (AoS), then pivots the layout in memory to columnar (SoA) during background compaction to maximize compression density and SIMD cache locality.
  • Vectorized (SIMD) Queries: Leverages portable hardware intrinsics (Vector<T> and Vector256<T>) to query and aggregate millions of records per second directly on memory-mapped column files.
  • Virtual Memory File Projection: Maps cold storage chunk files to memory via MemoryMappedFile projection, allowing queries to scan datasets much larger than physical memory without triggering GC pressure.

๐Ÿ›๏ธ Architectural Layout

                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                  โ”‚          Concurrent Ingest Threads            โ”‚
                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                          โ”‚  1. Zero-Allocation Ingest (Write)
                                          โ–ผ
                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                  โ”‚    HotRingBuffer<TelemetryRow> (AoS Layout)   โ”‚
                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                          โ”‚  2. Background Pivot (AoS -> SoA)
                                          โ–ผ
                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                  โ”‚    Columnar Spans (Timestamps, CPUs, Mem...)  โ”‚
                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”˜
                            โ”‚                 โ”‚                 โ”‚
                            โ”‚ 3. DoD          โ”‚ 3. Gorilla XOR  โ”‚ 3. RLE
                            โ–ผ                 โ–ผ                 โ–ผ
                  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                  โ”‚ Timestamp Comp. โ”‚ โ”‚ Float Comp.   โ”‚ โ”‚ Integer Comp. โ”‚
                  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                            โ”‚                 โ”‚                 โ”‚
                            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                              โ”‚ 4. Single-pass Offset Write
                                              โ–ผ
                                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                 โ”‚  chunk_*.glacier file  โ”‚
                                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                              โ”‚
                                              โ”‚ 5. MemoryMappedFile Projection
                                              โ–ผ
                                 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                                 โ”‚ Vectorized QueryEngine โ”‚ (SIMD average, sums, filters)
                                 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

1. Ingestion Layer (HotRingBuffer<T>)

Telemetry writes are written into a pre-allocated circular ring buffer. A lock-free write cursor is advanced atomically using Interlocked.Increment, allowing multiple concurrent ingestion threads to record telemetry without lock contention or memory allocations.

2. The Compaction Pivot (Compactor)

When a batch size (e.g., 10,000 rows) is reached, a background thread transposes the Array of Structs (AoS) format into a Struct of Arrays (SoA) format. Pivoting elements into contiguous arrays by data type prepares columns for compression algorithms tailored to their data distribution.

3. Bit-Packing & Compression Engine

  • Timestamps (Delta-of-Delta): Computes the difference in intervals (DoD). If data arrives at perfectly regular intervals (DoD = 0), it is encoded as a single bit.
  • Floating-Point Metrics (Gorilla XOR): Computes the XOR between consecutive floats. Zero leading/trailing bits are stripped and only the meaningful bits are bit-packed, achieving high compression ratios for slowly changing metrics (e.g. CPU or temperature logs).
  • Integers/Enums (RLE): Identifies consecutive repeating values and packs them into [Value, Count] pairs.
  • The 64-bit Accumulator Trick: Instead of writing bits individually, the BitWriter and BitReader accumulate bits in a CPU register (ulong). Bytes are written to memory in bulk only when the accumulator reaches capacity, eliminating loop overhead.

4. Query Execution (QueryEngine)

Analytical queries project only the relevant columns into the virtual address space using memory-mapped views. The QueryEngine applies vectorized logic (Vector<T>) to decode and filter values directly in memory-mapped views, enabling sub-millisecond aggregates over millions of rows with negligible heap footprint.


โšก Performance Benchmarks

Below are the official benchmark results executed on Windows 11 using .NET SDK 10.0.301 on a machine supporting AVX-512 vector extensions.

BenchmarkDotNet v0.14.0, Windows 11 (10.0.26200.8655)
Unknown processor
.NET SDK 10.0.301
  [Host]     : .NET 10.0.9 (10.0.926.27113), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
  DefaultJob : .NET 10.0.9 (10.0.926.27113), X64 RyuJIT AVX-512F+CD+BW+DQ+VL+VBMI
Method N Mean Gen 0 Gen 1 Gen 2 Allocated Throughput (Values/sec)
HotIngestSingleThreaded 10000 138.83 ฮผs 142.8 142.8 142.8 458 KB * ~72.0M writes/sec
GorillaCompressFloats 10000 33.27 ฮผs - - - 0 B 300.5M values/sec
GorillaDecompressFloats 10000 37.46 ฮผs - - - 0 B 266.9M values/sec
TimestampCompressDoD 10000 4.95 ฮผs - - - 0 B 2.01B values/sec
TimestampDecompressDoD 10000 10.32 ฮผs - - - 0 B 969.4M values/sec
IntegerCompressRle 10000 19.81 ฮผs - - - 0 B 504.7M values/sec
IntegerDecompressRle 10000 34.39 ฮผs - - - 0 B 290.7M values/sec
QueryEngineSIMD 10000 325.96 ฮผs - - - 577 B ** 30.7M records/sec

* Allocations in HotIngestSingleThreaded reflect the setup instantiation of the new ring buffer array inside the benchmark loop.
** Allocations in QueryEngineSIMD are exclusively due to the .NET BCL MemoryMappedFile and MemoryMappedViewAccessor wrapper instances, which are garbage-collected outside of the hot path.


๐Ÿ“Š Comparison: Glacier.Chrono vs. TimescaleDB

Feature TimescaleDB Glacier.Chrono
Execution Model External Database Server (PostgreSQL Extension) Embedded, in-process C# Class Library
Ingestion Latency High (Network, IPC, Transaction Locks, SQL Parsing) Ultra-low (Lock-free Ring Buffer writes)
Compression Quality High (DoD, Gorilla, RLE, Dictionary) Identical (Custom C# implementations of DoD, Gorilla, RLE)
Memory Allocation Relies on PostgreSQL memory buffers Zero heap allocations during ingestion & compression
Scale Limits Scalable across disk storage clusters Scalable via Memory-Mapped files larger than RAM
Deployment Complexity High (Docker, PG configuration, backup tooling) Zero (Packaged as a lightweight NuGet library)

๐Ÿ› ๏ธ Quick Start

1. Ingest Data Concurrently

Define the schema using a layout-packed struct:

using System.Runtime.InteropServices;
using Glacier.Chrono.Storage;

[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct TelemetryRow
{
    public long Timestamp; // 8 bytes
    public float CpuUsage; // 4 bytes
    public float MemUsage; // 4 bytes
    public int EntityId;   // 4 bytes
}

// Instantiate a lock-free Ring Buffer
int bufferCapacity = 16384;
var ringBuffer = new HotRingBuffer<TelemetryRow>(bufferCapacity);

// Write concurrently
var record = new TelemetryRow 
{ 
    Timestamp = DateTime.UtcNow.Ticks, 
    CpuUsage = 45.2f, 
    MemUsage = 80.1f, 
    EntityId = 1 
};
ringBuffer.Write(in record);

2. Run Background Compaction

Periodically compact ingested rows to disk. Compaction converts rows to columns and flushes them to compressed binary format.

using Glacier.Chrono.Storage;

long nextSequence = 0;
int batchSize = 10000;
string outputDirectory = "./glacier_data";

// Pre-allocate compaction buffer arrays once to ensure zero allocations on the hot path
var compBuffers = new CompactorBuffers(batchSize);

bool success = Compactor.CompactBatch(
    ringBuffer, 
    ref nextSequence, 
    batchSize, 
    outputDirectory, 
    compBuffers
);

3. Query Column Aggregates with SIMD

Execute vector-scan average queries over memory-mapped files without loading unneeded columns:

using Glacier.Chrono.Query;

string chunkFilePath = "./glacier_data/chunk_0.glacier";
int targetEntityId = 1;
int batchSize = 10000;

// Pre-allocate query buffers to avoid heap allocations
var queryBuffers = new QueryBuffers(batchSize);

// Scans only the mapped EntityId and CpuUsage columns
double avgCpu = QueryEngine.GetAverageCpuUsageForEntity(
    chunkFilePath, 
    targetEntityId, 
    queryBuffers
);

Console.WriteLine($"SIMD Average CPU Usage: {avgCpu}%");

๐Ÿ“‚ Repository Layout

Glacier.Chrono/
โ”œโ”€โ”€ Glacier.Chrono.slnx       # Solution configuration file
โ”œโ”€โ”€ spec.md                   # Core architectural specification
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ Glacier.Chrono/       # Library project
โ”‚       โ”œโ”€โ”€ Compression/      # Compressors (DoD, Gorilla, RLE, BitReaderWriter)
โ”‚       โ”œโ”€โ”€ Storage/          # HotRingBuffer, TelemetryRow, Compactor
โ”‚       โ”œโ”€โ”€ Query/            # SIMD QueryEngine
โ”‚       โ””โ”€โ”€ Glacier.Chrono.csproj
โ””โ”€โ”€ samples/
    โ”œโ”€โ”€ Glacier.Chrono.Demo/        # Correctness and zero-allocation verification app
    โ””โ”€โ”€ Glacier.Chrono.Benchmarks/  # BenchmarkDotNet performance evaluation suite

๐Ÿงช Building and Testing

  1. Build the solution:
    dotnet build
    
  2. Execute correct-by-construction demo:
    dotnet run --project samples/Glacier.Chrono.Demo/Glacier.Chrono.Demo.csproj -c Release
    
  3. Execute BenchmarkDotNet:
    dotnet run --project samples/Glacier.Chrono.Benchmarks/Glacier.Chrono.Benchmarks.csproj -c Release
    

๐Ÿ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 1,978 6/16/2026