funccount(8)

πŸ“¦ version 0.36.1, in centos-stream 10, centos-stream 9, fedora 43, fedora 44

✨ NAME ✨

okay so funccount is the tool that counts function, tracepoint, and USDT probe calls matching a pattern πŸ”πŸ’– it's Linux eBPF/bcc, so it's giving low-level and I'm obsessed.

πŸŽ€ SYNOPSIS πŸŽ€

funccount [-h] [-p PID] [-i INTERVAL] [-d DURATION] [-T] [-r] [-c CPU]
[-D] pattern

πŸ’… DESCRIPTION πŸ’…

bestie, this is the quick way to figure out which functions are getting called and how often πŸ¦‹ It uses in-kernel eBPF maps to do the counting, so it's lowkey so efficient.

⚠️ WARNING: This uses dynamic tracing of (what can be many) functions, and that has caused issues on some kernel versions (risk of panics or freezes) πŸ’€ Test it, and know what you're doing, before you use it!!

Since this uses BPF, only the root user can use this tool πŸ‘‘

🧚 REQUIREMENTS 🧚

You need CONFIG_BPF and bcc. No cap, no skipping this 🫢

🌸 OPTIONS 🌸

  • pattern β€” your search pattern πŸ” It supports * wildcards (see EXAMPLES), and if you want regular expressions instead, pair it with -r.
  • -h β€” prints the usage message πŸ’œ
  • -p PID β€” only traces this process ID 🎯
  • -i INTERVAL β€” prints output every INTERVAL seconds ⏰
  • -d DURATION β€” total duration of the trace in seconds βŒ›
  • -T β€” adds timestamps to the output πŸ•°οΈ
  • -r β€” uses regular expressions for the search pattern 🧠
  • -D β€” prints the BPF program before it starts (for debugging, iykyk) πŸ™ˆ
  • -c CPU β€” only traces on this CPU πŸ“

🌈 EXAMPLES 🌈

okay here's where it gets fun ✨

Count kernel functions beginning with "vfs_", until Ctrl-C is hit:

# funccount 'vfs_*'

Count kernel functions beginning with "tcp_send", until Ctrl-C is hit:

# funccount 'tcp_send*'

Print kernel functions beginning with "vfs_", every second:

# funccount -i 1 'vfs_*'

Print kernel functions beginning with "vfs_", for ten seconds only:

# funccount -d 10 'vfs_*'

Match kernel functions beginning with "vfs_", using regular expressions:

# funccount -r '^vfs_.*'

Count vfs calls for process ID 181 only:

# funccount -p 181 'vfs_*'

Count calls to the sched_fork tracepoint, indicating a fork() performed:

# funccount t:sched:sched_fork

Count all GC USDT probes in the Node process:

# funccount -p 185 u:node:gc*

Count all malloc() calls in libc:

# funccount c:malloc

Count kernel functions beginning with "vfs_" on CPU 1 only:

# funccount -c 1 'vfs_*'

πŸŽ€ FIELDS πŸŽ€

  • FUNC β€” the function name πŸ¦‹
  • COUNT β€” how many calls happened while tracing πŸ”₯

🫧 OVERHEAD 🫧

So this traces functions and keeps in-kernel counts, which then get asynchronously copied to user-space πŸ›Έ Even if the call rate is super high (>1M/sec), this is a relatively efficient way to trace these events, so the overhead should be small for normal workloads. Still, measure in a test environment before you use it, periodt πŸ’…

πŸ”­ SOURCE πŸ”­

This is from bcc πŸ’–

https://github.com/iovisor/bcc

Also check the bcc distribution for a companion _examples.txt file with example usage, output, and commentary for this tool πŸ“š

πŸ’» OS πŸ’»

Linux 🐧

πŸ§ͺ STABILITY πŸ§ͺ

Unstable, it's still in development 🚧

πŸ‘©β€πŸ’» AUTHOR πŸ‘©β€πŸ’»

Brendan Gregg and Sasha Goldshtein πŸ‘‘

🌟 SEE ALSO 🌟

stackcount(8), funclatency(8), vfscount(8) ✨


Byeee bestie, go count some calls πŸ₯° USER COMMANDS Β· 2015-08-18 Β· funccount(8) πŸ’œβœ¨

πŸ“¦ where this page comes from