1*288bf522SAndroid Build Coastguard WorkerWhat is it ? 2*288bf522SAndroid Build Coastguard Worker---------- 3*288bf522SAndroid Build Coastguard Workerioblame is a IO profiler. It gives a detailed listing of the list of 4*288bf522SAndroid Build Coastguard Workerfiles that running pids are doing IO to (with the aggregate amount of 5*288bf522SAndroid Build Coastguard Workerread/write to each file). The goal is that using this tool, app 6*288bf522SAndroid Build Coastguard Workerdevelopers can identify IO heavy paths, and tune them, then 7*288bf522SAndroid Build Coastguard Workeriteratively run this tool again to measure improvements/IO reduction. 8*288bf522SAndroid Build Coastguard Worker 9*288bf522SAndroid Build Coastguard Workerioblame is implemented as a collection of kernel filesystem 10*288bf522SAndroid Build Coastguard Workertracepoints, and a script. 11*288bf522SAndroid Build Coastguard Worker 12*288bf522SAndroid Build Coastguard WorkerWhat does the output from ioblame look like ? 13*288bf522SAndroid Build Coastguard Worker------------------------------------------- 14*288bf522SAndroid Build Coastguard Workerioblame gives 2 different views. 15*288bf522SAndroid Build Coastguard Worker 16*288bf522SAndroid Build Coastguard WorkerFile view is the default. 17*288bf522SAndroid Build Coastguard Worker 18*288bf522SAndroid Build Coastguard Worker1) File view : For each file, it gives a list of pids that are doing 19*288bf522SAndroid Build Coastguard WorkerIO on that file (it also gives the amount of IO each pid does and 20*288bf522SAndroid Build Coastguard Workerthe aggregate amount of IO done to the file by all pids). 21*288bf522SAndroid Build Coastguard Worker 22*288bf522SAndroid Build Coastguard WorkerFile: /app/Chrome/Chrome.apk 23*288bf522SAndroid Build Coastguard Worker Chrome_ChildIOT Reads: 96 KB 24*288bf522SAndroid Build Coastguard Worker Chrome_DBThread Reads: 652 KB 25*288bf522SAndroid Build Coastguard Worker Chrome_FileUser Reads: 72 KB 26*288bf522SAndroid Build Coastguard Worker Chrome_InProcGp Reads: 732 KB 27*288bf522SAndroid Build Coastguard Worker Chrome_IOThread Reads: 1396 KB 28*288bf522SAndroid Build Coastguard Worker Compositor Reads: 652 KB 29*288bf522SAndroid Build Coastguard Worker CookieMonsterBa Reads: 284 KB 30*288bf522SAndroid Build Coastguard Worker CrRendererMain Reads: 17012 KB 31*288bf522SAndroid Build Coastguard Worker dboxed_process0 Reads: 512 KB 32*288bf522SAndroid Build Coastguard Worker JavaBridge Reads: 128 KB 33*288bf522SAndroid Build Coastguard Worker ogle.android.gm Reads: 14996 KB 34*288bf522SAndroid Build Coastguard Worker WorkerPool/8556 Reads: 408 KB 35*288bf522SAndroid Build Coastguard Worker Total Reads: 36940 KB i_size: 71354 KB 36*288bf522SAndroid Build Coastguard WorkerFile: /app/Gmail2Light/Gmail2Light.apk 37*288bf522SAndroid Build Coastguard Worker AsyncTask_#2 Reads: 24 KB 38*288bf522SAndroid Build Coastguard Worker Chrome_IOThread Reads: 68 KB 39*288bf522SAndroid Build Coastguard Worker ogle.android.gm Reads: 1440 KB 40*288bf522SAndroid Build Coastguard Worker Thread-6 Reads: 8 KB 41*288bf522SAndroid Build Coastguard Worker Total Reads: 1540 KB i_size: 9736 KB 42*288bf522SAndroid Build Coastguard Worker 43*288bf522SAndroid Build Coastguard WorkerAnd ditto for writes. 44*288bf522SAndroid Build Coastguard Worker 45*288bf522SAndroid Build Coastguard WorkerTo enable PID view, use -v 46*288bf522SAndroid Build Coastguard Worker 47*288bf522SAndroid Build Coastguard WorkerPID: CrRendererMain 48*288bf522SAndroid Build Coastguard Worker /app/Chrome/Chrome.apk Reads: 17012 KB i_size: 71354 KB 49*288bf522SAndroid Build Coastguard Worker /etc/fonts.xml Reads: 24 KB i_size: 22 KB 50*288bf522SAndroid Build Coastguard Worker /fonts/CarroisGothicSC-Regular.ttf Reads: 40 KB i_size: 39 KB 51*288bf522SAndroid Build Coastguard Worker /fonts/ComingSoon.ttf Reads: 60 KB i_size: 57 KB 52*288bf522SAndroid Build Coastguard Worker /fonts/CutiveMono.ttf Reads: 68 KB i_size: 67 KB 53*288bf522SAndroid Build Coastguard Worker /fonts/DancingScript-Bold.ttf Reads: 116 KB i_size: 112 KB 54*288bf522SAndroid Build Coastguard Worker /fonts/DancingScript-Regular.ttf Reads: 116 KB i_size: 113 KB 55*288bf522SAndroid Build Coastguard Worker /fonts/DroidSansMono.ttf Reads: 108 KB i_size: 105 KB 56*288bf522SAndroid Build Coastguard Worker /fonts/NotoColorEmoji.ttf Reads: 204 KB i_size: 7108 KB 57*288bf522SAndroid Build Coastguard Worker /fonts/NotoNaskhArabic-Bold.ttf Reads: 116 KB i_size: 113 KB 58*288bf522SAndroid Build Coastguard Worker,,, 59*288bf522SAndroid Build Coastguard Worker /fonts/NotoSerif-BoldItalic.ttf Reads: 248 KB i_size: 256 KB 60*288bf522SAndroid Build Coastguard Worker /fonts/NotoSerif-Bold.ttf Reads: 244 KB i_size: 242 KB 61*288bf522SAndroid Build Coastguard Worker /fonts/NotoSerif-Italic.ttf Reads: 244 KB i_size: 243 KB 62*288bf522SAndroid Build Coastguard Worker /fonts/NotoSerif-Regular.ttf Reads: 244 KB i_size: 240 KB 63*288bf522SAndroid Build Coastguard Worker /fonts/Roboto-BlackItalic.ttf Reads: 256 KB i_size: 322 KB 64*288bf522SAndroid Build Coastguard Worker /fonts/Roboto-Black.ttf Reads: 256 KB i_size: 299 KB 65*288bf522SAndroid Build Coastguard Worker /fonts/Roboto-BoldItalic.ttf Reads: 256 KB i_size: 324 KB 66*288bf522SAndroid Build Coastguard Worker /fonts/RobotoCondensed-BoldItalic.ttf Reads: 256 KB i_size: 322 KB 67*288bf522SAndroid Build Coastguard Worker /fonts/RobotoCondensed-Bold.ttf Reads: 256 KB i_size: 296 KB 68*288bf522SAndroid Build Coastguard Worker /fonts/RobotoCondensed-Italic.ttf Reads: 256 KB i_size: 321 KB 69*288bf522SAndroid Build Coastguard Worker /fonts/RobotoCondensed-LightItalic.ttf Reads: 256 KB i_size: 324 KB 70*288bf522SAndroid Build Coastguard Worker /fonts/RobotoCondensed-Light.ttf Reads: 256 KB i_size: 295 KB 71*288bf522SAndroid Build Coastguard Worker /fonts/RobotoCondensed-MediumItalic.ttf Reads: 256 KB i_size: 322 KB 72*288bf522SAndroid Build Coastguard Worker /fonts/RobotoCondensed-Medium.ttf Reads: 256 KB i_size: 296 KB 73*288bf522SAndroid Build Coastguard Worker /fonts/Roboto-LightItalic.ttf Reads: 256 KB i_size: 324 KB 74*288bf522SAndroid Build Coastguard Worker /fonts/Roboto-MediumItalic.ttf Reads: 256 KB i_size: 323 KB 75*288bf522SAndroid Build Coastguard Worker /fonts/Roboto-Regular.ttf Reads: 88 KB i_size: 298 KB 76*288bf522SAndroid Build Coastguard Worker /fonts/Roboto-ThinItalic.ttf Reads: 256 KB i_size: 321 KB 77*288bf522SAndroid Build Coastguard Worker /fonts/Roboto-Thin.ttf Reads: 256 KB i_size: 300 KB 78*288bf522SAndroid Build Coastguard Worker /lib/libft2.so Reads: 56 KB i_size: 479 KB 79*288bf522SAndroid Build Coastguard Worker /lib/libicuuc.so Reads: 88 KB i_size: 1182 KB 80*288bf522SAndroid Build Coastguard Worker Total Reads: 32760 KB 81*288bf522SAndroid Build Coastguard Worker 82*288bf522SAndroid Build Coastguard WorkerAnd ditto for writes. 83*288bf522SAndroid Build Coastguard Worker 84*288bf522SAndroid Build Coastguard WorkerFor the -p, writepages option, ioblame does not (and cannot) give you 85*288bf522SAndroid Build Coastguard Workerthe app/pid that did the original write (since the write most likely 86*288bf522SAndroid Build Coastguard Workerhappens from a flush thread or VM reclaim). In this mode, we only get 87*288bf522SAndroid Build Coastguard Workerthe pathname of the file and the amount of data written out. 88*288bf522SAndroid Build Coastguard Worker 89*288bf522SAndroid Build Coastguard WorkerFinally, it reports the total amount of file data IO done by pids and 90*288bf522SAndroid Build Coastguard Workerthe total IO done to the block device. So we can look at IO overheads 91*288bf522SAndroid Build Coastguard Worker(eg block level prefetching, filesystem metadata overhead etc). 92*288bf522SAndroid Build Coastguard Worker 93*288bf522SAndroid Build Coastguard WorkerFor detailed examples, look at ioblame-gmail-launch.example and 94*288bf522SAndroid Build Coastguard Workerioblame-gmail-run.example. 95*288bf522SAndroid Build Coastguard Worker 96*288bf522SAndroid Build Coastguard WorkerHow do I run ioblame ? 97*288bf522SAndroid Build Coastguard Worker-------------------- 98*288bf522SAndroid Build Coastguard Workerioblame -r [ I am only interested in reads ] 99*288bf522SAndroid Build Coastguard Workerioblame -w [ I am only interested in writes ] 100*288bf522SAndroid Build Coastguard Workerioblame -p [ I am only interested in writepage(s) - mmap'ed writes ] 101*288bf522SAndroid Build Coastguard Workerioblame -r -w -p [ I am only interested in reads, writes and writepages ] 102*288bf522SAndroid Build Coastguard Workerand finally, -v adds the PID view 103*288bf522SAndroid Build Coastguard Worker 104*288bf522SAndroid Build Coastguard Worker1) The most common way of running ioblame is to start ioblame, then go 105*288bf522SAndroid Build Coastguard Workeroff and launch the app(s) of interest, do interesting stuff with the 106*288bf522SAndroid Build Coastguard Workerapp(s), and when finished with the app, hit ^C ONCE on 107*288bf522SAndroid Build Coastguard Workerioblame. Hitting ^C once will cause ioblame to catch the signal, break 108*288bf522SAndroid Build Coastguard Workerout of the sleep, terminate its tracing, and process the ftraces and 109*288bf522SAndroid Build Coastguard Workerdump out IO stats for the app. 110*288bf522SAndroid Build Coastguard Worker 111*288bf522SAndroid Build Coastguard Workerexample : 112*288bf522SAndroid Build Coastguard Worker 113*288bf522SAndroid Build Coastguard Workersrmohan0.mtv.corp.google.com> sh ioblame.sh -r -w -p 114*288bf522SAndroid Build Coastguard WorkerFound aosp_gobo Device 115*288bf522SAndroid Build Coastguard WorkerOK to kill sleep when test is done 116*288bf522SAndroid Build Coastguard Worker^Csignal INT received, killing streaming trace capture 117*288bf522SAndroid Build Coastguard Worker 118*288bf522SAndroid Build Coastguard Worker(at this point, run your apps, when done type ^C ONCE) and output will 119*288bf522SAndroid Build Coastguard Workerappear on stdout. 120*288bf522SAndroid Build Coastguard Worker 121*288bf522SAndroid Build Coastguard Worker2) Sometimes, we want to do IO profiling in a different way (instead of 122*288bf522SAndroid Build Coastguard Workerrunning something and then hitting ^C on ioblame). For instance, we 123*288bf522SAndroid Build Coastguard Workermight want to do IO profiling related to the launch of an App. This 124*288bf522SAndroid Build Coastguard Workerrequires you to modify the script slightly, as described in the next 125*288bf522SAndroid Build Coastguard Workerparagraph. 126*288bf522SAndroid Build Coastguard Worker 127*288bf522SAndroid Build Coastguard WorkerIf you want to do IO profiling related to App launch, you need to modify 128*288bf522SAndroid Build Coastguard Worker2 functions - prep_to_do_something and do_something. Again examples of 129*288bf522SAndroid Build Coastguard Workerchanges to these functions clarifies things better : 130*288bf522SAndroid Build Coastguard Worker 131*288bf522SAndroid Build Coastguard Workerprep_to_do_something() { 132*288bf522SAndroid Build Coastguard Worker adb shell "am force-stop com.google.android.gm" # This line I added for example 133*288bf522SAndroid Build Coastguard Worker # stops the running app (gmail) 134*288bf522SAndroid Build Coastguard Worker adb shell 'echo 3 > /proc/sys/vm/drop_caches' 135*288bf522SAndroid Build Coastguard Worker sleep 1 136*288bf522SAndroid Build Coastguard Worker} 137*288bf522SAndroid Build Coastguard Worker 138*288bf522SAndroid Build Coastguard Workerdo_something() { 139*288bf522SAndroid Build Coastguard Worker # Arrange things so that the first SIGINT will kill the 140*288bf522SAndroid Build Coastguard Worker # child process (sleep), but will return to the parent. 141*288bf522SAndroid Build Coastguard Worker# trap 'catch_sigint' INT 142*288bf522SAndroid Build Coastguard Worker# echo "OK to kill sleep when test is done" 143*288bf522SAndroid Build Coastguard Worker# sleep 1d 144*288bf522SAndroid Build Coastguard Worker # For the purpose of this example, I commented out the above 3 lines that 145*288bf522SAndroid Build Coastguard Worker # make ioblame sleep forever after catching the SIGINT and instead it launches 146*288bf522SAndroid Build Coastguard Worker # gmail, waiting for launch to complete. When launch completes, ioblame will 147*288bf522SAndroid Build Coastguard Worker # stop tracing, and process the traces 148*288bf522SAndroid Build Coastguard Worker adb shell "am start -W -n com.google.android.gm/.ConversationListActivityGmail" 149*288bf522SAndroid Build Coastguard Worker} 150*288bf522SAndroid Build Coastguard Worker 151*288bf522SAndroid Build Coastguard WorkerLimitations : 152*288bf522SAndroid Build Coastguard Worker----------- 153*288bf522SAndroid Build Coastguard WorkerThe ioblame kernel tracepoints currently only cover the getpage(s) 154*288bf522SAndroid Build Coastguard Workerpath (so all filesystem reads) and filesystem write() syscalls. There 155*288bf522SAndroid Build Coastguard Workerare no tracepoints in the putpage(s) paths. This is because when 156*288bf522SAndroid Build Coastguard Workerputpage(s) is called, we most often cannot tell which thread/pid has 157*288bf522SAndroid Build Coastguard Workerdirtied the page that is being written out, because the majority of 158*288bf522SAndroid Build Coastguard Workerputpage(s) happen from the flush threads or from the pageout 159*288bf522SAndroid Build Coastguard Workerthreads. The upshot of this is the mmap'ed writes are not reported by 160*288bf522SAndroid Build Coastguard Workerioblame. In practice, while mmap'ed reads are very common, mmap'ed 161*288bf522SAndroid Build Coastguard Workerwrites are infrequent. 162*288bf522SAndroid Build Coastguard Worker 163*288bf522SAndroid Build Coastguard WorkerKernel Patches Required : 164*288bf522SAndroid Build Coastguard Worker----------------------- 165*288bf522SAndroid Build Coastguard Workerioblame needs the kernel to be patched with these 3 kernel patches. 166*288bf522SAndroid Build Coastguard WorkerWithout these patches, ioblame won't work at all. 167*288bf522SAndroid Build Coastguard Worker 168*288bf522SAndroid Build Coastguard Workercommit ae2f6765db98e2fcb99082e336dd8b24e7644620 169*288bf522SAndroid Build Coastguard WorkerAuthor: Mohan Srinivasan <[email protected]> 170*288bf522SAndroid Build Coastguard WorkerDate: Fri Mar 10 16:08:30 2017 -0800 171*288bf522SAndroid Build Coastguard Worker 172*288bf522SAndroid Build Coastguard Worker ANDROID: Replace spaces by '_' for some android filesystem tracepoints. 173*288bf522SAndroid Build Coastguard Worker 174*288bf522SAndroid Build Coastguard Worker Andoid files frequently have spaces in them, as do cmdline strings. 175*288bf522SAndroid Build Coastguard Worker Replace these spaces with '_', so tools that parse these tracepoints 176*288bf522SAndroid Build Coastguard Worker don't get terribly confused. 177*288bf522SAndroid Build Coastguard Worker 178*288bf522SAndroid Build Coastguard Worker Change-Id: I1cbbedf5c803aa6a58d9b8b7836e9125683c49d1 179*288bf522SAndroid Build Coastguard Worker Signed-off-by: Mohan Srinivasan <[email protected]> 180*288bf522SAndroid Build Coastguard Worker (cherry picked from commit 5035d5f0933758dd515327d038e5bef7e40dbaa7) 181*288bf522SAndroid Build Coastguard Worker 182*288bf522SAndroid Build Coastguard Workercommit a2a04ea83d2960867324fa059ba1eedc2fc7784e (HEAD -> android-4.4) 183*288bf522SAndroid Build Coastguard WorkerAuthor: Mohan Srinivasan <[email protected]> 184*288bf522SAndroid Build Coastguard WorkerDate: Fri Feb 3 15:48:03 2017 -0800 185*288bf522SAndroid Build Coastguard Worker 186*288bf522SAndroid Build Coastguard Worker ANDROID: Refactor fs readpage/write tracepoints. 187*288bf522SAndroid Build Coastguard Worker 188*288bf522SAndroid Build Coastguard Worker Refactor the fs readpage/write tracepoints to move the 189*288bf522SAndroid Build Coastguard Worker inode->path lookup outside the tracepoint code, and pass a pointer 190*288bf522SAndroid Build Coastguard Worker to the path into the tracepoint code instead. This is necessary 191*288bf522SAndroid Build Coastguard Worker because the tracepoint code runs non-preemptible. Thanks to 192*288bf522SAndroid Build Coastguard Worker Trilok Soni for catching this in 4.4. 193*288bf522SAndroid Build Coastguard Worker 194*288bf522SAndroid Build Coastguard Worker Change-Id: I7486c5947918d155a30c61d6b9cd5027cf8fbe15 195*288bf522SAndroid Build Coastguard Worker Signed-off-by: Mohan Srinivasan <[email protected]> 196*288bf522SAndroid Build Coastguard Worker 197*288bf522SAndroid Build Coastguard Workercommit 32cbbe59538d2dd0b77822cc27ce32ca487c467d 198*288bf522SAndroid Build Coastguard WorkerAuthor: Mohan Srinivasan <[email protected]> 199*288bf522SAndroid Build Coastguard WorkerDate: Mon Sep 19 17:33:50 2016 -0700 200*288bf522SAndroid Build Coastguard Worker 201*288bf522SAndroid Build Coastguard Worker ANDROID: fs: FS tracepoints to track IO. 202*288bf522SAndroid Build Coastguard Worker 203*288bf522SAndroid Build Coastguard Worker Adds tracepoints in ext4/f2fs/mpage to track readpages/buffered 204*288bf522SAndroid Build Coastguard Worker write()s. This allows us to track files that are being read/written 205*288bf522SAndroid Build Coastguard Worker to PIDs. 206*288bf522SAndroid Build Coastguard Worker 207*288bf522SAndroid Build Coastguard Worker Change-Id: I26bd36f933108927d6903da04d8cb42fd9c3ef3d 208*288bf522SAndroid Build Coastguard Worker Signed-off-by: Mohan Srinivasan <[email protected]> 209*288bf522SAndroid Build Coastguard Worker 210*288bf522SAndroid Build Coastguard WorkerThe -w (writepages) option requires this additional patch and 211*288bf522SAndroid Build Coastguard Workercurrently only with f2fs. 212*288bf522SAndroid Build Coastguard Worker 213*288bf522SAndroid Build Coastguard Workercommit c60bc59c6af4fbdeaf7bbeaebee6b55d9e488324 (HEAD -> 214*288bf522SAndroid Build Coastguard Workerandroid-mtk-gobo-3.18) 215*288bf522SAndroid Build Coastguard WorkerAuthor: Mohan Srinivasan <[email protected]> 216*288bf522SAndroid Build Coastguard WorkerDate: Fri Sep 8 13:53:01 2017 -0700 217*288bf522SAndroid Build Coastguard Worker 218*288bf522SAndroid Build Coastguard Worker Tracepoints in f2fs data writepage(s). 219*288bf522SAndroid Build Coastguard Worker 220*288bf522SAndroid Build Coastguard Worker Tracepoints f2fs writepage(s). This is experimental (for now). 221*288bf522SAndroid Build Coastguard Worker Allowing ioblame to track <pathname, amount of data written> 222*288bf522SAndroid Build Coastguard Worker for files. 223*288bf522SAndroid Build Coastguard Worker 224*288bf522SAndroid Build Coastguard Worker Signed-off-by: Mohan Srinivasan <[email protected]> 225*288bf522SAndroid Build Coastguard Worker Change-Id: I4c76c6f442e0a2c5872225f8113935f9f368cc64 226