Commit 7e41820
committed
feat(sandbox): add warm pool claim and scheduler
introduce a warm pool system to reduce sandbox cold-start latency by
pre-warming instances and claiming them on create when available.
add global and per-profile warm pool configuration, startup/shutdown
lifecycle hooks, an in-process bounded warmup queue with workers, and a
periodic scheduler to replenish and rotate warm instances.
update sandbox creation flow to check idempotency first, attempt warm
claim before normal create, and enqueue warmup work through the queue
(with background-task fallback when queue is unavailable).
extend sandbox model/manager with warm pool state and atomic claim logic,
exclude warm pool instances from user listing and GC expiry/idle scans,
and add unit tests for claim behavior, manager methods, and queue
lifecycle/statistics.1 parent c5e22e4 commit 7e41820
File tree
20 files changed
+2064
-35
lines changed- deploy/docker
- pkgs/bay
- app
- api/v1
- managers/sandbox
- models
- services
- gc/tasks
- warm_pool
- tests
- scripts
- docker-host
- docker-network
- unit
- api
- warm_pool
20 files changed
+2064
-35
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
53 | 65 | | |
54 | 66 | | |
55 | 67 | | |
| |||
65 | 77 | | |
66 | 78 | | |
67 | 79 | | |
| 80 | + | |
68 | 81 | | |
69 | 82 | | |
70 | 83 | | |
| |||
81 | 94 | | |
82 | 95 | | |
83 | 96 | | |
| 97 | + | |
84 | 98 | | |
85 | 99 | | |
86 | 100 | | |
| |||
114 | 128 | | |
115 | 129 | | |
116 | 130 | | |
| 131 | + | |
117 | 132 | | |
118 | 133 | | |
119 | 134 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
| 335 | + | |
335 | 336 | | |
336 | 337 | | |
337 | 338 | | |
338 | 339 | | |
339 | 340 | | |
340 | | - | |
| 341 | + | |
341 | 342 | | |
342 | 343 | | |
343 | 344 | | |
| |||
348 | 349 | | |
349 | 350 | | |
350 | 351 | | |
| 352 | + | |
351 | 353 | | |
352 | 354 | | |
353 | 355 | | |
354 | 356 | | |
355 | 357 | | |
356 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
357 | 396 | | |
358 | 397 | | |
359 | 398 | | |
| |||
362 | 401 | | |
363 | 402 | | |
364 | 403 | | |
365 | | - | |
| 404 | + | |
366 | 405 | | |
367 | 406 | | |
368 | 407 | | |
| |||
374 | 413 | | |
375 | 414 | | |
376 | 415 | | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
383 | | - | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
384 | 429 | | |
385 | 430 | | |
386 | 431 | | |
| |||
537 | 582 | | |
538 | 583 | | |
539 | 584 | | |
| 585 | + | |
540 | 586 | | |
541 | 587 | | |
542 | 588 | | |
543 | | - | |
| 589 | + | |
544 | 590 | | |
545 | 591 | | |
546 | 592 | | |
547 | 593 | | |
| 594 | + | |
548 | 595 | | |
549 | | - | |
550 | | - | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
183 | 192 | | |
184 | 193 | | |
185 | 194 | | |
| |||
346 | 355 | | |
347 | 356 | | |
348 | 357 | | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
349 | 372 | | |
350 | 373 | | |
351 | 374 | | |
| |||
389 | 412 | | |
390 | 413 | | |
391 | 414 | | |
| 415 | + | |
392 | 416 | | |
393 | 417 | | |
394 | 418 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
49 | 53 | | |
50 | 54 | | |
51 | 55 | | |
| |||
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
58 | 65 | | |
59 | 66 | | |
60 | 67 | | |
| |||
0 commit comments