Skip to content

perf(asgi): remove per-request fresh event-loop creation in bridge worker path #73

Closed

Description

@ZhuchkaTriplesix

Context

ASGI bridge currently executes handle_rsgi via run_in_executor, and worker function uses asyncio.run(...) per request (fresh event loop per call). This adds fixed per-request overhead and executor churn under load.

Current code

  • oxyroute/asgi.py: _run_handle_rsgi_blocking(...) + asyncio.run(_inner())

Goal

Reduce per-request overhead by avoiding fresh loop creation on every request in ASGI mode.

Candidate approaches

  1. Long-lived worker thread with persistent loop.
  2. Alternative bridge architecture that removes need for per-request asyncio.run.

Acceptance criteria

  • ASGI bridge no longer creates a new loop per request.
  • Stress test (tests/test_asgi_stress.py) remains green.
  • Include before/after benchmark notes in PR description.

Notes

Keep behavior compatibility first; this is an internal perf refactor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions