wings-codegen 0.0.4

Cranelift AOT machine-code backend for Wings VM
Documentation

Wings VM

English | 简体中文 · Website & Docs · crates.io

A managed AOT microprocess virtual machine for high-concurrency stateful applications.

Wings implements its runtime in Rust and compiles wings-lang business logic ahead-of-time (AOT) into managed native machine code via Cranelift. Its goal is to deliver higher sustained throughput and lower memory footprint than BEAM under identical stateful workloads, while preserving message isolation, preemptive fairness, hierarchical resource quotas, and fault recovery.

  • Throughput Goal: Achieve higher sustained throughput under identical CPU quotas and tail-latency (p99 / p999) constraints.
  • Memory Goal: Lower total machine memory footprint and raise single-node process density under identical session state, mailbox depth, and active ratios.
  • Primary Platforms: macOS AArch64 (Apple Silicon) and Linux x86-64.

[!IMPORTANT] Early-Stage Notice (0.0.x): Wings is under rapid early iteration with no backward-compatibility guarantees. Language syntax, the managed C ABI, artifact manifests (manifest.json / bundle.json), CLI flags, and Rust APIs may change with breaking updates—always recompile .wings sources after upgrading.

Current Capabilities

  • Language & Frontend (wings-lang): Supports actor and top-level/local immutable struct types, multiple state bindings, int / bool / unit / [int] / bytes / str, typed nullable pid<Actor> handles, if / else branching, while loops, bounded direct and mutual recursion within managed stack frames, and a lightweight wings-lsp language server (diagnostics, hover, goto-definition, references, document symbols, rename, completion).
  • Actor Messaging & Fault Tolerance: Supports spawn(Actor), one-way messaging (! / .tell), non-blocking requests with timeout callbacks (.ask(..., timeout: ..., then: ...)), delayed self-timers (send_after), and lifecycle exit notifications (monitor).
  • Compiler & Runtime: Precise CFG-based GC root liveness analysis, per-process chunked bitmap mark-sweep GC with inline single-buffer storage (BufferStorage::One), O(1) slot + generation capability addressing (Slot <= 64 B), pooled reusable coroutine stacks with zero-stack direct spawn, segmented cache-line-partitioned lock-free fast mailboxes (SharedMailboxInner <= 448 B, 64 B Envelope), multi-worker preemptive Scheduler with zero-alloc intrusive ready lists, three-level (VM -> Tenant -> Process, 128 B AccountNode) resource admission, and zero-RMW global Rust allocator + OS process memory accounting (WingsAllocator / native_memory_ledger).
  • Bundling & Network Serving: Multi-actor bundling via wings-compile build-app, and event-driven non-blocking Reactor serving (native kqueue/epoll + slab connection indexing + reply wakeup pipe + Condvar graceful drain) via wings-vm serve over stdio, --tcp (JSON Lines), and --http (JSON-RPC + GET /healthz, /metrics, /faults).
  • Paired BEAM Benchmarks & Known Boundaries: The manual workflow runs hot-queue, sparse-256 (10,000 actors), mixed-4k, and fairness on Linux x86-64 under a hard 2-vCPU quota and on macOS Arm64. See Evaluation & Acceptance for the latest CI results, methodology, and bare-metal sign-off. OS loader metadata outside the Rust allocator is measured at process scope; multi-file imports and declarative supervision remain on the roadmap.

Quick Start

Prerequisites: Rust 1.85+ and a system C linker (cc, overridable via CC). Install the CLI toolchain directly from crates.io:

cargo install wings-compile wings-vm wings-lsp --version 0.0.4 --locked

1. Static Check & Single-Actor Execution

# Static syntax, type, and protocol check
cargo run -p wings-compile -- check examples/counter.wings

# Build a single-actor native AOT artifact (output directory must not exist)
cargo run -p wings-compile -- build examples/counter.wings -o target/counter-aot

# Execute a JSON Lines message stream (--trusted is for trusted local builds only)
cargo run -p wings-vm -- run --trusted target/counter-aot < examples/counter.messages.jsonl

2. Multi-Actor Application Bundle & Serving

# Compile a multi-actor bundle (includes supervision restart and heartbeat timers)
cargo run -p wings-compile -- build-app examples/session-service.wings -o target/session-bundle

# Start a multi-worker HTTP server (POST /<handler> and GET /healthz)
cargo run -p wings-vm -- serve --trusted target/session-bundle --workers 2 --http 127.0.0.1:8080

# Or start a TCP JSON Lines server
cargo run -p wings-vm -- serve --trusted target/session-bundle --workers 2 --tcp 127.0.0.1:9000

3. Development & Verification Commands

# Inspect checks selected for staged, unstaged, and untracked changes
python3 scripts/verify_incremental.py --plan

# Run selected checks; reuse successful local results when inputs are unchanged
python3 scripts/verify_incremental.py

# Include committed branch changes relative to main
python3 scripts/verify_incremental.py --base main

Routine CI uses the same incremental scheduler. Full dual-platform, MSRV, and AOT checks run manually through release.yml before publishing; paired BEAM benchmarks remain a separate manual workflow. See Evaluation for scope and cache rules.

Documentation

中文读者请参阅 简体中文 README 及 docs/zh/ 目录下的完整中文文档。

Document 中文文档 Summary
Product Positioning 产品定位 Performance & memory targets, target workloads, and trade-offs vs. BEAM / Tokio / Wasmtime
Architecture 架构设计 11-crate workspace isolation, Cranelift AOT pipeline, managed C ABI, and precise GC
Language Design 语言设计 wings-lang syntax, immutable value types, async messaging, timers, and monitors
Runtime 运行时 Microprocess layout, stack pooling, lock-free mailboxes, M:N preemption, and 3-level quotas
Evaluation & Acceptance 评测与验收 Paired BEAM benchmarks, dual-platform CI results, and optimization discipline
Risks & Roadmap 风险与里程碑 0.0.x evolution policy, technical slices 1–7, known risks, and M1–M5 milestones
Crate Publishing 包发布 Apache-2.0 license, topological crates.io release order, and release history

Before contributing code or documentation, please review AGENTS.md.