raptor 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5259e8e7d7ae239536524ece94ff765535658f324ad1902d6ec3d56af5796af0
4
- data.tar.gz: '03508278f0a423ff56a50ac4135d687cc302137607fcad3a8064854bc06d4a49'
3
+ metadata.gz: c6a6d47ad196a81ed02688a02354215ff73727c992215403d46df7524b16437f
4
+ data.tar.gz: 994e7060d8278195ff9af6bcd2f86f3bb0af3335626c40475311ab275351d3cb
5
5
  SHA512:
6
- metadata.gz: 78a11a24ce8eda1a18de094f06fa5d31ec58e80e18f1cbc9349bb144ced58d0878f31aee2ba383e0f2b132378d0da20f621cec6735fde8cc7bdacd268ea1825c
7
- data.tar.gz: 67c167083e7ef9cb940822d5ef47d802cc56c3fbc82447367d41e5a4c98de3bd1f431164f46b3f7cd8c9c1bd9e21b7aa942c7c9dd75c44260c6981850d805eb9
6
+ metadata.gz: 7febcca4e7599b65ba6c60b193f957a3fa9423c1269517037bbf32e6b01e9b06284dc6072e39d19b2ccf6f00546fea94b37e096ba24ba003d008a2ba0e2acce4
7
+ data.tar.gz: 7761be422a232b755f930ce527d54975c9dc2c4d5d99c6f792226e1c745612d2360b26d54f79f6276f0c6e0d6647a3f3f87b4fe5ce6cf4215892eb5402b61c0e
@@ -49,6 +49,7 @@ steps:
49
49
  - bundle exec rake ci
50
50
 
51
51
  - label: ":ruby: Ruby head"
52
+ priority: -1
52
53
  soft_fail: true
53
54
  image: "rubylang/ruby:master-dev"
54
55
  commands:
@@ -58,6 +59,7 @@ steps:
58
59
  - bundle exec rake ci
59
60
 
60
61
  - label: ":ruby: Ruby head +YJIT"
62
+ priority: -1
61
63
  soft_fail: true
62
64
  image: "rubylang/ruby:master-dev"
63
65
  env:
@@ -69,6 +71,7 @@ steps:
69
71
  - bundle exec rake ci
70
72
 
71
73
  - label: ":ruby: Ruby head +GC.stress"
74
+ priority: -1
72
75
  soft_fail: true
73
76
  image: "rubylang/ruby:master-dev"
74
77
  env:
@@ -80,6 +83,7 @@ steps:
80
83
  - bundle exec rake ci
81
84
 
82
85
  - label: ":ruby: Ruby head +YJIT +GC.stress"
86
+ priority: -1
83
87
  soft_fail: true
84
88
  image: "rubylang/ruby:master-dev"
85
89
  env:
@@ -161,6 +165,7 @@ steps:
161
165
  - bundle exec rake ci
162
166
 
163
167
  - label: ":ruby: Ruby head"
168
+ priority: -1
164
169
  soft_fail: true
165
170
  agents:
166
171
  queue: macos
@@ -174,6 +179,7 @@ steps:
174
179
  - bundle exec rake ci
175
180
 
176
181
  - label: ":ruby: Ruby head +YJIT"
182
+ priority: -1
177
183
  soft_fail: true
178
184
  agents:
179
185
  queue: macos
@@ -189,6 +195,7 @@ steps:
189
195
  - bundle exec rake ci
190
196
 
191
197
  - label: ":ruby: Ruby head +GC.stress"
198
+ priority: -1
192
199
  soft_fail: true
193
200
  agents:
194
201
  queue: macos
@@ -204,6 +211,7 @@ steps:
204
211
  - bundle exec rake ci
205
212
 
206
213
  - label: ":ruby: Ruby head +YJIT +GC.stress"
214
+ priority: -1
207
215
  soft_fail: true
208
216
  agents:
209
217
  queue: macos
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.29.0] - 2026-11-25
4
+
5
+ - Share `worker_drain_timeout` across request draining phases
6
+ - Close inherited control sockets in workers
7
+
3
8
  ## [0.28.0] - 2026-11-25
4
9
 
5
10
  - Publish stats files atomically
data/README.md CHANGED
@@ -37,7 +37,7 @@ run proc { |_env| [200, { "content-type" => "text/plain" }, ["Hello, World!"]] }
37
37
  ```
38
38
  > bundle exec raptor -w 10 -t 3 hello_world.ru
39
39
  [Raptor 39704|Main|Main] Cluster initializing:
40
- [Raptor 39704|Main|Main] ├─ Version: 0.28.0
40
+ [Raptor 39704|Main|Main] ├─ Version: 0.29.0
41
41
  [Raptor 39704|Main|Main] ├─ Ruby Version: ruby 4.0.9 (2026-10-23 revision 3e93b23afc) +YJIT +PRISM [arm64-darwin25]
42
42
  [Raptor 39704|Main|Main] ├─ Environment: development
43
43
  [Raptor 39704|Main|Main] ├─ Master PID: 39704
@@ -281,7 +281,7 @@ statistics. The exporter handles worker forks and restart cleanup automatically.
281
281
 
282
282
  ## (Micro) Benchmarks
283
283
 
284
- Raptor 0.28.0 vs Puma 8.0.2 vs Falcon 0.57.0. Each case has 3 fresh-process samples, interleaved in seeded shuffled
284
+ Raptor 0.29.0 vs Puma 8.0.2 vs Falcon 0.57.0. Each case has 3 fresh-process samples, interleaved in seeded shuffled
285
285
  rounds. Each sample warms up for 3s and measures for 15s. Metrics are independent medians. ± is (max − min) / 2 /
286
286
  median, not a confidence interval. Failure counts below each table sum all samples, so a failed run cannot disappear in
287
287
  a median. Throughput counts successful ordinary requests only.
@@ -309,90 +309,90 @@ accounting for shared pages instead of counting them fully in every worker.
309
309
 
310
310
  | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
311
311
  | ------ | -------------- | --------------- | ------------ | --------------- | ------ | ------------- | ---------- | ------- |
312
- | Raptor | Fixed (3) | - | 3.38k ±0.6% | - | 46.10 | - | 2.443 | 335.6 |
313
- | Raptor | Scaling (3–16) | - | 8.23k ±0.4% | - | 22.06 | - | 0.467 | 322.5 |
314
- | Puma | Fixed (3) | Fixed (3) | 1.40k ±1.7% | 58.6% lower | 134.87 | 192.5% higher | 0.785 | 272.9 |
315
- | Puma | Scaling (3–16) | Scaling (3–16) | 8.15k ±1.8% | 1.0% lower | 22.29 | 1.0% higher | 0.466 | 319.7 |
316
- | Falcon | Fibers | Fixed (3) | 10.91k ±0.4% | 222.8% higher | 15.67 | 66.0% lower | 0.441 | 427.6 |
317
- | Falcon | Fibers | Scaling (3–16) | 10.91k ±0.4% | 32.5% higher | 15.67 | 29.0% lower | 0.441 | 427.6 |
312
+ | Raptor | Fixed (3) | - | 3.35k ±1.4% | - | 47.84 | - | 2.452 | 334.1 |
313
+ | Raptor | Scaling (3–16) | - | 8.23k ±0.7% | - | 22.03 | - | 0.467 | 320.5 |
314
+ | Puma | Fixed (3) | Fixed (3) | 1.41k ±1.4% | 57.9% lower | 133.47 | 179.0% higher | 0.765 | 272.0 |
315
+ | Puma | Scaling (3–16) | Scaling (3–16) | 8.15k ±0.6% | 0.9% lower | 22.20 | 0.7% higher | 0.462 | 317.6 |
316
+ | Falcon | Fibers | Fixed (3) | 10.90k ±0.8% | 225.1% higher | 15.68 | 67.2% lower | 0.445 | 467.5 |
317
+ | Falcon | Fibers | Scaling (3–16) | 10.90k ±0.8% | 32.5% higher | 15.68 | 28.8% lower | 0.445 | 467.5 |
318
318
 
319
319
  ### IO over HTTP/1.1 keep-alive
320
320
 
321
321
  | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
322
322
  | ------ | -------------- | --------------- | ----------- | --------------- | ------ | ------------- | ---------- | ------- |
323
- | Raptor | Fixed (3) | - | 3.02k ±7.0% | - | 48.69 | - | 2.341 | 339.0 |
324
- | Raptor | Scaling (3–16) | - | 7.38k ±0.5% | - | 24.60 | - | 0.457 | 343.8 |
325
- | Raptor | Fixed (16) | - | 7.54k ±0.5% | - | 24.17 | - | 0.454 | 336.5 |
326
- | Puma | Fixed (3) | Fixed (3) | 1.37k ±1.5% | 54.7% lower | 114.49 | 135.1% higher | 0.726 | 281.4 |
327
- | Puma | Scaling (3–16) | Scaling (3–16) | 7.45k ±0.3% | 0.9% higher | 24.38 | 0.9% lower | 0.432 | 312.0 |
328
- | Puma | Fixed (16) | Fixed (16) | 7.56k ±1.2% | 0.3% higher | 24.12 | 0.2% lower | 0.431 | 317.2 |
329
- | Falcon | Fibers | Fixed (3) | 7.42k ±0.9% | 145.8% higher | 24.51 | 49.7% lower | 0.393 | 335.6 |
330
- | Falcon | Fibers | Scaling (3–16) | 7.42k ±0.9% | 0.6% higher | 24.51 | 0.4% lower | 0.393 | 335.6 |
331
- | Falcon | Fibers | Fixed (16) | 7.42k ±0.9% | 1.5% lower | 24.51 | 1.4% higher | 0.393 | 335.6 |
323
+ | Raptor | Fixed (3) | - | 3.20k ±9.2% | - | 50.70 | - | 2.390 | 345.1 |
324
+ | Raptor | Scaling (3–16) | - | 7.38k ±0.6% | - | 24.60 | - | 0.463 | 342.4 |
325
+ | Raptor | Fixed (16) | - | 7.52k ±0.0% | - | 24.18 | - | 0.457 | 338.3 |
326
+ | Puma | Fixed (3) | Fixed (3) | 1.39k ±1.4% | 56.7% lower | 111.46 | 119.8% higher | 0.734 | 282.1 |
327
+ | Puma | Scaling (3–16) | Scaling (3–16) | 7.49k ±0.4% | 1.6% higher | 24.20 | 1.6% lower | 0.439 | 312.4 |
328
+ | Puma | Fixed (16) | Fixed (16) | 7.57k ±0.9% | 0.6% higher | 24.10 | 0.3% lower | 0.429 | 318.1 |
329
+ | Falcon | Fibers | Fixed (3) | 7.44k ±1.4% | 132.3% higher | 24.53 | 51.6% lower | 0.384 | 334.2 |
330
+ | Falcon | Fibers | Scaling (3–16) | 7.44k ±1.4% | 0.8% higher | 24.53 | 0.3% lower | 0.384 | 334.2 |
331
+ | Falcon | Fibers | Fixed (16) | 7.44k ±1.4% | 1.1% lower | 24.53 | 1.5% higher | 0.384 | 334.2 |
332
332
 
333
333
  ### IO over HTTP/2
334
334
 
335
- | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
336
- | ------ | -------------- | --------------- | ------------ | --------------- | ------ | ------------- | ---------- | ------- |
337
- | Raptor | Fixed (3) | - | 1.54k ±1.0% | - | 116.93 | - | 0.830 | 410.5 |
338
- | Raptor | Scaling (3–16) | - | 6.58k ±21.1% | - | 33.33 | - | 0.549 | 905.0 |
339
- | Falcon | Fibers | Fixed (3) | 7.01k ±5.8% | 353.6% higher | 27.20 | 76.7% lower | 0.425 | 518.8 |
340
- | Falcon | Fibers | Scaling (3–16) | 7.01k ±5.8% | 6.5% higher | 27.20 | 18.4% lower | 0.425 | 518.8 |
335
+ | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
336
+ | ------ | -------------- | --------------- | ----------- | --------------- | ------ | ------------- | ---------- | ------- |
337
+ | Raptor | Fixed (3) | - | 1.55k ±0.8% | - | 120.06 | - | 0.842 | 418.9 |
338
+ | Raptor | Scaling (3–16) | - | 8.46k ±3.7% | - | 21.77 | - | 0.553 | 928.8 |
339
+ | Falcon | Fibers | Fixed (3) | 7.18k ±4.2% | 363.9% higher | 26.01 | 78.3% lower | 0.435 | 529.6 |
340
+ | Falcon | Fibers | Scaling (3–16) | 7.18k ±4.2% | 15.1% lower | 26.01 | 19.5% higher | 0.435 | 529.6 |
341
341
 
342
342
  ### CPU over HTTP/1.1
343
343
 
344
344
  | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
345
345
  | ------ | -------------- | --------------- | ----------- | --------------- | ------ | ------------- | ---------- | ------- |
346
- | Raptor | Fixed (3) | - | 3.35k ±1.6% | - | 69.30 | - | 2.573 | 502.2 |
347
- | Raptor | Scaling (3–16) | - | 3.42k ±0.7% | - | 63.97 | - | 2.450 | 492.6 |
348
- | Puma | Fixed (3) | Fixed (3) | 3.13k ±5.8% | 6.4% lower | 59.73 | 13.8% lower | 2.571 | 445.3 |
349
- | Puma | Scaling (3–16) | Scaling (3–16) | 3.42k ±4.9% | 0.0% higher | 49.04 | 23.3% lower | 2.279 | 454.0 |
350
- | Falcon | Fibers | Fixed (3) | 3.39k ±0.8% | 1.2% higher | 49.24 | 28.9% lower | 2.531 | 431.4 |
351
- | Falcon | Fibers | Scaling (3–16) | 3.39k ±0.8% | 0.8% lower | 49.24 | 23.0% lower | 2.531 | 431.4 |
346
+ | Raptor | Fixed (3) | - | 3.33k ±0.3% | - | 68.91 | - | 2.570 | 507.8 |
347
+ | Raptor | Scaling (3–16) | - | 3.39k ±3.0% | - | 62.76 | - | 2.430 | 489.6 |
348
+ | Puma | Fixed (3) | Fixed (3) | 3.27k ±2.3% | 2.0% lower | 56.55 | 17.9% lower | 2.496 | 443.3 |
349
+ | Puma | Scaling (3–16) | Scaling (3–16) | 3.27k ±4.6% | 3.7% lower | 48.35 | 23.0% lower | 2.200 | 439.0 |
350
+ | Falcon | Fibers | Fixed (3) | 3.47k ±0.7% | 4.1% higher | 47.50 | 31.1% lower | 2.473 | 421.1 |
351
+ | Falcon | Fibers | Scaling (3–16) | 3.47k ±0.7% | 2.2% higher | 47.50 | 24.3% lower | 2.473 | 421.1 |
352
352
 
353
353
  ### CPU over HTTP/1.1 keep-alive
354
354
 
355
355
  | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
356
356
  | ------ | -------------- | --------------- | ----------- | --------------- | ------ | ------------- | ---------- | ------- |
357
- | Raptor | Fixed (3) | - | 3.10k ±1.6% | - | 50.26 | - | 2.557 | 478.1 |
358
- | Raptor | Scaling (3–16) | - | 3.12k ±2.4% | - | 54.20 | - | 2.594 | 519.0 |
359
- | Puma | Fixed (3) | Fixed (3) | 3.46k ±1.1% | 11.7% higher | 55.42 | 10.3% higher | 2.390 | 379.6 |
360
- | Puma | Scaling (3–16) | Scaling (3–16) | 3.31k ±7.1% | 6.1% higher | 62.85 | 16.0% higher | 2.271 | 490.2 |
361
- | Falcon | Fibers | Fixed (3) | 3.14k ±0.5% | 1.3% higher | 70.46 | 40.2% higher | 2.791 | 527.2 |
362
- | Falcon | Fibers | Scaling (3–16) | 3.14k ±0.5% | 0.8% higher | 70.46 | 30.0% higher | 2.791 | 527.2 |
357
+ | Raptor | Fixed (3) | - | 3.12k ±0.4% | - | 48.97 | - | 2.570 | 476.6 |
358
+ | Raptor | Scaling (3–16) | - | 3.02k ±2.0% | - | 50.35 | - | 2.593 | 504.5 |
359
+ | Puma | Fixed (3) | Fixed (3) | 3.51k ±0.9% | 12.5% higher | 51.41 | 5.0% higher | 2.346 | 381.8 |
360
+ | Puma | Scaling (3–16) | Scaling (3–16) | 2.94k ±4.4% | 2.8% lower | 64.76 | 28.6% higher | 2.243 | 469.3 |
361
+ | Falcon | Fibers | Fixed (3) | 3.13k ±0.6% | 0.1% higher | 68.29 | 39.4% higher | 2.806 | 536.3 |
362
+ | Falcon | Fibers | Scaling (3–16) | 3.13k ±0.6% | 3.4% higher | 68.29 | 35.6% higher | 2.806 | 536.3 |
363
363
 
364
364
  ### CPU over HTTP/2
365
365
 
366
366
  | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
367
367
  | ------ | -------------- | --------------- | ------------ | --------------- | ------ | ------------- | ---------- | ------- |
368
- | Raptor | Fixed (3) | - | 3.43k ±2.6% | - | 68.02 | - | 2.441 | 553.6 |
369
- | Raptor | Scaling (3–16) | - | 3.39k ±2.5% | - | 64.54 | - | 2.399 | 588.0 |
370
- | Falcon | Fibers | Fixed (3) | 2.26k ±14.9% | 34.2% lower | 98.81 | 45.3% higher | 2.543 | 574.5 |
371
- | Falcon | Fibers | Scaling (3–16) | 2.26k ±14.9% | 33.5% lower | 98.81 | 53.1% higher | 2.543 | 574.5 |
368
+ | Raptor | Fixed (3) | - | 3.45k ±3.9% | - | 67.62 | - | 2.425 | 581.6 |
369
+ | Raptor | Scaling (3–16) | - | 3.35k ±1.6% | - | 64.00 | - | 2.409 | 584.6 |
370
+ | Falcon | Fibers | Fixed (3) | 2.71k ±28.6% | 21.6% lower | 151.92 | 124.7% higher | 2.494 | 575.5 |
371
+ | Falcon | Fibers | Scaling (3–16) | 2.71k ±28.6% | 19.3% lower | 151.92 | 137.4% higher | 2.494 | 575.5 |
372
372
 
373
373
  ### 64 KiB body over HTTP/1.1 keep-alive
374
374
 
375
- | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
376
- | ------ | -------------- | --------------- | ------------- | --------------- | ------ | ------------- | ---------- | ------- |
377
- | Raptor | Scaling (3–16) | - | 92.13k ±1.7% | - | 3.82 | - | 0.052 | 499.3 |
378
- | Puma | Scaling (3–16) | Scaling (3–16) | 88.15k ±1.4% | 4.3% lower | 3.76 | 1.5% lower | 0.054 | 1251.5 |
379
- | Falcon | Fibers | Scaling (3–16) | 100.77k ±1.8% | 9.4% higher | 3.92 | 2.6% higher | 0.052 | 348.8 |
375
+ | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
376
+ | ------ | -------------- | --------------- | ------------ | --------------- | ------ | ------------- | ---------- | ------- |
377
+ | Raptor | Scaling (3–16) | - | 93.53k ±1.0% | - | 3.71 | - | 0.052 | 501.2 |
378
+ | Puma | Scaling (3–16) | Scaling (3–16) | 84.26k ±0.5% | 9.9% lower | 3.94 | 6.1% higher | 0.056 | 1210.8 |
379
+ | Falcon | Fibers | Scaling (3–16) | 97.44k ±1.1% | 4.2% higher | 3.96 | 6.7% higher | 0.053 | 341.9 |
380
380
 
381
381
  ### IO + SSE (native) over HTTP/1.1 keep-alive
382
382
 
383
383
  | Server | Mode | Raptor baseline | req/s | vs Raptor req/s | p95 ms | vs Raptor p95 | CPU ms/req | PSS MiB |
384
384
  | ------------- | -------------- | --------------- | ------------ | --------------- | ------ | ------------- | ---------- | ------- |
385
- | Raptor | Fixed (3) | - | 3.18k ±3.8% | - | 45.76 | - | 2.371 | 349.0 |
386
- | Raptor | Scaling (3–16) | - | 7.45k ±1.1% | - | 24.41 | - | 0.465 | 342.3 |
387
- | Puma | Fixed (3) | Fixed (3) | 0.34k ±10.2% | 89.4% lower | 313.88 | 585.9% higher | 1.623 | 249.0 |
388
- | Puma | Scaling (3–16) | Scaling (3–16) | 7.40k ±0.9% | 0.7% lower | 24.56 | 0.6% higher | 0.437 | 310.7 |
389
- | Falcon | Fibers | Fixed (3) | 7.47k ±4.9% | 135.0% higher | 24.46 | 46.5% lower | 0.383 | 342.3 |
390
- | Falcon | Fibers | Scaling (3–16) | 7.47k ±4.9% | 0.3% higher | 24.46 | 0.2% higher | 0.383 | 342.3 |
391
- | Raptor (enum) | Fixed (3) | - | 0.88k ±5.1% | - | 61.42 | - | 8.443 | 319.4 |
385
+ | Raptor | Fixed (3) | - | 3.16k ±12.5% | - | 50.55 | - | 2.374 | 347.8 |
386
+ | Raptor | Scaling (3–16) | - | 7.42k ±1.5% | - | 24.45 | - | 0.470 | 341.1 |
387
+ | Puma | Fixed (3) | Fixed (3) | 0.34k ±5.3% | 89.3% lower | 328.18 | 549.2% higher | 1.712 | 243.8 |
388
+ | Puma | Scaling (3–16) | Scaling (3–16) | 7.44k ±3.6% | 0.2% higher | 24.32 | 0.5% lower | 0.435 | 311.0 |
389
+ | Falcon | Fibers | Fixed (3) | 7.58k ±4.2% | 140.0% higher | 24.24 | 52.0% lower | 0.385 | 335.5 |
390
+ | Falcon | Fibers | Scaling (3–16) | 7.58k ±4.2% | 2.2% higher | 24.24 | 0.9% lower | 0.385 | 335.5 |
391
+ | Raptor (enum) | Fixed (3) | - | 0.88k ±4.2% | - | 63.87 | - | 8.136 | 330.3 |
392
392
 
393
- Puma, Fixed (3) had 59 timeouts, 2 stalled streams across all samples.
393
+ Puma, Fixed (3) had 57 timeouts, 1 stalled stream across all samples.
394
394
 
395
- Raptor (enum), Fixed (3) had 39 timeouts, 1 stalled stream across all samples.
395
+ Raptor (enum), Fixed (3) had 8 timeouts, 1 stalled stream across all samples.
396
396
 
397
397
  > ruby 4.1.0dev (2026-11-10T00:02:04Z HEAD 7a07e456e4) +YJIT +PRISM [aarch64-linux]
398
398
  > 10 workers, 120 HTTP/1.1 client connections, 40 HTTP/2 connections × 3 streams.
@@ -151,7 +151,7 @@ module Raptor
151
151
  # @option options [Hash] :http2 HTTP/2-specific settings
152
152
  # @option options [Integer] :worker_boot_timeout seconds to wait for a worker to finish booting before killing it
153
153
  # @option options [Integer] :worker_timeout seconds to wait for a booted worker to check in before killing it
154
- # @option options [Integer] :worker_drain_timeout seconds a worker waits for in-flight requests during shutdown before force-killing app threads
154
+ # @option options [Integer] :worker_drain_timeout total seconds to drain application work and detached responses
155
155
  # @option options [Integer] :worker_shutdown_timeout seconds to wait for graceful worker exit before force-killing
156
156
  # @option options [Integer, Array<Integer>, nil] :refork_after request-count threshold(s) at which a warm worker is promoted to a fork source for phased refork; nil or 0 disables. Requires `PR_SET_CHILD_SUBREAPER` (Linux)
157
157
  # @option options [Array<Proc>] :before_fork procs called in the master before each direct worker fork, not seed forks
@@ -872,6 +872,7 @@ module Raptor
872
872
  #
873
873
  # @rbs (Integer index, Integer phase) -> void
874
874
  def run_worker(index, phase)
875
+ @control_server&.shutdown
875
876
  @fork_w.close if @fork_w && !@fork_w.closed?
876
877
  @resp_r.close if @resp_r && !@resp_r.closed?
877
878
 
@@ -16,6 +16,7 @@ module Raptor
16
16
  # @rbs @path: String
17
17
  # @rbs @stats: ^() -> Hash[Symbol, untyped]
18
18
  # @rbs @server: UNIXServer?
19
+ # @rbs @owner_pid: Integer?
19
20
  # @rbs @client: Atom
20
21
  # @rbs @thread: Thread?
21
22
 
@@ -35,6 +36,7 @@ module Raptor
35
36
  @path = uri.path
36
37
  @stats = stats
37
38
  @server = nil
39
+ @owner_pid = nil
38
40
  @client = Atom.new(nil)
39
41
  @thread = nil
40
42
  end
@@ -47,6 +49,7 @@ module Raptor
47
49
  def bind
48
50
  remove_stale_socket
49
51
  @server = UNIXServer.new(@path)
52
+ @owner_pid = Process.pid
50
53
  end
51
54
 
52
55
  # Starts serving requests in a background thread.
@@ -65,7 +68,7 @@ module Raptor
65
68
  end
66
69
  end
67
70
 
68
- # Stops serving and removes the socket.
71
+ # Stops serving and removes the socket path only in the binding process.
69
72
  #
70
73
  # @return [void]
71
74
  #
@@ -81,7 +84,7 @@ module Raptor
81
84
  @server&.close
82
85
  client.close if client.is_a?(UNIXSocket)
83
86
  @thread&.join
84
- File.delete(@path) rescue nil
87
+ File.delete(@path) rescue nil if Process.pid == @owner_pid
85
88
  end
86
89
 
87
90
  private
@@ -573,23 +573,30 @@ module Raptor
573
573
  wakeup rescue nil
574
574
  end
575
575
 
576
- # Waits for detached responses to finish, then cancels any that outlive
577
- # the worker drain period.
576
+ # Waits for detached responses until the shared drain deadline, then cancels any still open.
578
577
  #
579
- # @param timeout [Numeric] seconds to wait before cancelling open bodies
578
+ # @param deadline [Float] monotonic time at which request draining ends
580
579
  # @return [void]
581
580
  #
582
- # @rbs (Numeric timeout) -> void
583
- def drain_detached_bodies(timeout)
581
+ # @rbs (Float deadline) -> void
582
+ def drain_detached_bodies(deadline)
584
583
  barrier = AtomicBoolean.new(false)
585
584
  @io_queue << [:barrier, nil, barrier]
586
585
  wakeup rescue nil
587
586
  @io_applied.wait { barrier.true? }
588
587
 
589
- Timeout.timeout(timeout) do
590
- @detached_drained.wait { @detached_count.value.zero? }
588
+ remaining = deadline - Process.clock_gettime(Process::CLOCK_MONOTONIC)
589
+ if remaining.positive?
590
+ begin
591
+ Timeout.timeout(remaining) do
592
+ @detached_drained.wait { @detached_count.value.zero? }
593
+ end
594
+
595
+ return
596
+ rescue Timeout::Error
597
+ end
591
598
  end
592
- rescue Timeout::Error
599
+
593
600
  @io_queue << [:cancel_all]
594
601
  wakeup rescue nil
595
602
  @detached_drained.wait { @detached_count.value.zero? }
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Raptor
5
- VERSION = "0.28.0"
5
+ VERSION = "0.29.0"
6
6
  end
data/lib/raptor/worker.rb CHANGED
@@ -179,14 +179,16 @@ module Raptor
179
179
  @reactor_thread.value if @reactor_thread && !@reactor_thread.alive?
180
180
  end
181
181
 
182
- # Drains requests and releases the serving threads and parser Ractors.
183
- # A seed keeps its listeners open for the cluster to manage.
182
+ # Drains app work and detached responses within one shared timeout, then
183
+ # releases the serving threads and parser Ractors. A seed keeps its listeners open.
184
184
  #
185
185
  # @rbs (?close_listeners: bool) -> void
186
186
  def shutdown(close_listeners: true)
187
187
  return if @stopped
188
188
 
189
189
  @stopped = true
190
+ deadline = Process.clock_gettime(Process::CLOCK_MONOTONIC) + @options[:worker_drain_timeout]
191
+
190
192
  begin
191
193
  if close_listeners
192
194
  @server&.shutdown
@@ -198,9 +200,9 @@ module Raptor
198
200
  @http1&.shutdown
199
201
  if @reactor_thread&.alive?
200
202
  @http2&.shutdown(@reactor)
201
- @reactor.drain_detached_bodies(@options[:worker_drain_timeout])
203
+ @reactor.drain_detached_bodies(deadline)
202
204
  end
203
- drain_thread_pool if @thread_pool
205
+ drain_thread_pool(deadline) if @thread_pool
204
206
  @reactor&.shutdown
205
207
  begin
206
208
  @reactor_thread&.join
@@ -213,16 +215,16 @@ module Raptor
213
215
 
214
216
  private
215
217
 
216
- # Waits for app work to finish within the configured drain timeout.
218
+ # Waits for app work to finish within the shared drain deadline.
217
219
  #
218
- # @rbs () -> void
219
- def drain_thread_pool
220
+ # @rbs (Float deadline) -> void
221
+ def drain_thread_pool(deadline)
220
222
  drain_thread = Thread.new do
221
223
  Thread.current.name = "Thread Pool Drain"
222
224
 
223
225
  @thread_pool.shutdown
224
226
  end
225
- return if drain_thread.join(@options[:worker_drain_timeout])
227
+ return if drain_thread.join([deadline - Process.clock_gettime(Process::CLOCK_MONOTONIC), 0].max)
226
228
 
227
229
  Log.warn "Force-killing in-flight app threads after #{@options[:worker_drain_timeout]}s drain timeout"
228
230
  @thread_pool.instance_variable_get(:@threads).each(&:kill)
@@ -180,7 +180,7 @@ module Raptor
180
180
  # @option options [Hash] :http2 HTTP/2-specific settings
181
181
  # @option options [Integer] :worker_boot_timeout seconds to wait for a worker to finish booting before killing it
182
182
  # @option options [Integer] :worker_timeout seconds to wait for a booted worker to check in before killing it
183
- # @option options [Integer] :worker_drain_timeout seconds a worker waits for in-flight requests during shutdown before force-killing app threads
183
+ # @option options [Integer] :worker_drain_timeout total seconds to drain application work and detached responses
184
184
  # @option options [Integer] :worker_shutdown_timeout seconds to wait for graceful worker exit before force-killing
185
185
  # @option options [Integer, Array<Integer>, nil] :refork_after request-count threshold(s) at which a warm worker is promoted to a fork source for phased refork; nil or 0 disables. Requires `PR_SET_CHILD_SUBREAPER` (Linux)
186
186
  # @option options [Array<Proc>] :before_fork procs called in the master before each direct worker fork, not seed forks
@@ -11,6 +11,8 @@ module Raptor
11
11
 
12
12
  @server: UNIXServer?
13
13
 
14
+ @owner_pid: Integer?
15
+
14
16
  @client: Atom
15
17
 
16
18
  @thread: Thread?
@@ -40,7 +42,7 @@ module Raptor
40
42
  # @rbs () -> void
41
43
  def start: () -> void
42
44
 
43
- # Stops serving and removes the socket.
45
+ # Stops serving and removes the socket path only in the binding process.
44
46
  #
45
47
  # @return [void]
46
48
  #
@@ -359,14 +359,13 @@ module Raptor
359
359
  # @rbs (Integer id, Integer stream_id) -> void
360
360
  def cancel_http2_body: (Integer id, Integer stream_id) -> void
361
361
 
362
- # Waits for detached responses to finish, then cancels any that outlive
363
- # the worker drain period.
362
+ # Waits for detached responses until the shared drain deadline, then cancels any still open.
364
363
  #
365
- # @param timeout [Numeric] seconds to wait before cancelling open bodies
364
+ # @param deadline [Float] monotonic time at which request draining ends
366
365
  # @return [void]
367
366
  #
368
- # @rbs (Numeric timeout) -> void
369
- def drain_detached_bodies: (Numeric timeout) -> void
367
+ # @rbs (Float deadline) -> void
368
+ def drain_detached_bodies: (Float deadline) -> void
370
369
 
371
370
  # Stores an HTTP/2 connection's socket, state, writer, and flow
372
371
  # controller in the reactor's per-connection maps.
@@ -73,17 +73,17 @@ module Raptor
73
73
  # @rbs () -> void
74
74
  def join: () -> void
75
75
 
76
- # Drains requests and releases the serving threads and parser Ractors.
77
- # A seed keeps its listeners open for the cluster to manage.
76
+ # Drains app work and detached responses within one shared timeout, then
77
+ # releases the serving threads and parser Ractors. A seed keeps its listeners open.
78
78
  #
79
79
  # @rbs (?close_listeners: bool) -> void
80
80
  def shutdown: (?close_listeners: bool) -> void
81
81
 
82
82
  private
83
83
 
84
- # Waits for app work to finish within the configured drain timeout.
84
+ # Waits for app work to finish within the shared drain deadline.
85
85
  #
86
- # @rbs () -> void
87
- def drain_thread_pool: () -> void
86
+ # @rbs (Float deadline) -> void
87
+ def drain_thread_pool: (Float deadline) -> void
88
88
  end
89
89
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raptor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.0
4
+ version: 0.29.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Young