Commit 3ae16d4
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 3ae16d4
File tree
7 files changed
+368
-161
lines changed- src
- internal/profilerecord
- runtime
- pprof
7 files changed
+368
-161
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 | | - | |
1265 | | - | |
1266 | | - | |
1267 | | - | |
1268 | | - | |
1269 | | - | |
1270 | | - | |
1271 | | - | |
1272 | | - | |
1273 | | - | |
| 1254 | + | |
| 1255 | + | |
1274 | 1256 | | |
1275 | 1257 | | |
1276 | 1258 | | |
1277 | 1259 | | |
1278 | 1260 | | |
1279 | 1261 | | |
1280 | | - | |
1281 | | - | |
| 1262 | + | |
1282 | 1263 | | |
1283 | 1264 | | |
1284 | 1265 | | |
| |||
1316 | 1297 | | |
1317 | 1298 | | |
1318 | 1299 | | |
1319 | | - | |
| 1300 | + | |
1320 | 1301 | | |
1321 | 1302 | | |
1322 | 1303 | | |
1323 | 1304 | | |
1324 | 1305 | | |
1325 | 1306 | | |
1326 | | - | |
| 1307 | + | |
1327 | 1308 | | |
1328 | 1309 | | |
1329 | 1310 | | |
1330 | | - | |
| 1311 | + | |
1331 | 1312 | | |
1332 | 1313 | | |
1333 | 1314 | | |
| |||
1358 | 1339 | | |
1359 | 1340 | | |
1360 | 1341 | | |
1361 | | - | |
| 1342 | + | |
1362 | 1343 | | |
1363 | 1344 | | |
1364 | 1345 | | |
| |||
1401 | 1382 | | |
1402 | 1383 | | |
1403 | 1384 | | |
1404 | | - | |
1405 | | - | |
1406 | | - | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
1407 | 1394 | | |
1408 | 1395 | | |
1409 | 1396 | | |
| |||
1414 | 1401 | | |
1415 | 1402 | | |
1416 | 1403 | | |
1417 | | - | |
1418 | 1404 | | |
1419 | 1405 | | |
1420 | 1406 | | |
| |||
1436 | 1422 | | |
1437 | 1423 | | |
1438 | 1424 | | |
1439 | | - | |
1440 | 1425 | | |
1441 | 1426 | | |
1442 | 1427 | | |
| |||
1528 | 1513 | | |
1529 | 1514 | | |
1530 | 1515 | | |
1531 | | - | |
| 1516 | + | |
1532 | 1517 | | |
1533 | 1518 | | |
1534 | 1519 | | |
| |||
1545 | 1530 | | |
1546 | 1531 | | |
1547 | 1532 | | |
1548 | | - | |
| 1533 | + | |
1549 | 1534 | | |
1550 | 1535 | | |
1551 | 1536 | | |
| |||
1559 | 1544 | | |
1560 | 1545 | | |
1561 | 1546 | | |
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 | | - | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
1635 | 1554 | | |
1636 | 1555 | | |
1637 | 1556 | | |
| |||
1641 | 1560 | | |
1642 | 1561 | | |
1643 | 1562 | | |
1644 | | - | |
| 1563 | + | |
1645 | 1564 | | |
1646 | 1565 | | |
1647 | 1566 | | |
| |||
1653 | 1572 | | |
1654 | 1573 | | |
1655 | 1574 | | |
1656 | | - | |
1657 | | - | |
1658 | | - | |
1659 | | - | |
1660 | | - | |
| 1575 | + | |
1661 | 1576 | | |
1662 | 1577 | | |
1663 | 1578 | | |
| |||
0 commit comments