Commit faa2d9a
Channel keepalive eliminates cold-channel latency cliff (facebookresearch#740)
Summary:
Pull Request resolved: facebookresearch#740
Adds a per-MockServicesClient keepalive timer that fires a fire-and-forget `getStatus()` probe RPC every N milliseconds, keeping Rocket channels warm between sparse session bursts.
After D105903218 distributed outbound RPCs across one MockServicesClient per SREventBase (123 channels on BGM), the t25 QPS-latency sweep surfaced a severe cold-channel anti-pattern: p95 latency at low offered load was up to 14× *worse* than at peak load on BGM (9,488 ms at q=5/inst vs 684 ms at q=35/inst), with throughput collapsing to 31% of requested (1.55 of 5 QPS). Grace and CPL showed milder 2.5-2.8× cliffs.
Root cause (confirmed via perf-record diff at q=5 vs q=35 on BGM): at low offered load, ≈1.5 sessions in-flight × K=16 fanout = 24 RPCs spread across 123 channels — most channels idle for 100-300 ms between bursts. Each cold RPC then pays three compounding penalties: Rocket channel re-arm (+2.4pp Folly, +1.9pp RPC-AsyncIO at q=5), deep C-state wake on idle SREventBase cores (Zen4c C6 wake ≈100 µs; `poll_idle` + `acpi_processor_ffh_cstate_enter` in top 14 hot functions), and cold allocator/JIT caches (+4.1pp MemAlloc, +2.0pp JIT-Unresolved). All three penalties share the same proximate cause: channel idle time > 100 ms.
Touching every channel every 150 ms via a cheap getStatus() probe eliminates all three penalties simultaneously. The probe runs on the channel's own EventBase (thread-affine) and is fire-and-forget (drops the returned SemiFuture); transport errors are swallowed silently to avoid keepalive failures propagating to the application path.
Bandwidth cost: ~13K pings/sec/instance × ~100 bytes round-trip = ~1.3 MB/s — negligible. mock_services CPU cost ≈0.07 cores per instance.
Knobs:
- New CLI flag `--mock_keepalive_interval_ms` on LeafNodeRank (default 0 = disabled so the anti-pattern stays observable for regression testing).
- New `MOCK_KEEPALIVE_INTERVAL_MS` env override in run.sh so sweep scripts can A/B without rebuilding.
- Recommended starting value: 150 ms (validated). 300-500 ms likely sufficient; tunable.
Reviewed By: YifanYuan3
Differential Revision: D1065584231 parent b3038be commit faa2d9a
5 files changed
Lines changed: 127 additions & 11 deletions
File tree
- packages/feedsim
- third_party/src/workloads/ranking
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
719 | 719 | | |
720 | 720 | | |
721 | 721 | | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
722 | 732 | | |
723 | 733 | | |
724 | 734 | | |
| |||
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
325 | 327 | | |
326 | 328 | | |
327 | 329 | | |
| |||
468 | 470 | | |
469 | 471 | | |
470 | 472 | | |
471 | | - | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
472 | 476 | | |
473 | 477 | | |
474 | 478 | | |
| |||
2357 | 2361 | | |
2358 | 2362 | | |
2359 | 2363 | | |
2360 | | - | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
2361 | 2367 | | |
2362 | 2368 | | |
2363 | 2369 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
Lines changed: 86 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 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 | + | |
| 87 | + | |
| 88 | + | |
32 | 89 | | |
33 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
34 | 94 | | |
35 | 95 | | |
36 | 96 | | |
| |||
88 | 148 | | |
89 | 149 | | |
90 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
91 | 161 | | |
92 | 162 | | |
93 | 163 | | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
100 | 179 | | |
101 | 180 | | |
102 | 181 | | |
| |||
Lines changed: 12 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
69 | | - | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
70 | 74 | | |
71 | 75 | | |
72 | 76 | | |
| |||
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
100 | 110 | | |
101 | 111 | | |
| 112 | + | |
102 | 113 | | |
103 | 114 | | |
104 | 115 | | |
| |||
0 commit comments