_____ ___ ____ ___ _ _
|_ _/ _ \ / ___|_ _| \ | |
| || | | | | | || \| |
| || |_| | |___ | || |\ |
|_| \___/ \____|___|_| \_|
A high-performance Rust implementation of gRPC built on monoio (thread-per-core runtime) and defiant (arena-based zero-copy protobuf).
tocin is a fork of tonic optimized for high-throughput streaming workloads through thread-per-core architecture and zero-copy memory management.
- Thread-per-core architecture: Built on monoio, eliminating cross-thread synchronization overhead
- Zero-copy protobuf: Uses defiant with arena allocation for minimal memory allocations
- High performance: 9-14% faster for streaming workloads, 11% faster for multiple messages
- gRPC compatible: Maintains gRPC compatibility with optimized internals
Benchmarks comparing tocin vs tonic:
| Benchmark | tonic | tocin | Improvement |
|---|---|---|---|
| Small chunks (100B) | 1361 MB/s | 1558 MB/s | +14.5% |
| Large messages (10kB) | 11382 MB/s | 12451 MB/s | +9.4% |
| Multiple messages (20) | 5338 MB/s | 5937 MB/s | +11.2% |
| Streaming (10 msgs) | 4827 MB/s | 5424 MB/s | +12.4% |
tocin excels at:
- Streaming multiple messages
- Very large messages (>10kB)
- Small chunk sizes
- High-throughput scenarios
- Bi-directional streaming
- High performance async I/O with thread-per-core model
- Zero-copy protobuf decoding with arena allocation
- Interoperability with standard gRPC implementations
- Custom metadata
- Authentication
- Health checking
tocin is built on:
- Runtime: monoio - thread-per-core, io_uring-based async runtime
- Protobuf: defiant - arena-based, zero-copy protobuf implementation
The thread-per-core model eliminates work-stealing overhead, while arena allocation minimizes allocations during message decoding.
tocin's MSRV is 1.75.
[tocin-build] uses protoc Protocol Buffers compiler to compile Protocol Buffers resource files.
tocin: Generic gRPC and HTTP/2 client/server implementation.tocin-build: Service codegen framework.tocin-defiant: defiant-based codec implementation.tocin-defiant-build: defiant-based service codegen.tocin-types: gRPC utility types including Well Known Types.tocin-health: Implementation of the standard gRPC health checking service.
- tocin uses monoio's thread-per-core model where tasks are
!Send - Each thread has its own event loop with no work-stealing
- tocin uses arena allocation via defiant with borrowed data (
&'arena [u8]) - Messages borrow from arena instead of owning heap allocations
- tocin APIs require lifetime annotations:
Message<'arena> - Arena lifetime must be threaded through the application
This project is licensed under the MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in tocin by you, shall be licensed as MIT, without any additional terms or conditions.
tocin is a fork of tonic by Lucio Franco and contributors. The core gRPC implementation and design patterns come from the excellent work of the tonic team.