mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-21 02:33:23 +00:00
1e5a538221
Previously, we limited the number of streams that could be opened by the peer but not `accept`ed by the application. However, to guarantee bounded resource use, applications will typically want to limit the number of streams they process concurrently. While this could be *approximately* implemented at the application layer by controlling calls to accept, that approach has a significant drawback: If streams are slow to process, the worst-case per-stream latency observed by a peer who opens the maximum number of streams can be arbitrarily bad, because streams may be opened above the limit the local application is willing to process. Reducing the number of unaccepted streams tolerated can reduce the proportion of streams affected, but reducing it too low will increase the number of round trips required to open any given number of streams, increasing average latency significantly. As a side benefit, this reduces the effort needed for applications to limit concurrency to a fixed quantity, which is expected to be the overwhelmingly common case. Should a use case for dynamic concurrency limits arise, we can expose a setter.