Commit 41f44d9
Pre-build 64-slot response template pool to eliminate per-request RPC-DataGen cost (facebookresearch#742)
Summary:
Pull Request resolved: facebookresearch#742
The t31v6 BGM hot-function breakdown showed RPC-DataGen at 5.9% of total CPU, dominated by `SilesiaResponseGenerator::generateRankingResponse` (~4.65% leaf self-time) plus the matching `~RankingObject` / `~RankingStory` destructor chain (~1.23%) — every request constructs a fresh 2000-story RankingResponse, serializes it, then immediately destroys it. Total chain is ~5.5% of CPU that has no production analog (this is test-only data fabrication).
Switch to a precomputed template pool: build `kResponseTemplatePoolSize=64` RankingResponse instances at server startup (right after `g_silesia_response_gen` is wired), and each request hands a `RankingResponse&` to the serializer by rotating through the pool. Only the `queryID` field is mutated per-request (the one field a real aggregator varies). 64 slots are enough to keep any single template from getting cache-hot enough to skew the Serialization/Compression bucket measurements.
Three callsites updated:
- `LeafNodeRank.cc:1216-1224` — DLRM async request handler Stage-5 (the dominant hot path)
- `LeafNodeRank.cc:1419-1425` — second async response handler (sister to the above)
- `LeafNodeRank.cc:1511-1513` — sync legacy ranking handler
Init point added at `LeafNodeRank.cc:~2346` after the Silesia loader is up, so the templates correctly use Silesia-derived payload bytes when `--silesia_dir` is set (and fall back to the xor128 RNG path otherwise).
Wire-shape is identical to today: same story count, same object count per story, same payload-map sizes, same action counts. The 64-slot rotation prevents any single template from being cache-hot enough to distort the Serialization or Compression CPU buckets.
Reviewed By: YifanYuan3
Differential Revision: D1073276071 parent a7c6960 commit 41f44d9
1 file changed
Lines changed: 52 additions & 10 deletions
Lines changed: 52 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
286 | 317 | | |
287 | 318 | | |
288 | 319 | | |
| |||
1202 | 1233 | | |
1203 | 1234 | | |
1204 | 1235 | | |
1205 | | - | |
1206 | | - | |
1207 | | - | |
1208 | | - | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
1209 | 1242 | | |
1210 | 1243 | | |
1211 | | - | |
1212 | 1244 | | |
1213 | 1245 | | |
1214 | 1246 | | |
| |||
1404 | 1436 | | |
1405 | 1437 | | |
1406 | 1438 | | |
1407 | | - | |
1408 | | - | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
1409 | 1443 | | |
1410 | 1444 | | |
1411 | 1445 | | |
| |||
1495 | 1529 | | |
1496 | 1530 | | |
1497 | 1531 | | |
1498 | | - | |
1499 | | - | |
1500 | | - | |
| 1532 | + | |
| 1533 | + | |
1501 | 1534 | | |
1502 | 1535 | | |
1503 | 1536 | | |
| |||
2331 | 2364 | | |
2332 | 2365 | | |
2333 | 2366 | | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
2334 | 2376 | | |
2335 | 2377 | | |
2336 | 2378 | | |
| |||
0 commit comments