completengine

Concurrent Event Simulation Engine

Orchestrating thousands of simultaneous processes into coherent outcomes. Built for precision. Engineered for scale.

Version 3.2.1
License Apache 2.0
Status Active

Architecture

CompletEngine uses a lock-free event loop with work-stealing schedulers to achieve near-linear scalability across cores. The architecture separates event sourcing from process execution, enabling deterministic replay of concurrent simulations.

Event Loop

Lock-free ring buffer processes events in arrival order. Each event is tagged with a logical timestamp for causal ordering across distributed nodes.

engine.loop(events, scheduler: .workStealing)

Synchronization

Barrier-based synchronization ensures all threads reach consistent state before advancing. Configurable sync granularity from per-tick to per-epoch.

barrier.sync(threads, granularity: .tick)

Deadlock Detection

Real-time cycle detection in the resource dependency graph identifies deadlocks within one tick. Automatic resolution via priority-based preemption.

detector.watch(graph, resolve: .preempt)

Benchmarks

Performance measured on AMD EPYC 9654 (96 cores), 384GB DDR5. All benchmarks run with deterministic seeding for reproducibility.

Throughput (events/sec) 2.4M
P99 Latency 0.8ms
Linear Scaling (96 cores) 94.2%
Memory Efficiency 12KB/thread
Sync Overhead 1.2%
Deadlock Resolution <1 tick

API Reference

Core types and methods for configuring and running concurrent simulations.

struct Engine

The primary simulation engine. Manages thread pools, event queues, and synchronization barriers.

let engine = Engine::new(Config {
    threads: 96,
    scheduler: Scheduler::WorkStealing,
    sync_granularity: Granularity::Tick,
    deadlock_detection: true,
});
fn engine.run(events: EventStream) -> SimResult

Execute a simulation with the given event stream. Returns a deterministic result that can be replayed.

let result = engine.run(events)?;
assert_eq!(result.checksum(), expected_checksum);
fn barrier.sync(threads: &[Thread]) -> SyncResult

Synchronize all threads at a barrier point. Blocks until all threads have reached the barrier.

let sync = barrier.sync(&active_threads)?;
match sync.status {
    SyncStatus::Complete => continue,
    SyncStatus::Timeout(d) => handle_timeout(d),
}

Quick Start

Get a concurrent simulation running in under five minutes.

01

Install

cargo add completengine
02

Configure

let config = Config::default()
    .threads(num_cpus::get())
    .scheduler(Scheduler::WorkStealing);
03

Define Events

let events = EventStream::from_iter(
    (0..10_000).map(|i| Event::new(i, payload))
);
04

Run

let engine = Engine::new(config);
let result = engine.run(events)?;
println!("Processed {} events in {:?}",
    result.count(), result.elapsed());