funcslower(8)
β¨ NAME β¨
Okay bestie, welcome to funcslower(8) from the System Manager's Manual π It's a tool for tracing slow kernel or user function calls π’π¨
β¨ SYNOPSIS β¨
funcslower [-hf] [-p PID] [-U | -K] [-m MIN_MS] [-u MIN_US] [-a ARGUMENTS] [-T] [-t] [-v] function [function ...]
β¨ DESCRIPTION β¨
So this script watches a kernel or user function's entry and return points π and yells at you with a message whenever the function's latency goes over the threshold you set. You can trace multiple functions at once, and you can even mix kernel functions with user functions from different libraries π§π
WARNING: bestie, see the OVERHEAD section. Seriously, read it π
By default, the minimum threshold is 1 millisecond π Also, recursive functions are not supported. Only the inner-most recursive invocation gets traced π
Since this uses BPF, only the root user can run this tool. No cap, that's the rule ππ
β¨ REQUIREMENTS β¨
You need CONFIG_BPF and bcc. Non-negotiable π«Ά
β¨ OPTIONS β¨
-p PIDβ Only trace this PID. Main character energy π-m MIN_NSβ Minimum duration to trace, in milliseconds. The default is 1 ms β±οΈ-u MIN_USβ Minimum duration to trace, in microseconds. For when 1ms is too chunky π-a ARGUMENTSβ Print the function's arguments, up to 6 β¨-Tβ Print aHH:MM:SStimestamp with each entry π°οΈ-tβ Print a seconds timestamp with each entry, at microsecond resolution π¦-fβ Print the output in folded stack format πΈ-Uβ Show stacks from user space only. No kernel space stacks, bestie π§-Kβ Show stacks from kernel space only. No user space stacks at all π-vβ Print the resulting BPF program. It's for debugging, so it's giving detective π΅οΈββοΈfunctionβ The function to trace. You can pass multiple. If you just give a plain name, it's assumed to be a kernel function. For user functions, give the library name and the function name, likebash:readlineorc:mallocπ
β¨ EXAMPLES β¨
Trace vfs_write calls slower than 1ms:
# funcslower vfs_write
Trace open() calls in libc slower than 10us:
# funcslower -u 10 c:open
Trace both malloc() and free() slower than 10us, in pid 135 only:
# funcslower -p 135 -u 10 c:malloc c:free
Trace the write syscall and print its first 4 arguments:
# funcslower -a 4 SyS_write
Trace opens from libc and print the user and kernel stack frames:
# funcslower -UK c:open
β¨ FIELDS β¨
TIMEβ The time of the event, either as a human-readableHH:MM:SS, or as a seconds timestamp at microsecond accuracy from the first event seen β°COMMβ The process name πPIDβ The process ID πLATβ The latency of the operation, in either microseconds (us) or milliseconds (ms) πRVALβ The return value from the function. Super useful for spotting a relationship between slow calls and failed ones πFUNCβ The function name, followed by its arguments if you asked for them π
β¨ OVERHEAD β¨
Okay this section is the tea β The overhead depends on which function(s) you trace, and it can get severe π
Tracing something common like malloc() can slow a C/C++ program down by a factor of 2 or more π On the flip side, tracing a low-frequency event like the SyS_setreuid() function probably won't be a big deal. It's basically negligible for functions called up to 100-1000 times per second π«§
Before you go wild, use the funclatency and argdist tools for investigation first. They summarize data in-kernel, so they have a way lower overhead than this tool π§ To get a vibe check on how often a function is called (and estimate the overhead), use the funccount tool, like this:
# funccount c:open
β¨ SOURCE β¨
This is from bcc π
https://github.com/iovisor/bcc
Also, look in the bcc distribution for a companion _examples.txt file. It has example usage, output, and commentary for this tool π
β¨ OS β¨
Linux π§
β¨ STABILITY β¨
Unstable, it's still in development π§ Be gentle with it π₯Ί
β¨ AUTHOR β¨
Sasha Goldshtein π
β¨ SEE ALSO β¨
funccount(8), funclatency(8), argdist(8), trace(8) π¦
That's the whole tea, bestie π«Ά This page is from the USER COMMANDS section, dated 2017-03-30, and it's all about funcslower(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 jammy: bpfcc-tools 0.18.0+ds-2 Β· 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