Commit 5597be9
Replay USDT metadata on semaphore-count increase, not every call
73c1f64 made emitMetadata re-fire stall_reason_map and cubin_loaded
on every CUPTI callback when the per-probe semaphore was nonzero, to
fix multi-consumer attach: if a second consumer (e.g.
test/bpf/activity_parser) joins while parca-agent is already
attached, the semaphore stays nonzero across the 1→2 transition, so
a "fire on transition to nonzero" gate never re-fires and the second
consumer permanently misses metadata.
The unconditional re-fire turned out to be a sledgehammer: at
PyTorch-class CUDA call rates (~10K callbacks/sec × L loaded cubins
× ENTER+EXIT) it emits hundreds of thousands of cubin_loaded events
per second. Downstream, each one drives a /proc/<pid>/mem cubin read
in the parca-agent consumer — observed driving the agent heap to
38GB before OOM.
The USDT semaphore is a refcount: every uprobe attach increments,
every detach decrements. Track the raw count and re-emit whenever
the current count exceeds the previously observed count. That
handles 0→1 (cold start) and 1→2 (second consumer joins mid-run)
without firing every call.
ABA — attach+detach that net the same count between two of our
reads — is bounded by a 30s periodic refresh that also re-emits any
cubin whose lastEmittedNs has gone stale.
Steady-state cost in emitMetadata: two atomic uint16 loads, one
exchange, a branch. No mutex acquisition, no USDT fires. Pair with
BPF-side (pid, crc) dedup in the consumer to make the 30s-refresh
fires no-ops once a tracer has seen each cubin.
Signed-off-by: Tommy Reilly <gnurizen@gmail.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f30e18f commit 5597be9
2 files changed
Lines changed: 66 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
614 | 614 | | |
615 | 615 | | |
616 | 616 | | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
617 | 637 | | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
| 638 | + | |
625 | 639 | | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
630 | 660 | | |
631 | 661 | | |
632 | 662 | | |
633 | 663 | | |
634 | | - | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
635 | 671 | | |
636 | | - | |
637 | | - | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
638 | 678 | | |
639 | 679 | | |
640 | 680 | | |
| |||
759 | 799 | | |
760 | 800 | | |
761 | 801 | | |
| 802 | + | |
762 | 803 | | |
763 | 804 | | |
764 | 805 | | |
765 | | - | |
| 806 | + | |
766 | 807 | | |
767 | 808 | | |
768 | 809 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
162 | 163 | | |
163 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
164 | 174 | | |
165 | 175 | | |
166 | 176 | | |
| |||
0 commit comments