Commit d229162
committed
runtime/pprof: add debug=3 goroutine profile with goid and labels
This adds a new goroutine profile debug mode, debug=3.
This mode emits in the same binary proto output format as debug=0, with
the only difference being that it does not aggregate matching stack/label
combinations into a single count, and instead mits a sample per goroutine
with additional synthesized labels to communicate some of the details of
each goroutine, specifically:
- go::goroutine: the goroutine's ID
- go::goroutine_created_by: ID of the goroutine's creator (if any)
- go::goroutine_state: current state of the goroutine (e.g. runnable)
- go::goroutine_wait_minutes: approximate minutes goroutine has spent
waiting (if applicable)
These are synthesized as labels, side-by-side with any user-set labels
thus the 'go::' prefix to namespace these synthetic labels somewhat.
We aim to minimize collisions with user-set labels as while the format
does allow for multi-valued labels, meaning a collision would not
immediately overwrite a user-set label, the upstream proto does warn
that not all tools handle multi-valued labels well, so the namespace
prefix aims to avoid them if possible. The form 'go::' is chosen as the
upstream proto reserves 'pprof::', which seems to establish this format
as a convention.
Previously the debug=2 mode was the only way to get this kind of
per-goroutine information that is sometimes vital to understanding the
state of a process. However debug=2 had two major drawbacks:
1) its collection incurs a potentially lengthy and disruptive
stop-the-world pause due to it not (and perhaps being unable to)
utilizing the concurrent collection mechanism used by debug=0/1, and
2) it does not (currently) include user-set labels in the same profile.
This new mode that uses the same concurrent collection mechanism as 0/1,
with its minimal STW penalty, but also includes the per-goroutine details
that make debug=2 so useful. Changing debug=2, which already included
this per-goroutine detail, in-place to use the concurrent collection
mechanism could avoid introducing a new mode, but it is not clear that
this is possible with breaking changes to its output: debug=2 includes
argument _values_ in its output would would require collection in both a
concurrent and consistent manner. Thus the use of a new mode instead.
The difference in service latency observed by running goroutines during
profile collection is demonstrated by BenchmarkGoroutineProfileLatencyImpact:
│ debug=2 │ debug=3 │
│ max_latency_ns │ max_latency_ns vs base │
goroutines=100x3-14 508.4k ± 17% 166.7k ± 45% -67.21% (p=0.002 n=6)
goroutines=100x10-14 727.4k ± 9% 176.3k ± 34% -75.76% (p=0.002 n=6)
goroutines=100x50-14 1979.1k ± 6% 201.7k ± 18% -89.81% (p=0.002 n=6)
goroutines=1000x3-14 6454.9k ± 3% 235.6k ± 36% -96.35% (p=0.002 n=6)
goroutines=1000x10-14 10620.8k ± 47% 259.8k ± 165% -97.55% (p=0.002 n=6)
goroutines=1000x50-14 35170.8k ± 1% 228.7k ± 108% -99.35% (p=0.002 n=6)
goroutines=10000x3-14 63.836M ± 49% 1.961M ± 470% -96.93% (p=0.002 n=6)
goroutines=10000x10-14 58.962M ± 82% 4.073M ± 134% -93.09% (p=0.002 n=6)
goroutines=10000x50-14 259.723M ± 33% 4.730M ± 91% -98.18% (p=0.002 n=6)
geomean 10.62M 527.0k -95.04%1 parent c1e6e49 commit d229162
File tree
7 files changed
+430
-154
lines changed- src
- internal/profilerecord
- runtime
- pprof
7 files changed
+430
-154
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
15 | 21 | | |
16 | 22 | | |
17 | 23 | | |
| |||
26 | 32 | | |
27 | 33 | | |
28 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1246 | 1246 | | |
1247 | 1247 | | |
1248 | 1248 | | |
1249 | | - | |
1250 | | - | |
1251 | | - | |
1252 | | - | |
1253 | | - | |
1254 | | - | |
1255 | | - | |
1256 | | - | |
1257 | | - | |
1258 | | - | |
1259 | | - | |
| 1249 | + | |
| 1250 | + | |
1260 | 1251 | | |
1261 | 1252 | | |
1262 | 1253 | | |
1263 | | - | |
1264 | | - | |
| 1254 | + | |
| 1255 | + | |
1265 | 1256 | | |
1266 | 1257 | | |
1267 | 1258 | | |
1268 | | - | |
1269 | | - | |
1270 | | - | |
1271 | | - | |
1272 | | - | |
1273 | | - | |
| 1259 | + | |
| 1260 | + | |
1274 | 1261 | | |
1275 | 1262 | | |
1276 | 1263 | | |
1277 | 1264 | | |
1278 | 1265 | | |
1279 | 1266 | | |
1280 | | - | |
1281 | | - | |
| 1267 | + | |
1282 | 1268 | | |
1283 | 1269 | | |
1284 | 1270 | | |
| |||
1316 | 1302 | | |
1317 | 1303 | | |
1318 | 1304 | | |
1319 | | - | |
| 1305 | + | |
1320 | 1306 | | |
1321 | 1307 | | |
1322 | 1308 | | |
| |||
1358 | 1344 | | |
1359 | 1345 | | |
1360 | 1346 | | |
1361 | | - | |
| 1347 | + | |
1362 | 1348 | | |
1363 | 1349 | | |
1364 | 1350 | | |
| |||
1401 | 1387 | | |
1402 | 1388 | | |
1403 | 1389 | | |
1404 | | - | |
1405 | | - | |
1406 | | - | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
1407 | 1399 | | |
1408 | 1400 | | |
1409 | 1401 | | |
| |||
1414 | 1406 | | |
1415 | 1407 | | |
1416 | 1408 | | |
1417 | | - | |
1418 | 1409 | | |
1419 | 1410 | | |
1420 | 1411 | | |
| |||
1436 | 1427 | | |
1437 | 1428 | | |
1438 | 1429 | | |
1439 | | - | |
1440 | 1430 | | |
1441 | 1431 | | |
1442 | 1432 | | |
| |||
1559 | 1549 | | |
1560 | 1550 | | |
1561 | 1551 | | |
1562 | | - | |
1563 | | - | |
1564 | | - | |
1565 | | - | |
1566 | | - | |
1567 | | - | |
1568 | | - | |
1569 | | - | |
1570 | | - | |
1571 | | - | |
1572 | | - | |
1573 | | - | |
1574 | | - | |
1575 | | - | |
1576 | | - | |
1577 | | - | |
1578 | | - | |
1579 | | - | |
1580 | | - | |
1581 | | - | |
1582 | | - | |
1583 | | - | |
1584 | | - | |
1585 | | - | |
1586 | | - | |
1587 | | - | |
1588 | | - | |
1589 | | - | |
1590 | | - | |
1591 | | - | |
1592 | | - | |
1593 | | - | |
1594 | | - | |
1595 | | - | |
1596 | | - | |
1597 | | - | |
1598 | | - | |
1599 | | - | |
1600 | | - | |
1601 | | - | |
1602 | | - | |
1603 | | - | |
1604 | | - | |
1605 | | - | |
1606 | | - | |
1607 | | - | |
1608 | | - | |
1609 | | - | |
1610 | | - | |
1611 | | - | |
1612 | | - | |
1613 | | - | |
1614 | | - | |
1615 | | - | |
1616 | | - | |
1617 | | - | |
1618 | | - | |
1619 | | - | |
1620 | | - | |
1621 | | - | |
1622 | | - | |
1623 | | - | |
1624 | | - | |
1625 | | - | |
1626 | | - | |
1627 | | - | |
1628 | | - | |
1629 | | - | |
1630 | | - | |
1631 | | - | |
1632 | | - | |
1633 | | - | |
1634 | | - | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
1635 | 1559 | | |
1636 | 1560 | | |
1637 | 1561 | | |
| |||
1641 | 1565 | | |
1642 | 1566 | | |
1643 | 1567 | | |
1644 | | - | |
| 1568 | + | |
1645 | 1569 | | |
1646 | 1570 | | |
1647 | 1571 | | |
| |||
1653 | 1577 | | |
1654 | 1578 | | |
1655 | 1579 | | |
1656 | | - | |
1657 | | - | |
1658 | | - | |
1659 | | - | |
1660 | | - | |
| 1580 | + | |
1661 | 1581 | | |
1662 | 1582 | | |
1663 | 1583 | | |
| |||
0 commit comments