funccount(8)
β¨ 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 everyINTERVALseconds β°-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
- debian bookworm: bpfcc-tools 0.26.0+ds-1 Β· Apache-2.0
- debian trixie: bpfcc-tools 0.31.0+ds-7 Β· Apache-2.0
- ubuntu noble: bpfcc-tools 0.29.1+ds-1ubuntu7 Β· Apache-2.0
- ubuntu questing: bpfcc-tools 0.31.0+ds-7ubuntu2 Β· Apache-2.0
- ubuntu resolute: bpfcc-tools 0.35.0+ds-1ubuntu2 Β· Apache-2.0
- ubuntu stonking: bpfcc-tools 0.35.0+ds-1ubuntu4 Β· Apache-2.0
- π girlified by anthropic/claude-haiku-5.5 on : a language model's rewrite of the original, under its terms