uws: fix O(n^2) BackPressure buffer compaction and reallocation on large writes - #34023
Open
robobun wants to merge 4 commits into
Open
uws: fix O(n^2) BackPressure buffer compaction and reallocation on large writes#34023robobun wants to merge 4 commits into
robobun wants to merge 4 commits into
Claude / Claude Code Review
completed
Jul 14, 2026 in 14m 13s
Code review found 1 potential issue
Found 1 candidates, confirmed 1. See review comments for details.
Details
| Severity | Count |
|---|---|
| 🔴 Important | 0 |
| 🟡 Nit | 1 |
| 🟣 Pre-existing | 0 |
| Severity | File:Line | Issue |
|---|---|---|
| 🟡 Nit | packages/bun-uws/src/HttpResponse.h:599-605 |
Repeated >1MB writes still O(n²) on libc++ via exact-fit reserve |
Annotations
Check warning on line 605 in packages/bun-uws/src/HttpResponse.h
claude / Claude Code Review
Repeated >1MB writes still O(n²) on libc++ via exact-fit reserve
The remaining `length > 1024 * 1024` gate still fires on *every* user-level write >1MB, so on libc++ (macOS) N successive 2MB writes to a stalled socket each `reserve()` exact-fit and realloc+copy the accumulated buffer → O(N²), whereas pre-PR `append()` grew geometrically. Gating on `length > INT_MAX` (the only case a single write is actually split into multiple appends), or reserving `max(2*capacity, needed)`, keeps the 4 GiB fix without this. Narrow: libc++ only, requires repeated >1MB writes
Loading