π Nylon Ring
Ultra-Fast ABI-Stable HostβPlugin Interface for Rust
Build fast native plugins with an explicit C-compatible ABI.
Features β’ Quick Start β’ Performance β’ System Overview
π Features
- Stable ABI v1 β C-compatible types, fixed status values, version and structure-size validation.
- Flexible calls β fire-and-forget, async unary, synchronous fast path, and bounded streaming with backpressure.
- Safe lifecycle β in-flight call guards, graceful unload/reload, timeouts, and automatic request cleanup.
- Cross-language validation β Rust examples plus a buildable C plugin.
The workspace provides:
nylon-ringβ ABI types, vtables, and thedefine_plugin!macro.nylon-ring-hostβ dynamic loading, routing, streaming, lifecycle controls, and metrics.
MSRV: Rust 1.88.
π Quick start
Install
# Plugin
[]
= "0.1.2"
# Host
[]
= "0.1.2"
Plugin crates must also build as a dynamic library:
[]
= ["cdylib"]
Host
use ;
# async
Other call patterns:
plugin.call.await?;
plugin.call_response_fast.await?;
plugin.call_response_timeout.await?;
let = plugin.call_stream.await?;
See the complete Rust plugin example and Rust host example.
Run the workspace demo:
π Performance
Release-build snapshot on an Apple M1 Pro.
Single-stream (Criterion)
| Host operation | Time | Throughput |
|---|---|---|
| Fire-and-forget | 40.610 ns | 24.625M calls/s |
| Synchronous fast path | 59.121 ns | 16.914M calls/s |
| Standard unary | 95.797 ns | 10.439M calls/s |
| Unary + 128-byte payload | 110.07 ns | 9.085M calls/s |
| Unary + 1 KiB payload | 172.30 ns | 5.804M calls/s |
| Unary + 4 KiB payload | 232.85 ns | 4.295M calls/s |
Multi-core (10 workers)
| Host operation | Throughput |
|---|---|
| Fire-and-forget | 126.01M calls/s |
| Synchronous fast path | 99.18M calls/s |
| Standard unary | 25.34M calls/s |
These are reference measurements, not cross-platform guarantees. Single-stream uses Criterion estimates; multi-core is a direct-terminal run with 100 requests per batch for 10 seconds. Reproduce them with:
NYRING_BENCH_WORKERS=10
π System overview
+------------------------------------------------------+
| Host (nylon-ring-host) |
| NylonRingHost |
| ββ LoadedPlugin + in-flight call gate |
| ββ HostContext |
| ββ thread-local synchronous slot |
| ββ sharded unary router + inline completion |
| ββ bounded stream queues |
+-------------------------+----------------------------+
| C ABI v1
| NrPluginVTable / NrHostVTable
+-------------------------+----------------------------+
| Plugin |
| define_plugin! β named handlers β send_result |
+------------------------------------------------------+
The host validates and initializes a library, assigns each call a session ID, then routes plugin callbacks to the matching unary request or stream. Call guards keep the library loaded until active work finishes; graceful unload/reload stops new calls and waits for existing calls to drain.
π‘ Safety
- Host and plugin must use the same target and ABI version.
NrStrandNrBytesare borrowed; copy them before retaining their data.- Owned
NrVec<T>values carry the producer's drop callback, avoiding cross-allocator frees. - Plugins must stop worker threads and callbacks during shutdown.
- Only load trusted native libraries; this is not a security sandbox.
Development
Publishing is handled by GitHub Actions in dependency order using the
organization-level RUST_TOKEN secret.