iovisor/bcc

Reduce CPU overhead of per-event tools by allowing more buffering

Open

#1.033 geöffnet am 8. März 2017

Auf GitHub ansehen
 (12 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C (4.051 Forks)batch import
help wantedprio:high

Repository-Metriken

Stars
 (22.409 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 12T 6h) (12 gemergte PRs in 30 T)

Beschreibung

Not a big problem yet, but at some point we should look into this...

The normal perf_output-consuming loop we've been using is:

while 1:
    b.kprobe_poll()

This wakes up as quickly as it can, and can consume noticeable CPU. I had to tune it for my cpuunclaimed tool:

while 1:
    # allow some buffering by calling sleep(), to reduce the context switch
    # rate and lower overhead.
    try:
        if not exiting:
            sleep(wakeup_s)
    except KeyboardInterrupt:
        exiting = 1
    b.kprobe_poll()
    slept += wakeup_s

This ticket is to explore doing this for more tools. Should b.kprobe_poll() have a built-in sleep, that can be tuned? Eg, 100ms by default?

This is more practical now we have #997, and can increase the buffer size.

Contributor Guide