Skip to content

Log2n-io/Typhon

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

188 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Typhon

.NET

⚠️ The engine is in active development and not usable as a library or product. ⚠️

There is no reference documentation, no stable API, no NuGet package, and no support.

A microsecond-latency ACID data engine combining ECS archetype storage with tick-based parallel execution.

Typhon is an embedded data engine for real-time workloads like game servers, simulations, and stateful dataflow.
It pairs a microsecond-latency ACID store β€” MVCC snapshot isolation, configurable durability, source-generated ECS archetype accessors β€” with a tick-based parallel runtime that dispatches fine-grained system chunks across worker threads, each operating directly on the store.
The runtime doesn't sit on top of the database β€” it runs inside it.

πŸ“– Start here:


Key Features

  • Microsecond Operations β€” Optimized for Β΅s-level latency with pinned memory, SIMD, and lock-free reads
  • ACID Transactions β€” Full transactional semantics with optimistic concurrency control
  • MVCC Snapshot Isolation β€” Readers never block writers; each transaction sees a consistent snapshot
  • ECS Archetype System β€” Entities are typed by archetype; components are blittable structs with source-generated accessors and archetype inheritance
  • Larger-Than-RAM Storage β€” The database is a memory-mapped, paged file on disk, virtualized through a page cache that holds only the hot working set β€” so resident memory is bounded by the cache, not the database. Manipulate a 100 GiB store on a machine with a fraction of that RAM; component data, indexes, and the entity map all page to/from disk on demand (in-memory ECS frameworks, by contrast, must fit the entire world in RAM)
  • Workbench Dev UI β€” A local, browser-based companion (ASP.NET Core + React/Vite) β€” DataGrip for Typhon, not just a profiler. Open a recorded .typhon-trace, attach to a live engine over TCP, or open a .typhon database file directly. Performance: per-tick profiler timeline with CPU-sample + off-CPU overlays, Top Spans, Call Tree, Critical Path, System DAG. Data & schema: component/archetype browsers, Schema Inspector, a zoomable Hilbert-curve Database File Map, live Resource Tree. Queries: catalog, plan tree, per-execution inspector β€” all in a dockable, persisted workspace
  • Entity Clusters β€” SoA batched storage co-locating up to 64 entities per cluster, with cluster-native SIMD predicate evaluation (AVX-512 / AVX2 / scalar dispatch), zone-map pruning, and k-way sorted merge
  • Query Engine β€” Typed queries with Where, With/Without filters, polymorphic iteration, OR logic, navigation joins, and a cluster execution path that routes filtered scans through SIMD gather-compare on cluster SoA columns
  • Views & Change Tracking β€” Incremental entity-set monitoring across transactions (added/removed/modified detection) with ring-buffer delta streaming
  • B+Tree Indexes β€” Cache-aligned 128-byte nodes with optimistic lock coupling and specialized key-size variants
  • Spatial Indexing β€” Page-backed wide R-Tree for AABB / Radius / Ray / Frustum / kNN queries, plus a per-cell cluster broadphase (SpatialGrid) with BMI2 Morton-encoded cell keys and multi-resolution SimTier dispatch for near/far/coarse simulation budgets
  • Write-Ahead Logging β€” WAL (v2, always on) with configurable durability modes (Deferred, GroupCommit, Immediate) and coalesced tick-boundary snapshots via TickFence / ClusterTickFence chunks for the runtime tick loop
  • Page Integrity β€” CRC32C checksums, suspect-page detection, and crash-recovery rebuild (index + EntityMap); full-page images were retired in favor of a rebuild-based torn-page net
  • Schema Versioning β€” Component revisions with field-level migration support
  • Three Storage Modes β€” Versioned (full MVCC + WAL), SingleVersion (last-writer-wins; per-tx TickFence or Committed durability discipline β€” atomic, zero-loss, no revision chain), Transient (heap-only, no persistence)
  • Configurable Durability β€” Choose per-UnitOfWork whether data is deferred, group-committed, or immediately fsynced
  • Game Server Runtime β€” Tick-based micro-task DagScheduler with any-worker parallel dispatch, per-system change filters, typed MPSC event queues, side-transactions, cluster dormancy with staggered heartbeat wake, checkerboard Red/Black dispatch, and a 4-level overload response hierarchy (tick-rate modulation, player shedding)
  • Subscription Server + Client SDK β€” TCP delta streaming of published views with MemoryPack serialization, per-client incremental sync, backpressure-driven resync, and a zero-engine-dependency Typhon.Client assembly for game clients
  • Observability β€” Runtime telemetry, metrics, and diagnostics with zero-cost JIT-eliminated toggles
  • Deep-Trace Profiler β€” Per-tick Gantt and flame-graph visualization via a .typhon-trace binary format, live TCP streaming to a React/Vite viewer, and optional dotnet-trace CPU sampling correlation for full managed-stack profiles
  • Interactive Shell (tsh) β€” Database REPL for inspection and debugging
  • Public/Internal API split β€” Two namespaces per assembly (Typhon.Engine / Typhon.Engine.Internals), each subsystem folder split into public/ + internals/, enforced at compile time by the TYPHON008 Roslyn analyzer
  • Roslyn Analyzers β€” Custom analyzers detecting undisposed engine resources at compile time + the TYPHON008 internal-API leak detector

