Commit 8ac65ab
committed
fix(envd): stop memory exhaustion when client disconnects from streaming process
When a Start/Connect client disconnects while a process is producing
output, the fan-out loop drained the Source channel with no
subscribers, allocating 32 KiB per read cycle. With a fast producer,
envd RSS grew to hundreds of MiB in seconds, OOM-killing sandbox
processes.
Readers now reuse a single read buffer and only allocate + send when
HasSubscribers is true. The fan-out always consumes from Source and
drops values with no subscribers. The child process is never blocked
so servers and background processes stay responsive during disconnects.1 parent a2bb1cb commit 8ac65ab
2 files changed
Lines changed: 31 additions & 10 deletions
Lines changed: 17 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
242 | 243 | | |
243 | 244 | | |
244 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
245 | 250 | | |
246 | | - | |
| 251 | + | |
247 | 252 | | |
248 | | - | |
| 253 | + | |
| 254 | + | |
249 | 255 | | |
250 | | - | |
251 | 256 | | |
252 | 257 | | |
253 | 258 | | |
254 | | - | |
| 259 | + | |
255 | 260 | | |
256 | 261 | | |
257 | 262 | | |
258 | 263 | | |
259 | | - | |
| 264 | + | |
260 | 265 | | |
261 | 266 | | |
262 | 267 | | |
| |||
284 | 289 | | |
285 | 290 | | |
286 | 291 | | |
| 292 | + | |
| 293 | + | |
287 | 294 | | |
288 | | - | |
| 295 | + | |
289 | 296 | | |
290 | | - | |
| 297 | + | |
| 298 | + | |
291 | 299 | | |
292 | | - | |
293 | 300 | | |
294 | 301 | | |
295 | 302 | | |
296 | | - | |
| 303 | + | |
297 | 304 | | |
298 | 305 | | |
299 | 306 | | |
300 | 307 | | |
301 | | - | |
| 308 | + | |
302 | 309 | | |
303 | 310 | | |
304 | 311 | | |
| |||
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
87 | 101 | | |
88 | 102 | | |
89 | 103 | | |
| |||
0 commit comments