- File:
tocin/src/codec/mod.rs - Changes:
- Changed
Decoder::ItemtoDecoder::Item<'a>(GAT) - Added
arena: &'a defiant::Arenaparameter todecode()method - Updated
Codectrait to usetype Decode<'a>instead oftype Decode - Updated trait bounds to use
for<'a> Decoder<Item<'a> = ...>
- Changed
- File:
tocin-defiant/src/codec.rs - Changes:
- Implemented GAT in
ProstDecoder - Updated
decode()to accept arena parameter - Changed from creating temporary arena to using passed arena
- Note: Currently creates temp arena in
decode_chunk(line 381 of decode.rs) - needs future refactor
- Implemented GAT in
- Files:
tocin/src/codec/encode.rstocin/src/client/grpc.rstocin/src/server/grpc.rstocin/src/request.rstocin/src/codec/decode.rs
- Changes:
- Replaced
use tokio_stream::Streamwithuse futures_core::Stream - Replaced
use tokio_stream::StreamExtwithuse futures_util::StreamExt - Replaced
tokio_stream::adapters::Fusewithfutures_util::stream::Fuse
- Replaced
- File:
tocin/src/codec/decode.rs - Changes:
- Removed
SyncWrapperfromStreaming<T>struct - Changed
decoder: SyncWrapper<Box<...>>todecoder: Box<...> - Changed
body: SyncWrapper<Body>tobody: Body - Updated all
SyncWrapper::new()calls - Rationale: Monoio is thread-per-core, so
!Sendtypes are acceptable
- Removed
- Files:
tocin/src/service/interceptor.rstocin/src/service/layered.rstocin/src/service/recover_error.rstocin/src/service/mod.rs
- Changes:
- Commented out all tower-dependent code with
/* ... */ - Kept
Interceptortrait (core functionality) - Added TODO comments for re-implementation
- Disabled exports in
service/mod.rs
- Commented out all tower-dependent code with
- ✅ Compiles with warnings only (no errors)
⚠️ Has unused import warnings⚠️ Has feature flag warnings (expected - features removed from Cargo.toml)
The main blocking issues are:
-
GAT Lifetime Parameters Missing -
error[E0107]Streaming<T::Decode>needs to beStreaming<...>with proper lifetime handlingCodec<Decode = M2>trait bounds need updating toDecode<'a> = M2- Locations:
tocin/src/server/grpc.rs:401tocin/src/client/grpc.rs:218, 238, 274
- Root Cause:
Streaming<T>type assumesTis a concrete type, but with GATs, decoded items have lifetime parameters
-
Streaming Type Refactor Needed
- Current:
Streaming<T>whereT: 'static - Target: Need to handle
Streaming<T>whereThas lifetime from arena - This is a fundamental design change mentioned in INTEGRATION_PLAN.md
- Current:
-
Missing tokio-stream in Other Packages
- Several other workspace packages still use
tokio_stream - These will need similar refactoring
- Several other workspace packages still use
-
Refactor Streaming Type
- Option A: Make
Streaming<T>work with GAT types - Option B: Use callback pattern instead of
Streamtrait (per INTEGRATION_PLAN.md) - Option C: Temporary: Use owned types for now, optimize with arena later
- Option A: Make
-
Fix GAT Trait Bounds
- Update all
Codec<Decode = M>to handleDecode<'a> - May need higher-ranked trait bounds
for<'a> Codec<Decode<'a> = M>
- Update all
-
Remove Tokio-Based Transport Layer
- Remove
tocin/src/transport/hyper/tokio code - Files to update:
tocin/src/transport/server/mod.rstocin/src/transport/server/conn.rstocin/src/transport/server/incoming.rs
- Remove
-
Create Monoio-Based Transport Layer
- Implement using
monoio-http - Add arena support at connection level
- Per-connection arena ownership (not pooled)
- Implement using
-
Update Service Traits with Arena Lifetimes
- Add
arena: &'a Arenato service method signatures - Change from
#[async_trait]to#[async_trait(?Send)] - Implement callback pattern for streaming
- Add
-
Update tocin-build Codegen
- Generate traits with arena parameters
- Generate
#[async_trait(?Send)] - Split client streaming into
on_message+finish - Server streaming uses callback instead of Stream
- Per-connection arena (not pooled, not thread-local)
- Connection handler owns arena for its lifetime
- Reset between requests for bounded memory
- Memory profile:
num_connections × peak_message_size
- Monoio (thread-per-core) instead of Tokio (work-stealing)
- Tasks never migrate threads (
!Sendis acceptable) - Rationale: Arena references are
!Send, require thread pinning
- Callback pattern instead of
Streamtrait - Framework manages stream loop
- User implements per-message handlers
- Solves lifetime issues with arena-borrowed data
- ✅
tocin/src/codec/mod.rs- Decoder trait with GAT - ✅
tocin/src/codec/decode.rs- Updated Streaming (partial) - ✅
tocin/src/codec/encode.rs- Removed tokio-stream - ✅
tocin-defiant/src/codec.rs- Arena-aware decoder
- ✅
tocin/src/service/interceptor.rs- Tower code disabled - ✅
tocin/src/service/layered.rs- Tower code disabled - ✅
tocin/src/service/recover_error.rs- Tower code disabled - ✅
tocin/src/service/mod.rs- Updated exports
- ✅
tocin/src/server/grpc.rs- Removed tokio-stream - ✅
tocin/src/client/grpc.rs- Removed tokio-stream ⚠️ Both need GAT updates
- ✅
tocin/src/request.rs- Removed tokio-stream
- ✅ tokio (except features still used by other deps)
- ✅ hyper
- ✅ hyper-util
- ✅ tower
- ✅ tower-service
- ✅ tower-layer
- ✅ h2
- ✅ axum
- ✅ tokio-stream
- ✅ sync_wrapper
- ✅ monoio = { version = "0.2", features = ["sync"] }
- ✅ monoio-http = "0.3"
- ✅ defiant = { path = "../defiant/defiant" }
- ✅ futures-core = "0.3"
- ✅ futures-util = "0.3"
-
Arena in decode_chunk (
tocin/src/codec/decode.rs:381)- Currently creates temp arena per decode
- Need to thread arena from connection handler
-
Tower Integration
- All tower-dependent middleware is disabled
- Need to decide: re-implement without tower, or re-add tower conditionally
-
Feature Flags
- Removed
server,channel,routerfeatures from Cargo.toml - Getting warnings about these missing features
- Need to restore or update feature flag usage
- Removed
-
Streaming Refactor
- Major: Replace
Streamtrait with callback pattern - See INTEGRATION_PLAN.md sections on "Streaming Challenge"
- Major: Replace
From INTEGRATION_PLAN.md:
- Small messages (12 bytes): 237-253ns
- Medium messages (1KB): ~400ns
- Large messages (84KB): 105µs
- Many allocations: 100+ per decode
- Goal: <150ns for 10KB messages (~50% improvement)
- 1-2 allocations per message (vs 100+)
- Single-copy decode
- Zero allocations after arena warmup
- INTEGRATION_PLAN.md - Complete integration strategy
- /home/dan/Development/en/memory/conversation_including_api.txt - Design discussions
- Defiant: github.com/dwerner/defiant
- Monoio: github.com/bytedance/monoio
- Monoio-http: github.com/monoio-rs/monoio-http