Quick Start

A taste β€” declare a component and an archetype, spawn an entity, read it back:

// A component is a plain struct; an archetype is the fixed set of components an entity has.
[Component("Game.Health", 1, StorageMode = StorageMode.Versioned)]
public struct Health { public int Current, Max; }

[Archetype(1)]
public sealed partial class Unit : Archetype<Unit>
{
    public static readonly Comp<Health> Health = Register<Health>();
}

// ...build the engine + register the schema (see the Guide), then:
using var tx = dbe.CreateQuickTransaction();
var id = tx.Spawn<Unit>(Unit.Health.Set(new Health { Current = 100, Max = 100 }));
var hp = tx.Open(id).Read(Unit.Health);   // hp.Current == 100
tx.Commit();

Illustrative β€” engine build + schema registration are elided. The User Guide has the full, runnable version (doc/guide/example).

Architecture

Typhon Architecture Layers

Development Status

Typhon is in active development targeting an alpha release. Current state:

  • Core transaction engine with MVCC
  • B+Tree indexes with optimistic lock coupling
  • Component-level durability options
  • Write-Ahead Logging with configurable durability modes
  • Page integrity (CRC32C, suspect-mode rebuild, checkpoints)
  • Query engine with filtering, sorting, and navigation
  • Views and incremental change tracking
  • ECS archetype system with source-generated accessors
  • Entity cluster storage (SoA batched, SIMD predicate evaluation, zone-map pruning, k-way sorted merge)
  • Dual page store abstraction (PersistentStore + TransientStore)
  • Schema versioning and evolution
  • Spatial indexing (page-backed wide R-Tree: AABB / Radius / Ray / Frustum / kNN)
  • Spatial grid with per-cell cluster broadphase and BMI2 Morton encoding
  • Multi-resolution simulation (SimTier dispatch, cluster dormancy, checkerboard Red/Black)
  • Game server runtime (DagScheduler, parallel system dispatch, overload management, event queues)
  • Subscription server and Typhon.Client SDK (TCP delta streaming, MemoryPack wire protocol)
  • Deep-trace runtime profiler (.typhon-trace format, live TCP streaming, React viewer)
  • Interactive shell (tsh)
  • Observability and monitoring stack
  • HashMap collections with key-size specialization
  • Workbench dev UI (data browsing, profiler viewer, System DAG view, Data Flow timeline, Access Matrix, internal data API)
  • Public/Internal API namespace split + TYPHON008 analyzer
  • Crash recovery (WAL v2 replay, scrub + index/EntityMap rebuild, suspect-mode)
  • Backup and restore

Project Structure

Each engine subsystem folder splits into public/ (consumer surface, namespace Typhon.Engine) and internals/ (implementation, namespace Typhon.Engine.Internals).

Typhon/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ Typhon.Engine/              # Main database engine β€” 17-feature tree
β”‚   β”‚   β”œβ”€β”€ Foundation/             # Cross-cutting primitives
β”‚   β”‚   β”‚   β”œβ”€β”€ Collections/        # HashMaps, bitmaps, lock-free arrays
β”‚   β”‚   β”‚   β”œβ”€β”€ Concurrency/        # Latches, AccessControl, epoch system, deadlines, timer service
β”‚   β”‚   β”‚   └── Memory/             # Memory allocator + block primitives
β”‚   β”‚   β”œβ”€β”€ Ecs/                    # ECS engine, archetypes, entity clusters, accessors
β”‚   β”‚   β”œβ”€β”€ Indexing/               # B+Tree variants (key-size specialized, OLC)
β”‚   β”‚   β”œβ”€β”€ Querying/               # Query engine, views, navigation joins, predicates
β”‚   β”‚   β”œβ”€β”€ Schema/                 # Component & archetype schema, validation, evolution
β”‚   β”‚   β”œβ”€β”€ Spatial/                # R-Tree, spatial grid, tier dispatch, trigger zones
β”‚   β”‚   β”œβ”€β”€ Storage/                # Pages, cache, segments, PagedMMF / IPageStore / PersistentStore / TransientStore
β”‚   β”‚   β”œβ”€β”€ Transactions/           # MVCC transactions, UnitOfWork, change capture
β”‚   β”‚   β”œβ”€β”€ Revision/               # Revision chains, deferred cleanup
β”‚   β”‚   β”œβ”€β”€ Durability/             # WAL, checkpointing, recovery, FPI capture
β”‚   β”‚   β”œβ”€β”€ Runtime/                # DagScheduler, tick loop, systems, overload management, queues
β”‚   β”‚   β”œβ”€β”€ Subscriptions/          # TCP delta streaming server, published views
β”‚   β”‚   β”œβ”€β”€ Profiler/               # In-engine typed-event profiler (codecs in Typhon.Profiler/)
β”‚   β”‚   β”œβ”€β”€ Observability/          # Telemetry config, metrics, diagnostics
β”‚   β”‚   β”œβ”€β”€ Resources/              # Resource graph, lifecycle, options
β”‚   β”‚   β”œβ”€β”€ Errors/                 # Exception hierarchy, deadline propagation
β”‚   β”‚   └── Hosting/                # DI extensions, service collection helpers
β”‚   β”œβ”€β”€ Typhon.Analyzers/           # Roslyn analyzers (dispose detection + TYPHON008 internal-API leak)
β”‚   β”œβ”€β”€ Typhon.Client/              # External client SDK (TCP subscriptions, zero engine deps)
β”‚   β”œβ”€β”€ Typhon.Generators/          # Source generators (archetype accessors, traced-event encoders, source location)
β”‚   β”œβ”€β”€ Typhon.Profiler/            # Trace file format, readers/writers, sidecar cache, Chrome Trace exporter
β”‚   β”œβ”€β”€ Typhon.Protocol/            # MemoryPack wire-format types (TickDeltaMessage, etc.)
β”‚   β”œβ”€β”€ Typhon.Schema.Definition/   # Component & archetype attributes
β”‚   β”œβ”€β”€ Typhon.Shell/               # Interactive database shell (tsh)
β”‚   └── Typhon.Shell.Extensibility/ # Shell extension points
β”œβ”€β”€ test/
β”‚   β”œβ”€β”€ Typhon.Engine.Tests/        # NUnit test suite (3500+ tests)
β”‚   β”œβ”€β”€ Typhon.Client.Tests/        # Client SDK tests
β”‚   β”œβ”€β”€ Typhon.Workbench.Tests/     # Workbench server-side tests
β”‚   β”œβ”€β”€ Typhon.Benchmark/           # BenchmarkDotNet performance tests
β”‚   β”œβ”€β”€ Typhon.ARPG.Schema/         # Example ARPG game schema
β”‚   β”œβ”€β”€ Typhon.ARPG.Shell/          # Shell demo with ARPG data
β”‚   β”œβ”€β”€ Typhon.MonitoringDemo/      # Observability demo
β”‚   β”œβ”€β”€ Typhon.IOProfileRunner/     # Storage I/O profiling sandbox
β”‚   β”œβ”€β”€ Typhon.Scheduler.POC/       # DagScheduler POC harness
β”‚   β”œβ”€β”€ Typhon.SqliteBenchmark/     # Comparative SQLite benchmark
β”‚   └── AntHill/                    # Godot-based ant-colony demo (runtime + clusters + spatial tiers)
β”œβ”€β”€ tools/
β”‚   β”œβ”€β”€ Typhon.Workbench/           # Local dev UI (ASP.NET Core 10 + React 19/Vite) β€” data browsing, schema, profiler, System DAG, Data Flow timeline, Access Matrix
β”‚   β”œβ”€β”€ Typhon.Workbench.Fixtures/  # Dev-only test fixture generators consumed by the Workbench DEBUG tabs
β”‚   └── CheckDurations/             # Helper utility for tick-duration analysis
β”œβ”€β”€ claude/                         # Architecture docs, ADRs, design specs (separate nested git repo)
└── benchmark/                      # Benchmark results

History

This project has had quite a journey:

  • 2015 β€” Initial bootstrap with a different design, quickly shelved
  • 2020 β€” COVID resurrection as a POC: "Can we build a Β΅s-latency ACID database for persistent games?" Promising results, then shelved again
  • 2025 β€” Third resurrection with firm intention to reach alpha stage
  • 2025-2026 β€” Rapid progress: WAL & durability, query engine, ECS archetype system with source generators, schema evolution, observability stack, and interactive shell delivered
  • Q2 2026 alpha push β€” Game-server runtime (DagScheduler, parallel system dispatch, overload management), entity clusters with cluster-native SIMD query execution, dual page store abstraction (PersistentStore + TransientStore), spatial indexing (page-backed R-Tree + spatial grid cluster broadphase), multi-resolution SimTier dispatch with cluster dormancy and checkerboard, TCP subscription server with zero-engine-dependency client SDK, and a deep-trace runtime profiler with live-streaming viewer
  • Q2 2026 Workbench buildout β€” Internal Data API + System DAG view (#306, #314, #322), static schema export and Schema Inspector (#326), Data Flow Timeline + Access Matrix panels with cross-panel selection and hover linking (#327)
  • Q2 2026 API hardening β€” Public/Internal namespace migration, accessibility flips, friend-list audit, and leak-tightening pass: ~430 internal types now in Typhon.Engine.Internals enforced by the TYPHON008 analyzer (#329)
  • Q2 2026 durability redesign β€” Minimal WAL (WAL v2 format, RecoveryDriver, checkpoint v2 A/B slot-pairing), the Committed durability discipline (#392), cluster crash durability (#395), BulkLoad write path + storage hardening (#383), and retirement of full-page images in favor of a suspect-mode rebuild recovery net (#399, #401)
  • Q2 2026 Workbench redesign β€” shell rebuild (Stages 0–4), read-only Data Browser, zoomable Database File Map, off-CPU + integrated CPU-sample profiling, Trackβ†’DAG / Critical Path rework, the AntHill validation harness, and Query Console Phase 1 β€” write/execute/browse queries against a live store (#379, #390)

About

A microsecond-latency ACID database engine with a native Entity-Component-System data model, built for real-time systems.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors