funclatency(8)
funclatency(8), the System Manager's Manual, but make it cute π
β¨ NAME β¨
okay so funclatency is the tool that times functions and shows you their latency as a histogram π literally the whole vibe π
πΈ SYNOPSIS πΈ
funclatency [-h] [-p PID] [-i INTERVAL] [-d DURATION] [-T] [-u] [-m]
[-F] [-r] [-v] pattern
π DESCRIPTION π
okay bestie, this tool traces function calls and times how long each one takes (that's the latency π«Ά). it measures from the moment the function is called until it returns, and it counts both on-CPU time and time spent blocked. no cap, it's all included β¨
this tool uses in-kernel eBPF maps to store the timestamps and the histogram, which is so efficient it's giving main character π¦
π heads up: nested or recursive functions are not supported properly right now. the timestamps get overwritten and you'll get dubious output π try to match single functions, or groups of functions that run at the same stack layer, and that don't end up calling each other.
β οΈ 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 first, and know what you're doing before you use it, periodt.
since this uses BPF, only the root user can use this tool π
π REQUIREMENTS π
you'll need CONFIG_BPF and bcc π§
β¨ OPTIONS β¨
patternβ the function name or search pattern you want. it supports*wildcards (see EXAMPLES π). you can also use-rif you want regular expressions.-hβ prints the usage message π·-p PIDβ only trace this process ID π―-i INTERVALβ print output every interval seconds β°-d DURATIONβ the total duration of the trace, in seconds β³-l LEVELβ sets the level of nested or recursive functions πͺ-Tβ adds timestamps to the output π°οΈ-uβ outputs the histogram in microseconds π-mβ outputs the histogram in milliseconds π«§-Fβ prints a separate histogram for each function that matched π-rβ uses regular expressions for the search pattern π§-vβ prints the BPF program (for debugging, bestie) π
π¦ EXAMPLES π¦
time the do_sys_open() kernel function, and print the distribution as a histogram:
# funclatency do_sys_open
time the read() function in libc across all processes on the system:
# funclatency c:read
time vfs_read(), and print the histogram in microseconds:
# funclatency -u vfs_read
time do_nanosleep(), and print the histogram in milliseconds:
# funclatency -m do_nanosleep
time libc open(), print output every 2 seconds, for a duration of 10 seconds:
# funclatency -i 2 -d 10 c:read
time vfs_read(), print output every 5 seconds, with timestamps:
# funclatency -mTi 5 vfs_read
time vfs_read() for process ID 181 only:
# funclatency -p 181 vfs_read
time both vfs_fstat() and vfs_fstatat() calls, using a wildcard:
# funclatency 'vfs_fstat*'
time both vfs_fstat* calls, and print a separate histogram for each one:
# funclatency -F 'vfs_fstat*'
π FIELDS π
necsβ the nanosecond range π«§usecsβ the microsecond range πmsecsβ the millisecond range πΈcountβ how many calls fell into this range π’distributionβ an ASCII bar chart to visualize the distribution (the count column) π
πΈ OVERHEAD πΈ
this one traces kernel functions and keeps in-kernel timestamps and a histogram, which then get asynchronously copied to user-space. it's very efficient, but kernel functions can fire super often (>1M/sec), and at that point the overhead is expected to be measurable π₯Ί measure in a test environment and understand the overheads before you use it. you can also use funccount to measure the rate of kernel functions over a short duration, so you know what to expect beforehand β¨
π«Ά SOURCE π«Ά
this is from bcc π
https://github.com/iovisor/bcc
also look in the bcc distribution for a companion _examples.txt file, which has example usage, output, and commentary for this tool π
π OS π
Linux π§
π§ͺ STABILITY π§ͺ
Unstable, it's still in development π§
π©βπ» AUTHOR π©βπ»
Brendan Gregg, Sasha Goldshtein π
π SEE ALSO π
funccount(8) π¦
that's a wrap, bestie π this page is from the USER COMMANDS section, dated 2015-08-18, and it's all yours now π«Άπ
π¦ 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