Commit 3dafa71
committed
perf(memtrack): decide ring buffer wakeups producer-side
Every submit called bpf_ringbuf_query(BPF_RB_AVAIL_DATA) to decide
whether to force a consumer wakeup. That reads the consumer position, a
cache line the polling thread on another CPU writes continuously, so
each event paid a cross-CPU miss for a decision that only changes once
per watermark.
Count submitted bytes per CPU instead and force a wakeup whenever the
watermark is crossed. Events are fixed size, so this is the same
cadence the query approximated, decided entirely on the producer side
with no shared cache line involved. A missing counter forces the wakeup
rather than risking a stalled consumer.
Measured on a malloc/free latency harness (p50 per pair, glibc):
2064 ns to 1102 ns, the largest of the three hot-path wins. Verified at
10M malloc/free pairs (20,006,217 events, ~800 MB through the 256 MB
ring buffer) with the dropped-event counter still at zero, so batched
wakeups keep up with a sustained high event rate.1 parent d0669a1 commit 3dafa71
2 files changed
Lines changed: 37 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
16 | 15 | | |
17 | 16 | | |
18 | | - | |
19 | | - | |
20 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
21 | 41 | | |
22 | 42 | | |
23 | 43 | | |
| |||
144 | 164 | | |
145 | 165 | | |
146 | 166 | | |
147 | | - | |
| 167 | + | |
148 | 168 | | |
149 | 169 | | |
150 | 170 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
31 | 39 | | |
32 | 40 | | |
33 | 41 | | |
| |||
0 commit comments