Commit 2cc6ba0
authored
fix(perf): binary WebSocket transport and backpressure fix (#479)
* fix(perf): binary WebSocket transport and backpressure fix (#478)
Fix backpressure triggering on every SSH chunk regardless of buffer
state. The previous implementation used an incorrect heuristic
(eventNames().length * highWaterMark) that always exceeded the
threshold. Replace with actual bufferedAmount reads from the underlying
WebSocket, with high/low water mark hysteresis and drain-based resume.
Emit raw Buffer from SSH2 shell stream instead of converting to UTF-8
string. Socket.IO 4.x sends Buffers as binary WebSocket frames,
eliminating per-chunk toString('utf8') overhead and JSON string
escaping. The exec channel continues to emit strings as it accumulates
output before sending.
Bump webssh2_client to 3.2.2 which handles the binary data event.
Server and client must be updated together — the new server is not
backwards compatible with older clients.
Results: CPU on cat /dev/urandom | hexdump -c dropped from 100% to ~25%.
Normal interactive usage no longer triggers spurious pause/resume.
Closes #478
* refactor(test): extract shared helpers to reduce duplication
Extract setupShellFlow() and createMutableBufferContext() helpers
from repeated test setup blocks in stream-backpressure tests.1 parent ccaa513 commit 2cc6ba0
7 files changed
Lines changed: 523 additions & 42 deletions
File tree
- DOCS
- api
- architecture
- app
- socket/adapters
- types/contracts/v1
- tests/unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
| 117 | + | |
117 | 118 | | |
118 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
119 | 124 | | |
120 | 125 | | |
121 | 126 | | |
| |||
245 | 250 | | |
246 | 251 | | |
247 | 252 | | |
248 | | - | |
| 253 | + | |
249 | 254 | | |
250 | 255 | | |
251 | 256 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
18 | 87 | | |
19 | 88 | | |
20 | 89 | | |
| |||
180 | 249 | | |
181 | 250 | | |
182 | 251 | | |
183 | | - | |
184 | 252 | | |
185 | 253 | | |
186 | 254 | | |
187 | 255 | | |
188 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
189 | 307 | | |
190 | 308 | | |
191 | 309 | | |
| |||
215 | 333 | | |
216 | 334 | | |
217 | 335 | | |
218 | | - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
219 | 339 | | |
220 | 340 | | |
221 | 341 | | |
| |||
226 | 346 | | |
227 | 347 | | |
228 | 348 | | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
| 349 | + | |
234 | 350 | | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
240 | 354 | | |
241 | | - | |
242 | | - | |
243 | 355 | | |
244 | 356 | | |
245 | 357 | | |
| 358 | + | |
246 | 359 | | |
247 | 360 | | |
248 | 361 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
| 241 | + | |
242 | 242 | | |
243 | 243 | | |
244 | 244 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
0 commit comments