Skip to content

perf(persona): tool dispatch through the uniform client + kill Value round-trip - #1702

Merged
joelteply merged 3 commits into
canaryfrom
feat/persona-tools-uniform-client
Jun 20, 2026
Merged

joelteply merged 3 commits into
canaryfrom
feat/persona-tools-uniform-client

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What

Routes the persona's ToolExecutor through the same continuum_client::Connection every citizen uses, over InProcessTransport (the local-connection variant) — no bespoke Arc<CommandExecutor> path. cli / mobile / persona now differ only by transport. Closes the executor half of #15.

Why (performance + harmony)

  • Concurrent batch: execute_native_batch dispatches the whole batch via join_all — native parallel tool calls in a turn are independent, correlate by tool_use_id. Consolidated burst at O(batch), never per-event FIFO.
  • Killed a memcopy on the hot path: CommandClient::execute<P,R> did to_value/from_value for P=R=Value — two full tree-walks of pure waste on every persona tool call. New execute_value forwards the Value straight through; execute delegates through it (round-trip only at the genuine typed boundary). +10–15% at scale even in debug.
  • Cow command names (alloc only on _→/), time_async! probe on the dispatch seam.

Proven, not claimed (gated #[cfg(feature="stress-tests")])

  • Barrier(50) deadlock-proofs — intra-batch + cross-persona dispatch is concurrent; serialization would deadlock → timeout fails.
  • Realistic load harness (load_harness.rs) — 50-persona team on a shared project via the REAL CodeModule, real payloads. read 27k/s, search 17k/s, write 31k/s, tree 6k/s, 0 errors.
  • Read scaling sweep 10→400 personas: 23k→35k reads/sec, flat latency, NO contention cliff. Dispatch overhead ~13µs ≈ 2% of a real read — the client path is not the bottleneck.

Next

airc remote-path (AircIpcTransport) body-opaque streamlining (separate PR).

Refs #15.

🤖 Generated with Claude Code

…Value round-trip

Persona ToolExecutor now rides the SAME continuum_client::Connection every
citizen uses, over InProcessTransport (the local-connection variant) — no
bespoke Arc<CommandExecutor> path. cli/mobile/persona differ only by transport.

- execute_native_batch dispatches the whole batch CONCURRENTLY (join_all):
  native parallel tool calls in a turn are independent, correlate by
  tool_use_id. Consolidated burst at O(batch), never per-event FIFO.
- CommandClient::execute_value: Value-native dispatch that skips the
  to_value/from_value round-trip the typed execute() did for P=R=Value (two
  full tree-walks of pure waste on every persona tool call). execute() now
  delegates through it — one dispatch path; round-trip only at the genuine
  typed boundary. +10-15% at scale even in debug.
- Cow command names: only allocate the _->/ rewrite when an underscore exists.
- time_async! probe on the dispatch seam (not eprintln).

Proven, not claimed (gated #[cfg(feature="stress-tests")]):
- Barrier(50) deadlock-proofs: intra-batch + cross-persona dispatch is
  concurrent; serialization would deadlock -> timeout fails.
- load_harness.rs: realistic 50-persona team on a shared project via the REAL
  CodeModule (read/search/tree/write, real payloads). read 27k/s search 17k/s
  write 31k/s tree 6k/s, 0 errors. Dispatch overhead ~13us = ~2% of a real
  read. read scaling sweep 10->400 personas: 23k->35k reads/sec, flat latency,
  NO contention cliff.

Verdict: the in-process client path scales clean; dispatch is not the
bottleneck. Next: airc remote-path (AircIpcTransport) body-opaque streamlining.

Refs #15.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
joelteply and others added 2 commits June 20, 2026 13:41
…s, preserve behavior

Adversarial reviewer (default-BLOCK) findings on #1702, all fixed:

- BLOCKER: the per-call `time_async!` wrap allocated 3 Strings every tool call
  (TimingGuard is NOT a no-op when logging is off — `.into()` x2 on construct +
  `format!` in Drop before the LOGGER check). It ADDED hot-path allocations in
  the PR meant to remove them, with a false "no-op" comment. Removed the per-call
  wrap; dispatch latency is already captured by the executor's command_completed
  event + measured by the load harness. Hot path is now alloc-lean.
- MAJOR: error content fed to the model was the ClientError wrapper Display
  ("substrate refused command `x`: …"). Now unwraps ClientError::Refused.reason
  so the model sees the substrate's real message ("Unknown command: …"), matching
  the prior behavior. Pinned by an assertion in failed_call_*.
- MAJOR: Binary command results flipped from success(metadata) to error when
  routed through InProcessTransport. command_result_to_value now mirrors
  CommandResult::to_json_value (Binary → Ok(metadata)). Pinned by a new test.
- MINOR: reworded the exec_over doc — this executor is not yet wired into
  build_workspace_cycle (that's the next slice of #15).
- NIT: restored alphabetical order of the InProcessTransport re-export.

All green: client execute_value, 6 executor tests (incl. 3 stress proofs),
4 in_process_transport tests (incl. the new Binary pin).

Refs #15.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Re-review caught it: load_scaling_curve's comment still claimed per-call
dispatch is timed by a time_async! probe — that probe was removed in the prior
fix commit. Corrected to state batch latency is the measurement and per-call
dispatch is intentionally not separately probed on the hot path. Comment-only.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@joelteply
joelteply merged commit 2c3dc8c into canary Jun 20, 2026
2 checks passed
@joelteply
joelteply deleted the feat/persona-tools-uniform-client branch June 20, 2026 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant