Skip to content

dwerner/tocin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 _____ ___   ____ ___ _   _
|_   _/ _ \ / ___|_ _| \ | |
  | || | | | |    | ||  \| |
  | || |_| | |___ | || |\  |
  |_| \___/ \____|___|_| \_|

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.

Why tocin?

  • 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

Performance

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

Features

  • 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

Architecture

tocin is built on:

  1. Runtime: monoio - thread-per-core, io_uring-based async runtime
  2. 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.

Getting Started

Rust Version

tocin's MSRV is 1.75.

Dependencies

[tocin-build] uses protoc Protocol Buffers compiler to compile Protocol Buffers resource files.

Project Layout

Differences from tonic

Runtime Model

  • tocin uses monoio's thread-per-core model where tasks are !Send
  • Each thread has its own event loop with no work-stealing

Memory Management

  • tocin uses arena allocation via defiant with borrowed data (&'arena [u8])
  • Messages borrow from arena instead of owning heap allocations

Type System

  • tocin APIs require lifetime annotations: Message<'arena>
  • Arena lifetime must be threaded through the application

License

This project is licensed under the MIT license.

Contribution

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.

Credits

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.

About

Fork of tonic gRPC using defiant for arena-backed message parsing. Exploring zero-copy RPC performance.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors