funcinterval(8)

πŸ“¦ version 0.36.1, in alpine 3.24, nixpkgs unstable, opensuse-leap 16.0

✨ funcinterval(8) β€” the time-gap tracker ✨

πŸ’– NAME

funcinterval - Time interval between the same function, tracepoint as a histogram. πŸŽ€

🌸 SYNOPSIS

funcinterval [-h] [-p PID] [-i INTERVAL] [-d DURATION] [-T] [-u] [-m]
[-v] pattern

πŸ¦‹ DESCRIPTION

okay so this tool times the interval between the same function, and shows it to you as a histogram πŸ“Šβœ¨

bestie, eBPF/bcc is literally made for platform performance tuning πŸ’… With funclatency, we can profile specific functions to see how much latency a function costs. BUT lowkey, sometimes the performance drop isn't about how long a function takes, it's about the gap between function calls πŸ™ˆ That's the whole reason funcinterval exists. It's giving purpose 🧚

This tool uses in-kernel eBPF maps for storing timestamps and the histogram, for efficiency. The way that it keeps everything in the kernel is so smart ngl 🫢

⚠️ WARNING: This uses dynamic tracing of (what can be many) functions, an activity that has had issues on some kernel versions (risk of panics or freezes). Test, and know what you are doing, before use. Not me saying this with a straight face, but please be careful 😭

Since this uses BPF, only the root user can use this tool. No root, no tool, periodt πŸ‘‘

πŸŽ€ REQUIREMENTS

CONFIG_BPF and bcc. πŸ’œ

✨ OPTIONS ✨

  • pattern β€” the function name you want to watch πŸ”
  • -h β€” prints the usage message, for when you forget everything πŸ™ˆ
  • -p PID β€” only trace this process ID. Main character energy πŸ‘‘
  • -i INTERVAL β€” print output every INTERVAL seconds πŸ•’
  • -d DURATION β€” total duration of the trace, in seconds ⏳
  • -T β€” slap timestamps onto the output πŸ•°οΈ
  • -u β€” output the histogram in microseconds 🌸
  • -m β€” output the histogram in milliseconds πŸ“
  • -v β€” print the BPF program, for debugging purposes πŸ§šβ€β™€οΈ

πŸ’… EXAMPLES ✨

Time the interval of the do_sys_open() kernel function as a histogram:

# funcinterval do_sys_open

Time the interval of xhci_ring_ep_doorbell(), in microseconds:

# funcinterval -u xhci_ring_ep_doorbell

Time the interval of do_nanosleep(), in milliseconds:

# funcinterval -m do_nanosleep

Output every 5 seconds, with timestamps:

# funcinterval -mTi 5 vfs_read

Time process 181 only:

# funcinterval -p 181 vfs_read

Time the interval of the mm_vmscan_direct_reclaim_begin tracepoint:

# funcinterval t:vmscan:mm_vmscan_direct_reclaim_begin

Time the interval of c:malloc used by top every 3 seconds:

# funcinterval -p `pidof -s top` -i 3 c:malloc

Time the /usr/local/bin/python main function:

# funcinterval /usr/local/bin/python:main

πŸ“Š FIELDS πŸ“Š

  • necs β€” nanosecond range πŸ’«
  • usecs β€” microsecond range 🌷
  • msecs β€” millisecond range 🌈
  • count β€” how many calls fell into this range πŸ”’
  • distribution β€” an ASCII bar chart to visualize the distribution (count column) πŸ“ˆ

🫧 OVERHEAD 🫧

This traces kernel functions and maintains in-kernel timestamps and a histogram, which are asynchronously copied to user-space. While this method is very efficient, the rate of kernel functions can also be very high (>1M/sec), at which point the overhead is expected to be measurable. Measure in a test environment and understand overheads before use πŸ§ͺ You can also use funccount to measure the rate of kernel functions over a short duration, to set some expectations before use.

🌈 SOURCE 🌈

This is from bcc.

https://github.com/iovisor/bcc

Also look in the bcc distribution for a companion _examples.txt file containing example usage, output, and commentary for this tool. Bestie, that file is a goldmine πŸ“šπŸ’œ

πŸ“ OS πŸ“

Linux

🧁 STABILITY 🧁

Unstable - in development.

πŸ’œ AUTHOR πŸ’œ

Edward Wu

πŸ”— SEE ALSO πŸ”—

funclatency(8) funccount(8)


Bye bestie, go trace something iconic πŸ¦‹πŸ’–βœ¨ funcinterval(8), USER COMMANDS, bcc-era 2020-05-27 vibes 🌸🫢