Skip to content

perf: WebSocket frame receive/send goes through double future bridge (into_future -> future_into_py) #257

Closed

Description

@ZhuchkaTriplesix

Where: src/websocket.rs:98-100, 113-116, 136-139, 163-166, 187-190.

Currently, for every frame received or sent:

  1. The Granian transport coroutine is converted to a Tokio Future via pyo3_async_runtimes::tokio::into_future(coro).
  2. The Tokio Future is converted back into a Python asyncio Future via future_into_py(...).

This causes every frame to hop from the Python asyncio loop to the Tokio thread pool and back to the Python asyncio loop, adding task scheduling and context switching overhead on every WebSocket frame.

Fix direction:
Streamline the WebSocket async path so it awaits Granian transport coroutines without round-tripping through the Tokio executor.

Activity

  1. added
    enhancement
    on Oct 18, 2026
  2. added a commit that references this issue on Oct 18, 2026
  3. ZhuchkaTriplesix commented on Oct 18, 2026

    @ZhuchkaTriplesix
    MemberAuthor

    Resolved by #264

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions