Skip to content
CVL COREUnity SDK : Zero-Allocation Client

Zero-Allocation Client Architecture

[SPECIFICATION] Client Presentation Runtime Invariant

The CVL CORE Unity Client SDK operates as an allocation-free Zero-Authority Visual Proxy with turnkey movement smoothing included. Engineered to eliminate managed garbage collection (GC) frame spikes in Unity C#, the runtime enforces an architectural 0 B/frame managed heap ceiling across its 30Hz ingress, local movement prediction, 133ms snapshot ring-buffer interpolation, rollback blending, and screen-space UI pipelines—sustaining over 500 active physical proxies simultaneously on commodity hardware.


[SEC 01.0] Executive Architecture Overview & Client Pipeline

Section titled “[SEC 01.0] Executive Architecture Overview & Client Pipeline”

Standard multiplayer client architectures allocate megabytes of ephemeral managed memory per frame through stream deserialization, reference-type boxing, dynamic string parsing, and LINQ queries. In Unity, this churn triggers periodic 15ms–50ms Garbage Collection (Boehm GC / Incremental GC) pauses that destabilize frame rates, introduce frame pacing stutter, and induce input latency.

The CVL CORE client runtime acts as the high-efficiency counterpart to the authoritative spatial micro-kernel. While the server guarantees deterministic execution under a Sub-55.0 MB flatline RAM ceiling on a single-threaded Linux VPS, the client presentation layer consumes this high-density kinematic stream on low-spec client hardware without frame pacing degradation.

CVL CORE Client-Server System Topology & Wire Pipeline
+--------------------------------------------------------------------------------------------------+
| CVL CORE SYSTEM TOPOLOGY |
+--------------------------------------------------------------------------------------------------+
| |
| +------------------------------------+ +------------------------------------------+ |
| | SERVER RUNTIME | | CLIENT RUNTIME | |
| | - Sub-55.0 MB Flatline RAM Ceiling | | - 0 B Managed Heap Allocation Hot-Path | |
| | - Single-Threaded 30Hz Tick Loop | | - SPSC Lock-Free Spatial Ring Buffer | |
| | - 15Hz Asymmetric Egress Conflate | | - Blittable Struct Memory Layouts | |
| | - Commodity Linux VPS ($19.60/mo) | | - ArrayPool<byte> Command Dispatch | |
| +-----------------+------------------+ +--------------------+---------------------+ |
| | ^ |
| | Authoritative Wire Protocol | |
| +===================================================+ |
| 15Hz / 30Hz Little-Endian TCP Stream |
| |
+--------------------------------------------------------------------------------------------------+
[INVARIANT] Elimination of Garbage Collection Spikes
Section titled “[INVARIANT] Elimination of Garbage Collection Spikes”

By enforcing zero managed heap allocations on the 30Hz telemetry egress and 15Hz spatial broadcast ingress paths, client frame times remain locked to display hardware refresh intervals (60Hz / 120Hz) without garbage collection stalls.

[EFFICIENCY] Inbound Deserialization Efficiency
Section titled “[EFFICIENCY] Inbound Deserialization Efficiency”

The server’s 15Hz asymmetric egress conflation pipeline reduces inbound byte processing by over 50% compared to symmetric 30Hz broadcasting, lowering client CPU cache churn, thread wake-ups, and unmanaged memory throughput.

[DENSITY] Massive Proxy Concurrency Density
Section titled “[DENSITY] Massive Proxy Concurrency Density”

The presentation layer sustains over 500 active physical proxies simultaneously within a single client scene, maintaining sub-millisecond network parsing overhead on commodity x86 and ARM64 chipsets.

[VALIDATION] The Crucible Stress Validation
Section titled “[VALIDATION] The Crucible Stress Validation”

Stress-tested against 500 concurrent synthetic autonomous agents running at 30Hz, confirming that continuous snapshot ring-buffer interpolation, entity pool recycling, and high-frequency vitals updates allocate zero bytes of managed heap memory during active gameplay.

[TURNKEY SMOOTHING] Built-In Prediction, Interpolation & Rollback Blending
Section titled “[TURNKEY SMOOTHING] Built-In Prediction, Interpolation & Rollback Blending”

Developers do not have to hand-roll client movement responsiveness or jitter compensation from scratch. Out of the box, the Unity C# SDK ships with:

  • Remote Proxy Interpolation (CVLNetworkIdentity): Fixed 8-slot, 133ms historical snapshot ring buffer with dynamic RTT + jitter delay scaling, clock-drift alignment, and smoothed animator speed blending.
  • Local 30Hz Movement Prediction (CVLPlayerController): Responsive local fixed-step kinematics with 0.15s jump buffering, render-rate visualPivot smoothing, and a self-NetID filter to prevent broadcast echo rubber-banding.
  • Smooth Server Reconciliation: Minor server position corrections blend smoothly (0.15m blend threshold / 2.0m hard-snap threshold) rather than jarring the camera, alongside replicated stance and status bitmasks (OP_VITALS).
  • Upcoming Beta Tooling: One-click Unity Editor Scene-to-AABB Geometry Exporter, In-Viewport Server AABB Parity Debugger, and standardized bit-packed animation/VFX state-machine hooks (see the Engine Architecture Roadmap).

[SEC 02.0] Thread-Decoupled Ingress & Memory Topology

Section titled “[SEC 02.0] Thread-Decoupled Ingress & Memory Topology”

To isolate the Unity Main Thread from operating system socket I/O, the client segregates network ingress, spatial translation, and entity state hydration across asynchronous thread boundaries using lock-free data structures.

Thread-Decoupled Ingress & Memory Topology
NETWORK INGRESS THREAD
|
[ Non-Blocking TCP Socket ]
|
NetworkStream.Read()
|
ReadOnlySpan<byte>
|
+----------------------------+-----------------------------+
| High-Velocity Spatial Stream | Discrete Control Commands
v v
MemoryMarshal.Cast<byte, T>() ArrayPool<byte>.Shared.Rent()
| |
[ 65,536-Slot SPSC Ring Buffer ] [ ConcurrentQueue<NetCommand> ]
(KinematicState[65536]) (mainThreadNetQueue)
| |
====================|==========================================================|====================
| THREAD BOUNDARY |
====================|==========================================================|====================
v v
LateUpdate() / Interpolation Update() / Command Execution
| |
133ms Snapshot Ring Buffers Hydration Time-Box Governor
(Fixed 8-Slot Circular Array) (MAX_SPAWNS: 4, BUDGET: 2.5 ms)
| |
v v
Transform Position/Rotation Pre-Warmed Entity Object Pools
(Mathf.Lerp / Slerp) (Dictionary<ushort, Stack<GO>>)
|
v
ArrayPool<byte>.Shared.Return()

A dedicated background receiver thread reads inbound TCP stream data directly into pre-allocated byte buffers without invoking managed object instantiations.

High-frequency spatial updates bypass managed queues entirely. Unmanaged byte slices cast directly into blittable structs and enter a lock-free Single-Producer Single-Consumer (SPSC) circular ring buffer in O(1) time.

[POOLING] Discrete Command Allocation Path
Section titled “[POOLING] Discrete Command Allocation Path”

Infrequent state mutations (entity spawns, removals, vitals updates, combat damage flashes) rent byte buffers from ArrayPool<byte>.Shared, pass to the Main Thread via unmanaged command envelopes, and return to the pool immediately inside guaranteed execution blocks.

The Unity Main Thread processes queued network commands under strict time-box and spawn-count budgets, preventing frame pacing hitches during high-density spawn events.


[SEC 03.0] Protocol Architecture & Stream Segregation

Section titled “[SEC 03.0] Protocol Architecture & Stream Segregation”

Rather than exposing granular opcode implementations or byte offsets publicly, the client transport segregates network communication into three distinct functional streams. All wire layouts enforce sequential memory alignment and Little-Endian byte ordering.

[STREAMS] Stream Categorization & Wire Separation
Section titled “[STREAMS] Stream Categorization & Wire Separation”
  • High-Velocity Kinematic Streams: Compressed spatial coordinate frames delivering world transformations. Handled exclusively on the lock-free ring buffer path to eliminate latency and synchronization stalls.
  • Discrete State & Lifecycle Commands: Guaranteed event frames governing entity admission, pool binding, role transitions, health changes, and connection state. Handled via pooled command buffers.
  • Bidirectional RPC & Telemetry: Outbound 30Hz player input sampling, hardware RTT tracking, and Sidecar Event Bus integration, operating without managed allocations on the client egress thread.
[PROTOCOL] Authoritative Protocol Definitions & SDK Encapsulation
Section titled “[PROTOCOL] Authoritative Protocol Definitions & SDK Encapsulation”

All binary packet struct layouts, bitmask definitions, and opcode constants are sealed within the private SDK headers (Assets/CVL_CORE_SDK/Network/ProtocolConstants.cs). The public engine runtime exposes strongly typed event delegates and managed proxies, shielding gameplay code from raw wire formats.


[SEC 04.0] Zero-Copy Ingress & SPSC Ring Buffer Pipeline

Section titled “[SEC 04.0] Zero-Copy Ingress & SPSC Ring Buffer Pipeline”

Network ingestion bypasses BinaryReader and BitConverter entirely. Incoming TCP stream spans are cast directly to native struct arrays in place via MemoryMarshal.Cast.

[INGEST] Direct Memory Ingestion & Span Casting
Section titled “[INGEST] Direct Memory Ingestion & Span Casting”

The background reader casts incoming payload bytes directly to unmanaged structs and enqueues them into the circular buffer in O(1) time:

Assets/CVL_CORE_SDK/Network/CVLNetworkManager.cs
// Zero-copy cast directly over unmanaged memory span
ReadOnlySpan<byte> payloadSpan = streamSpan.Slice(readOffset, totalPayloadBytes);
ReadOnlySpan<WireSpatialStride> strides = MemoryMarshal.Cast<byte, WireSpatialStride>(payloadSpan);
for (int i = 0; i < strides.Length; i++)
{
ref readonly WireSpatialStride stride = ref strides[i];
// Filter local proxy self-NetID to prevent prediction rubberbanding
if (stride.NetId == this.localNetId) continue;
// Enqueue directly into unmanaged SPSC circular ring buffer
this.spatialRingBuffer.Enqueue(stride.NetId, serverTick, stride.PackedData);
}
[RING BUFFER] Lock-Free Circular Buffer Mechanics
Section titled “[RING BUFFER] Lock-Free Circular Buffer Mechanics”

The SpatialRingBuffer uses a power-of-two capacity (2^16 = 65,536 slots) so head and tail wraps execute via a single bitwise AND operation (head & (CAPACITY - 1)). If the network thread outpaces the rendering thread, the buffer overwrites stale data without locking threads or triggering allocations.


[SEC 05.0] Main Thread Hydration & Execution Budgeting

Section titled “[SEC 05.0] Main Thread Hydration & Execution Budgeting”

To maintain a consistent 60Hz or 120Hz display refresh rate, entity instantiation, destruction, and bundle parsing must never block the main rendering thread.

The client processes queued network commands inside Unity’s Update loop under two strict guardrails:

  1. Entity Activation Cap: A maximum of 4 entity proxies may be activated per frame (MAX_SPAWNS_PER_FRAME = 4).
  2. Frame Budget Guardrail: Command processing halts if main-thread execution exceeds 2.5 ms (MAX_HYDRATION_BUDGET_MS = 2.5). Any remaining commands roll over to the subsequent frame.
Assets/CVL_CORE_SDK/Network/CVLNetworkManager.cs
// Drain queue under strict execution time-budget
while (this.mainThreadNetQueue.TryDequeue(out NetCommand cmd))
{
try
{
ExecuteCommand(cmd);
}
finally
{
// Guaranteed buffer reclamation to prevent managed heap growth
if (cmd.RawBuffer != null)
ArrayPool<byte>.Shared.Return(cmd.RawBuffer);
}
if (spawnsProcessed >= MAX_SPAWNS_PER_FRAME || stopwatch.Elapsed.TotalMilliseconds >= MAX_HYDRATION_BUDGET_MS)
break;
}
[LIFECYCLE] Pre-Warmed Object Pooling & Zero-Destruction Lifecycle
Section titled “[LIFECYCLE] Pre-Warmed Object Pooling & Zero-Destruction Lifecycle”

Dynamic calls to GameObject.Instantiate() or GameObject.Destroy() on the gameplay path are strictly prohibited. The client pre-warms a fixed pool of visual prefabs at startup based on totalPoolCapacity configured in CVLEngineConfig. Despawned entities unbind screen-space nameplates, reset transforms, and push their references back onto the pool stack.


[SEC 06.0] Screen-Space UI & Sub-Canvas Isolation

Section titled “[SEC 06.0] Screen-Space UI & Sub-Canvas Isolation”

In standard Unity UI hierarchies, moving a world-space nameplate or modifying a RectTransform marks the root canvas dirty, forcing the engine to regenerate canvas geometry for all child elements on the main thread. With 500 active proxies moving simultaneously, root canvas rebuilds consume over 12 ms per frame.

CVL CORE eliminates canvas rebuild overhead through three architectural invariants:

[UI // 01] Root Canvas GraphicRaycaster Stripping
Section titled “[UI // 01] Root Canvas GraphicRaycaster Stripping”

The centralized Screen Space - Overlay canvas strips its GraphicRaycaster component at startup, eliminating per-frame raycast target traversal across hundreds of proxy nameplates.

[UI // 02] Sub-Canvas Isolation & Dirty Vertex Containment
Section titled “[UI // 02] Sub-Canvas Isolation & Dirty Vertex Containment”

Each pooled nameplate carries an isolated sub-Canvas component (overrideSorting = false). Positional updates isolate dirty vertex flags to the individual nameplate sub-tree, completely shielding the root canvas from batch invalidation.

Screen-space positions are filtered through a deadband threshold where squared displacement delta is evaluated against a minimum floor (sqrMagnitude >= 0.0001f). Sub-pixel movements bypass RectTransform mutations completely.

Assets/CVL_CORE_SDK/Core/CVLScreenSpaceUIManager.cs
private static void ConfigureSubCanvasIsolation(GameObject nameplateInstance)
{
// Isolate RectTransform modifications from parent canvas batching
Canvas subCanvas = nameplateInstance.GetComponent<Canvas>();
if (subCanvas == null)
subCanvas = nameplateInstance.AddComponent<Canvas>();
subCanvas.overrideSorting = false;
// Strip raycasting checks from child graphics
Graphic[] graphics = nameplateInstance.GetComponentsInChildren<Graphic>(true);
for (int i = 0; i < graphics.Length; i++)
graphics[i].raycastTarget = false;
}

[SEC 07.0] Performance Forensics & Memory Profile

Section titled “[SEC 07.0] Performance Forensics & Memory Profile”

The runtime behavior of the zero-allocation pipeline was benchmarked using the in-engine diagnostic profiler (CVLClientProfilerReport) across 600-frame test runs under a continuous 500-entity load on an Intel Core i9 workstation running Unity 2022 LTS.

[BENCHMARK] Empirical Client Profile Baseline (500 Active Entities)
Section titled “[BENCHMARK] Empirical Client Profile Baseline (500 Active Entities)”
Performance Metric Monolithic Engine Baseline (Unity/Mirror/PUN) CVL CORE Zero-Allocation Runtime Operational Advantage
Hot-Path GC Allocations 120 KB – 450 KB / frame 0 B / frame Eliminates managed garbage collections entirely.
GC Pause Frequency 1 pause every 3 – 8 seconds Zero pauses during gameplay Prevents visual micro-stutter and frame drops.
Peak GC Pause Duration 18.5 ms – 52.0 ms 0.0 ms Preserves a deterministic 60Hz/120Hz frame budget.
Packet Deserialization 1.8 ms – 3.4 ms (Reflective serialization) 0.12 ms (MemoryMarshal.Cast) Unlocks high-frequency processing for low-power CPUs.
Canvas Mesh Rebuilds 8.5 ms – 14.0 ms / frame 0.02 ms / frame (Sub-Canvas isolation) Protects main-thread rendering performance.
Egress Bandwidth Load 180 KB/s (Symmetric 30Hz broadcast) 78 KB/s (15Hz egress conflation) Cuts network infrastructure overhead by over 50%.

[SEC 08.0] Architectural Invariants & Client Guardrails

Section titled “[SEC 08.0] Architectural Invariants & Client Guardrails”

Operational and memory-access guardrails ensure deterministic client performance across multi-threaded runtimes.

[GUARDRAIL] Thread Boundary Isolation & Unity API Thread-Safety
Section titled “[GUARDRAIL] Thread Boundary Isolation & Unity API Thread-Safety”

The Unity Engine API is fundamentally thread-unsafe. Background network threads must never access Unity transform references, query Time.time, or modify active GameObject pointers. All cross-thread state transfer must pass through blittable structs via the SpatialRingBuffer or rented memory arrays in mainThreadNetQueue.

[GUARDRAIL] ArrayPool Buffer Leasing & Explicit Slice Count Discipline
Section titled “[GUARDRAIL] ArrayPool Buffer Leasing & Explicit Slice Count Discipline”

ArrayPool<byte>.Shared.Rent(minSize) returns an array whose length is guaranteed to be at least minSize, but may be rounded up to the nearest power of two. Always pass explicit packet length counters downstream rather than reading buffer.Length to avoid parsing uninitialized pool memory, and guarantee returns inside finally blocks.

[GUARDRAIL] Sequential Struct Layout Packing (Pack = 1)
Section titled “[GUARDRAIL] Sequential Struct Layout Packing (Pack = 1)”

Blittable structs used for zero-copy deserialization require sequential layout packing ([StructLayout(LayoutKind.Sequential, Pack = 1)]). Omitting packing attributes causes platform-dependent padding mismatches across 64-bit architectures. Struct alignment parity is verified at startup via IEEE 802.3 CRC32 hash assertions.

[CRITICAL // GUARDRAIL] CLIENT PHYSX ISOLATION & 30HZ TELEMETRY CONTINUITY

1. Remote Proxy PhysX Flushes: Calling Physics.SyncTransforms() or running active CharacterController / rigid collider components on remote proxies stalls the Unity Main Thread and causes 133ms snapshot interpolation jitter during mass spawn events. Remote proxies must have all CharacterController, Rigidbody, and non-trigger collider components disabled at instantiation, and Physics.SyncTransforms() must be gated strictly behind isLocal == true.
2. 30Hz Telemetry Continuity During Input Lock: When local player input is suspended by UI menus, spectator camera rigs, or vehicle mount bindings, set CVLEngineAPI.IsInputSuspended = true rather than disabling the player controller or ceasing the network tick. Stopping the 30Hz telemetry transmission loop causes the server to detect a transport flatline and evict the session upon FLATLINE_TIMEOUT (10.0s) expiration.