Commit ed6e385
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 emits 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 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 422.2k ± 13% 190.3k ± 38% -54.93% (p=0.002 n=6)
goroutines=100x10-14 619.7k ± 10% 171.1k ± 43% -72.38% (p=0.002 n=6)
goroutines=100x50-14 1423.6k ± 7% 174.3k ± 44% -87.76% (p=0.002 n=6)
goroutines=1000x3-14 2424.8k ± 8% 298.6k ± 106% -87.68% (p=0.002 n=6)
goroutines=1000x10-14 7378.4k ± 2% 268.2k ± 146% -96.36% (p=0.002 n=6)
goroutines=1000x50-14 23372.5k ± 10% 330.1k ± 173% -98.59% (p=0.002 n=6)
goroutines=10000x3-14 42.802M ± 47% 1.991M ± 105% -95.35% (p=0.002 n=6)
goroutines=10000x10-14 36668.2k ± 95% 743.1k ± 72% -97.97% (p=0.002 n=6)
goroutines=10000x50-14 120639.1k ± 2% 188.2k ± 2582% -99.84% (p=0.002 n=6)
geomean 6.760M 326.2k -95.18%1 parent c1e6e49 commit ed6e385
File tree
7 files changed
+366
-155
lines changed- src
- internal/profilerecord
- runtime
- pprof
7 files changed
+366
-155
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 | | - | |
1268 | | - | |
1269 | | - | |
1270 | | - | |
1271 | | - | |
1272 | | - | |
1273 | | - | |
| 1258 | + | |
| 1259 | + | |
1274 | 1260 | | |
1275 | 1261 | | |
1276 | 1262 | | |
1277 | 1263 | | |
1278 | 1264 | | |
1279 | 1265 | | |
1280 | | - | |
1281 | | - | |
| 1266 | + | |
1282 | 1267 | | |
1283 | 1268 | | |
1284 | 1269 | | |
| |||
1316 | 1301 | | |
1317 | 1302 | | |
1318 | 1303 | | |
1319 | | - | |
| 1304 | + | |
1320 | 1305 | | |
1321 | 1306 | | |
1322 | 1307 | | |
| |||
1358 | 1343 | | |
1359 | 1344 | | |
1360 | 1345 | | |
1361 | | - | |
| 1346 | + | |
1362 | 1347 | | |
1363 | 1348 | | |
1364 | 1349 | | |
| |||
1401 | 1386 | | |
1402 | 1387 | | |
1403 | 1388 | | |
1404 | | - | |
1405 | | - | |
1406 | | - | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
1407 | 1398 | | |
1408 | 1399 | | |
1409 | 1400 | | |
| |||
1414 | 1405 | | |
1415 | 1406 | | |
1416 | 1407 | | |
1417 | | - | |
1418 | 1408 | | |
1419 | 1409 | | |
1420 | 1410 | | |
| |||
1436 | 1426 | | |
1437 | 1427 | | |
1438 | 1428 | | |
1439 | | - | |
1440 | 1429 | | |
1441 | 1430 | | |
1442 | 1431 | | |
| |||
1559 | 1548 | | |
1560 | 1549 | | |
1561 | 1550 | | |
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 | | - | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
1635 | 1558 | | |
1636 | 1559 | | |
1637 | 1560 | | |
| |||
1641 | 1564 | | |
1642 | 1565 | | |
1643 | 1566 | | |
1644 | | - | |
| 1567 | + | |
1645 | 1568 | | |
1646 | 1569 | | |
1647 | 1570 | | |
| |||
1653 | 1576 | | |
1654 | 1577 | | |
1655 | 1578 | | |
1656 | | - | |
1657 | | - | |
1658 | | - | |
1659 | | - | |
1660 | | - | |
| 1579 | + | |
1661 | 1580 | | |
1662 | 1581 | | |
1663 | 1582 | | |
| |||
0 commit comments