btrfsslower(8)
๐ btrfsslower(8) ๐
okay bestie, welcome to the System Manager's Manual page for btrfsslower(8)! ๐ it's the cutest little tracer for finding slow btrfs file ops โจ
โจ NAME โจ
btrfsslower - Trace slow btrfs file operations, with per-event details. ๐
โจ SYNOPSIS โจ
btrfsslower [-h] [-j] [-p PID] [min_ms] [-d DURATION]
โจ DESCRIPTION โจ
okay so this tool traces the common btrfs file operations: reads, writes, opens, and syncs ๐ง It measures how long each one takes and prints the details for any that went over a threshold. main character energy, literally ๐
WARNING: See the OVERHEAD section. ๐
By default the minimum threshold is 10 milliseconds. If you use a threshold of 0, every event gets printed (warning: verbose ๐).
Since this works by tracing the btrfs_file_operations interface functions, it's going to need updating to match any changes to those functions. no cap ๐ซถ
Since this uses BPF, only the root user can use this tool. so be root, bestie ๐
โจ REQUIREMENTS โจ
CONFIG_BPF and bcc. ๐ธ
โจ OPTIONS โจ
-p PIDโ trace this PID only ๐ฏmin_msโ the minimum I/O latency (duration) to trace, in milliseconds. the default is 10 ms โฑ๏ธ-d DURATIONโ the total duration of the trace, in seconds โณ
โจ EXAMPLES โจ
Trace synchronous file reads and writes slower than 10 ms:
# btrfsslower
Trace slower than 1 ms:
# btrfsslower 1
Trace slower than 1 ms, and output just the fields in parsable format (csv):
# btrfsslower -j 1
Trace all file reads and writes (warning: the output will be verbose ๐):
# btrfsslower 0
Trace slower than 1 ms, for PID 181 only:
# btrfsslower -p 181 1
Trace for 10 seconds only:
# btrfsslower -d 10
โจ FIELDS โจ
okay the output columns, let's go ๐
TIME(s)โ time of I/O completion since the first I/O seen, in seconds โฐCOMMโ process name ๐งโ๐ปPIDโ process ID ๐Tโ type of operation.R== read,W== write,O== open,S== fsync ๐คOFF_KBโ file offset for the I/O, in Kbytes ๐ฆBYTESโ size of the I/O, in bytes ๐งฎLAT(ms)โ latency (duration) of the I/O, measured from when VFS issued it to the filesystem, until it completed. this time is inclusive of block device I/O, file system CPU cycles, file system locks, run queue latency, etc. it's a way more accurate measure of the latency apps actually feel doing file system I/O than measuring down at the block device interface. โจFILENAMEโ a cached kernel file name (comes fromdentry->d_name.name) ๐ENDTIME_usโ completion timestamp, in microseconds (-jonly) โOFFSET_bโ file offset, in bytes (-jonly) ๐LATENCY_usโ latency (duration) of the I/O, in microseconds (-jonly) ๐
โจ OVERHEAD โจ
this adds low-overhead instrumentation to btrfs writes and fsyncs, as well as to all system reads and opens (because of how the current btrfs_file_operations interface is implemented). the tricky part: all reads and writes from the file system cache will take extra overhead while tracing. those can be super frequent (depending on the workload, eg, 1M/sec), and at that point the tool's overhead can become noticeable. ๐ญ
so measure and quantify before you use it ๐ if it keeps being a problem, consider switching to a tool that only prints in-kernel summaries, like btrfsdist(8) ๐ฆ
also, the overhead of this tool should be lower than fileslower(8), since this one only targets btrfs functions and not every file read/write path (which can include socket I/O) ๐
โจ SOURCE โจ
this is from bcc ๐ซง
https://github.com/iovisor/bcc
also check out the bcc distribution for a companion _examples.txt file with example usage, output, and commentary for this tool ๐
โจ OS โจ
Linux ๐ง
โจ STABILITY โจ
Unstable - in development. ๐ง
โจ AUTHOR โจ
Brendan Gregg ๐
โจ SEE ALSO โจ
btrfsdist(8), biosnoop(8), funccount(8), fileslower(8) ๐
bestie, that's the whole page! ๐๐ this is from the USER COMMANDS section, dated 2016-02-15, and I'm obsessed that you made it this far ๐ซถโจ
๐ฆ 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