Skip to content

Benchmark: PolicyGateway latency for robotics control loops #3

@pshkv

Description

@pshkv

Problem

For robotics control loops running at 100Hz (10ms cycle time), the SINT gateway must add negligible latency — otherwise it becomes a bottleneck.

Requirement: T0_observe hot path (read-only sensor data, no DB calls) should be <1ms p99 on commodity hardware.

Current state

No benchmark exists. We don't know the actual latency of:

  • PolicyGateway.intercept() for a T0_observe allow
  • Token validation (Ed25519 verify)
  • Rate limit check (in-memory)
  • Evidence ledger append (hash + in-memory write)

Proposed benchmark

Using vitest's bench():

bench("T0_observe allow — sensor read hot path", async () => {
  await gateway.intercept({
    requestId: nextUUID(),
    agentId: agent.publicKey,
    tokenId: token.tokenId,
    resource: "ros2:///sensor/lidar",
    action: "subscribe",
    params: {},
  });
});

Run with: pnpm run bench

Acceptance criteria

  • p50 < 0.5ms for T0_observe allow
  • p99 < 2ms for T0_observe allow
  • p99 < 10ms for T2_act escalate (includes escalation overhead)

Notes

For production deployments, the gateway runs in-process (same Node.js process as the bridge adapter). HTTP round-trip is not in the critical path for local deployments.

The Ed25519 signature verification (via @noble/ed25519) is the most likely bottleneck — it's ~0.3ms per verify on a modern CPU.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions