Brendan Gregg | dc642c5 | 2016-02-09 00:32:51 -0800 | [diff] [blame] | 1 | Demonstrations of filelife, the Linux eBPF/bcc version. |
| 2 | |
| 3 | |
| 4 | filelife traces short-lived files: those that have been created and then |
| 5 | deleted while tracing. For example: |
| 6 | |
| 7 | # ./filelife |
| 8 | TIME PID COMM AGE(s) FILE |
| 9 | 05:57:59 8556 gcc 0.04 ccCB5EDe.s |
| 10 | 05:57:59 8560 rm 0.02 .entry_64.o.d |
| 11 | 05:57:59 8563 gcc 0.02 cc5UFHXf.s |
| 12 | 05:57:59 8567 rm 0.01 .thunk_64.o.d |
| 13 | 05:57:59 8578 rm 0.02 .syscall_64.o.d |
| 14 | 05:58:00 8589 rm 0.03 .common.o.d |
| 15 | 05:58:00 8596 rm 0.01 .8592.tmp |
| 16 | 05:58:00 8601 rm 0.01 .8597.tmp |
| 17 | 05:58:00 8606 rm 0.01 .8602.tmp |
| 18 | 05:58:00 8639 rm 0.02 .vma.o.d |
| 19 | 05:58:00 8650 rm 0.02 .vdso32-setup.o.d |
| 20 | 05:58:00 8656 rm 0.00 .vdso.lds.d |
| 21 | 05:58:00 8659 gcc 0.01 ccveeJAz.s |
| 22 | 05:58:00 8663 rm 0.01 .vdso-note.o.d |
| 23 | 05:58:00 8674 rm 0.02 .vclock_gettime.o.d |
| 24 | 05:58:01 8684 rm 0.01 .vgetcpu.o.d |
| 25 | 05:58:01 8690 collect2 0.00 ccvKMxdm.ld |
| 26 | |
| 27 | This has caught short-lived files that were created during a Linux kernel |
| 28 | build. The PID shows the process ID that finally deleted the file, and COMM |
| 29 | is its process name. The AGE(s) column shows the age of the file, in seconds, |
| 30 | when it was deleted. These are all short-lived, and existed for less than |
| 31 | one tenth of a second. |
| 32 | |
| 33 | Creating, populating, and then deleting files as part of another process can |
| 34 | be an inefficient method of inter-process communication. It can cause disk I/O |
| 35 | as files are closed and their file descriptors flushed, only later to be |
| 36 | deleted. As such, short-lived files can be a target of performance |
| 37 | optimizations. |
| 38 | |
| 39 | USAGE message: |
| 40 | |
| 41 | # ./filelife -h |
| 42 | usage: filelife [-h] [-p PID] |
| 43 | |
| 44 | Trace stat() syscalls |
| 45 | |
| 46 | optional arguments: |
| 47 | -h, --help show this help message and exit |
| 48 | -p PID, --pid PID trace this PID only |
| 49 | |
| 50 | examples: |
| 51 | ./filelife # trace all stat() syscalls |
| 52 | ./filelife -p 181 # only trace PID 181 |