{"id":139,"date":"2010-10-17T17:21:46","date_gmt":"2010-10-17T15:21:46","guid":{"rendered":"http:\/\/eguaj.tumblr.com\/post\/1336333060"},"modified":"2010-10-17T17:21:46","modified_gmt":"2010-10-17T15:21:46","slug":"1336333060","status":"publish","type":"post","link":"https:\/\/locallost.net\/?p=139","title":{"rendered":"Identifying constant disk writes on Mac OS X"},"content":{"rendered":"<p>A couple of month ago, I noticed that I was having a constant stream of disk write of about 1MB\/s on my MacBook (as seen in Activity Monitor.app). That would eventually drain my battery faster when running unplugged.<\/p>\n<p>First thing to do was to identify the culprit, the process, that generate those writes.<\/p>\n<p>As I'm not familiar with the BSD sub-system internals, I Googled and found a list of DTrace one-liners that proved to be handy:<\/p>\n<p>&#8211;\u00a0<a title=\"http:\/\/www.brendangregg.com\/DTrace\/dtrace_oneliners.txt\" href=\"http:\/\/www.brendangregg.com\/DTrace\/dtrace_oneliners.txt\"><a href=\"http:\/\/www.brendangregg.com\/DTrace\/dtrace_oneliners.txt\">http:\/\/www.brendangregg.com\/DTrace\/dtrace_oneliners.txt<\/a><\/a><\/p>\n<p>The first one:<\/p>\n<pre># dtrace -n 'io:::start { printf(\"%d %s %d\",pid,execname,args[0]-&gt;b_bcount); }'<\/pre>\n<p>It shows you the names of the process doing I\/O operations.<\/p>\n<p>From the result I immediatly spotted a process from Postgresql that was generating a fair amount of I\/O while no queries\/vacuum where running.<\/p>\n<p>Now, I know the source might be in Postgresql, but what was happenning? what files were concerned by theses I\/O?<\/p>\n<p>I needed to know what files where opened, so this DTrace gave me the next answer&#160;:<\/p>\n<pre>#\u00a0dtrace -n 'syscall::open*:entry { printf(\"%s %s\", execname, copyinstr(arg0) ); }'<\/pre>\n<p>This one prints the name of the files being opened by the running processes&#160;:<\/p>\n<pre>\u00a0\u00a00 \u00a018514 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0open_nocancel:entry postgres global\/pg_database\n\u00a0\u00a00 \u00a018514 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0open_nocancel:entry postgres pg_stat_tmp\/pgstat.stat\n\u00a0\u00a00 \u00a018514 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0open_nocancel:entry postgres pg_stat_tmp\/pgstat.stat\n\u00a0\u00a01 \u00a017728 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0    open:entry mdworker \/.vol\/234881026\/52307726\/\/Contents\/PkgInfo\n\u00a0\u00a01 \u00a017728 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0    open:entry mdworker \/opt\/local\/var\/db\/postgresql84\/defaultdb\/pg_stat_tmp\/pgstat.stat\n\u00a0\u00a01 \u00a017728 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0    open:entry mds .\n\u00a0\u00a00 \u00a018514 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0open_nocancel:entry postgres pg_stat_tmp\/pgstat.stat\n\u00a0\u00a00 \u00a018514 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0open_nocancel:entry postgres pg_stat_tmp\/pgstat.stat\n\u00a0\u00a00 \u00a018514 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0open_nocancel:entry postgres pg_stat_tmp\/pgstat.stat\n<\/pre>\n<p>From this output, I found that it would be related to the pg_stat mecanism.<\/p>\n<p>I edited the `postgresql.conf' file and disabled the stat collection by setting:<\/p>\n<pre>track_activities = off\ntrack_counts = off\n<\/pre>\n<p>Then, after restarting postgresql, the continuous flow of writes was gone.<\/p>\n<p>Thank you DTrace!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A couple of month ago, I noticed that I was having a constant stream of disk write of about 1MB\/s on my MacBook (as seen in Activity Monitor.app). That would eventually drain my battery faster when running unplugged. First thing &hellip; <a href=\"https:\/\/locallost.net\/?p=139\">Continuer la lecture <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[10],"tags":[],"class_list":["post-139","post","type-post","status-publish","format-standard","hentry","category-regular"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p2Bei9-2f","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/posts\/139","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/locallost.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=139"}],"version-history":[{"count":0,"href":"https:\/\/locallost.net\/index.php?rest_route=\/wp\/v2\/posts\/139\/revisions"}],"wp:attachment":[{"href":"https:\/\/locallost.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=139"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/locallost.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=139"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/locallost.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=139"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}