Skip to content

The IO loop's select walks every waiter per pass: n arrivals cost O(n^2) #1250

Open

Description

@phenomenon0

Class PERF: right answers, pathological cost.\n\nWhat you did A server holding N concurrent connections; every arrival re-scans all waiters in the select pass.\n\nWhy it matters At a few hundred connections the wake cost is quadratic in the number of waiters \u2014 the difference between a toy and a server. This is on the hot path of any Bend HTTP/TCP service.\n\nFix pointer Keep a waiter set per descriptor (epoll-style) instead of walking every waiter per pass \u2014 we have this working on our branch for descriptors and timers and verified both in all applicable lanes.

Activity

  1. oxura commented on Oct 9, 2026

    @oxura
    Contributor

    The descriptor/timer implementation and Linux native/Bun runtime proof are available in draft #1442 (#1442), head 89cb66d. This is not merge-ready or counted as a completed issue.

    The protected compiler size prerequisite needs your decision: unchanged main has 63,905 ttok, this implementation 67,176, against the permanent 64,000 cap. The repository gate therefore reports 53/54. AGENTS.md reserves caps to Taelin; I have not changed the cap/gate, split the compiler to evade it or removed unrelated functionality.

    The draft records all 48 interleaved real socket-arrival samples, exact completion counts, native/Bun medians, the real shared-FD repark regression and ASan/UBSan result, plus the untouched native late-channel failure that also occurs on the baseline. macOS and mini-cluster gates are not claimed.

    Your fix pointer says the descriptor/timer implementation already works on a branch. Please point me to it/intended integration boundary if this overlaps your work; otherwise the protected budget needs a maintainer-applied decision before this draft can be made ready.

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

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions