Skip to content

client/transport: in-process dispatch fast-path (skip codec + network hop) #4817

Description

@asim

Context (from the gap audit + Mu benchmarks — architectural, human-led)

For "go-micro is the spine an agent dispatches through" to be true and fast, in-process calls can't pay codec + transport tax. Mu measured a service.Call at ~398µs over HTTP loopback, ~64µs / 187 allocs over the memory transport — still too heavy for an agent making many tool calls per turn, and the reason Mu built capabilities three ways (HTTP / go-micro / package func).

Audit findings:

  • client/rpc_client.go:148 — no in-process fast-path: every Call does pool.Get(address) → Dial → transport, simulating a network hop even when caller and callee share a process.
  • transport/memory.go:82 — the memory transport double-serializes (gob over an io.Pipe on top of the RPC codec) with ~4–5 goroutine handoffs per call — the dominant latency source.

Good news

Low-risk: the server already keeps a process-local handler table (server router serviceMap), and the RPC codec already passes *codec/bytes.Frame bodies through without serialization. So a local transport / a client shortcut that dispatches directly to router.ServeRequest would eliminate the gob+pipe double-serialization and the goroutine handoffs — plausibly low-single-digit µs and a handful of allocs.

Why human-led

Touches the client/transport/registry seam and dispatch semantics (metadata, context, streaming) — architectural. Design 1:1.

Acceptance (once designed)

  • An in-process Call (client and server in the same process) skips codec+transport and dispatches directly; a benchmark shows a large drop in latency/allocs vs. the memory transport.
  • No behavior change for cross-process calls; existing client/server/transport tests pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementneeds-humanRequires a human/architect decision (breaking or architectural)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions