Skip to content

perf(orchestrator): make RoutingDecisionEngine::decide_route async to eliminate block_in_place #784

@AlexMikhalev

Description

@AlexMikhalev

Context

RoutingDecisionEngine::decide_route() uses tokio::task::block_in_place + block_on() to call async TelemetryStore::model_performance() per candidate model (routing.rs:362-370).

This blocks a tokio worker thread (25% capacity loss with 4 threads), panics on single-thread runtime, and acquires the read lock N times when once would suffice.

Proposed fix

Make decide_route() async (caller spawn_agent() is already async), or pre-fetch ModelPerformanceSnapshot data and pass it in.

Acceptance criteria

  • No block_in_place or block_on in decide_route
  • Tests work with default #[tokio::test]
  • All existing tests pass

Refs #536 (Gitea), Refs #523

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions