Commit bfd97c5
committed
http2: reduce scheduled callbacks per request
Two per-request scheduling eliminations:
- The end-of-stream check that lets the final DATA frame carry the
END_STREAM flag was scheduled with process.nextTick() on every
write. When the write is dispatched from inside end() - the common
case of end(chunk) - the check can instead run synchronously once
end() returns and the writable state has settled. An end()
override marks the stream while the base method runs, and
[kWriteGeneric] hands the check back to it instead of scheduling
a tick. Writes not tied to end() keep the nextTick behavior.
- Every stream destruction scheduled a setImmediate() to ask the
session to clean itself up, but Http2Session[kMaybeDestroy] is a
no-op unless the session is closed and has no remaining streams.
Gate the setImmediate() on that condition: session.close() runs
its own check, and the native side notifies again through
ongracefulclosecomplete once pending data is flushed.
The wire format is unchanged (verified byte-identical h2load
traffic), and the END_STREAM merge is preserved.
h2load -c 4 -m 100, 1 KiB payload, alternating runs vs the previous
commit: consistently around +1% (within run-to-run noise on any
single set, positive across 42 paired samples).
Signed-off-by: Matteo Collina <hello@matteocollina.com>1 parent 2739f63 commit bfd97c5
1 file changed
Lines changed: 37 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2208 | 2208 | | |
2209 | 2209 | | |
2210 | 2210 | | |
| 2211 | + | |
| 2212 | + | |
2211 | 2213 | | |
2212 | 2214 | | |
2213 | 2215 | | |
| |||
2454 | 2456 | | |
2455 | 2457 | | |
2456 | 2458 | | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
2457 | 2465 | | |
2458 | 2466 | | |
2459 | 2467 | | |
| |||
2494 | 2502 | | |
2495 | 2503 | | |
2496 | 2504 | | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
| 2520 | + | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
2497 | 2524 | | |
2498 | 2525 | | |
2499 | 2526 | | |
| |||
2656 | 2683 | | |
2657 | 2684 | | |
2658 | 2685 | | |
2659 | | - | |
2660 | | - | |
| 2686 | + | |
| 2687 | + | |
| 2688 | + | |
| 2689 | + | |
| 2690 | + | |
| 2691 | + | |
| 2692 | + | |
| 2693 | + | |
| 2694 | + | |
| 2695 | + | |
2661 | 2696 | | |
2662 | 2697 | | |
2663 | 2698 | | |
| |||
0 commit comments