{"id":76,"date":"2012-04-24T05:07:24","date_gmt":"2012-04-24T05:07:24","guid":{"rendered":"http:\/\/finaldie.com\/wordpress\/?p=76"},"modified":"2013-01-27T08:24:34","modified_gmt":"2013-01-27T08:24:34","slug":"profile-with-oprofile","status":"publish","type":"post","link":"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/","title":{"rendered":"Profile with oprofile"},"content":{"rendered":"<h1>SUMMARY<\/h1>\n<p>After my previous article of how to profile a program with gprof, I think many guys has recognize the importance of profile.\u00a0Today the new blog for introducing how to profile a program with <strong><a href=\"http:\/\/oprofile.sourceforge.net\/news\/\" target=\"_blank\">oprofile<\/a><\/strong>.<\/p>\n<h1>Why oprofile<\/h1>\n<p>Many guys may asked why oprofile? There is gprof we can use. Ok, cool down, I&#8217;ll take a little time to explain why do this. As we know, gprof has some\u00a0defects, which can not profile a program in the some scenes(See <a href=\"http:\/\/finaldie.com\/wordpress\/?p=70\" target=\"_blank\">detail<\/a>). So, in a given scene, when a daemon program and you has no\u00a0permission to\u00a0re-compile it. So, what would you do this? The answer is that gprof cannot do this. Because without re-compile it with &#8220;-pg&#8221;, the program cannot generate a &#8220;gmon.out&#8221; result file. And another reason is that your program will run very slowly, since you re-compile with &#8220;-pg&#8221;, you may cannot find the correct hot point. So, you need a tool, which can do profile at runtime and run as fast as possible, for lucky, oprofile can do it.<\/p>\n<h1>How to<\/h1>\n<p>Let&#8217;s go forward to doing it as fast as we can, I think most of guys hate reading a long article, especially the\u00a0redundancy one. Ok, drop it, free your mind and follow me to take a look at what we have to.<\/p>\n<h2>Work flow<\/h2>\n<ul>\n<li>First, you need to download or apt-get or yum to install oprofile.<\/li>\n<li>opcontrol &#8211;vmlinux=\/path\/vmlinux &#8211;start<\/li>\n<li>run your program<\/li>\n<li>opcontrol &#8211;stop<\/li>\n<li>opcontrol &#8211;dump<\/li>\n<li>opreport -cfg | <a href=\"http:\/\/code.google.com\/p\/jrfonseca\/wiki\/Gprof2Dot#Profiling_tools\" target=\"_blank\">gpref2dot.py<\/a> -f oprofile | dot -Tpng -o out.png<\/li>\n<\/ul>\n<p>Ok, now you can open the out.png to research, the call graph, hot point function in it.<\/p>\n<h1>CONCLUSION<\/h1>\n<p>So that&#8217;s also simple, isn&#8217;t it? But these are some notes you need to know before you want to try it:<\/p>\n<ul>\n<li>oprofile need kernel support, that means you may not run it sucessful in some kernel, such as redhat. In this case, you need to find the specify oprofile release for redhat.<\/li>\n<li>oprofile is the kernel level tool of profile.<\/li>\n<li>oprofile can do profile at runtime without any compile step.<\/li>\n<li>If you cannot find your &#8220;vmlinux&#8221; image, you may need to specify the &#8211;no-vmlinux argument or download your kernel image for skipping that error.<\/li>\n<li>Compile your program with &#8220;-g&#8221; is necessary or you won&#8217;t see any useful graph.<\/li>\n<li>Use &#8211;callgraph argument in some scenes, which your program will call in nest.<\/li>\n<li>Use &#8211;separate argument when you want to see the information\u00a0more clearly. Specify the multiple threads program.<\/li>\n<\/ul>\n<p>Ok, there are a lot of features you need to find out. Have a fun to try it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SUMMARY After my previous article of how to profile a program with gprof, I think many guys has recognize the importance of profile.\u00a0Today the new blog for introducing how to profile a program with oprofile. Why oprofile Many guys may asked why oprofile? There is gprof we can use. Ok, cool down, I&#8217;ll take a &#8230; <a title=\"Profile with oprofile\" class=\"read-more\" href=\"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/\" aria-label=\"More on Profile with oprofile\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Profile with oprofile - Final Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Profile with oprofile - Final Blog\" \/>\n<meta property=\"og:description\" content=\"SUMMARY After my previous article of how to profile a program with gprof, I think many guys has recognize the importance of profile.\u00a0Today the new blog for introducing how to profile a program with oprofile. Why oprofile Many guys may asked why oprofile? There is gprof we can use. Ok, cool down, I&#8217;ll take a ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/\" \/>\n<meta property=\"og:site_name\" content=\"Final Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/hu.yuzhang\" \/>\n<meta property=\"article:published_time\" content=\"2012-04-24T05:07:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2013-01-27T08:24:34+00:00\" \/>\n<meta name=\"author\" content=\"final\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hyzwowtools\" \/>\n<meta name=\"twitter:site\" content=\"@hyzwowtools\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"final\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/\",\"url\":\"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/\",\"name\":\"Profile with oprofile - Final Blog\",\"isPartOf\":{\"@id\":\"https:\/\/finaldie.com\/blog\/#website\"},\"datePublished\":\"2012-04-24T05:07:24+00:00\",\"dateModified\":\"2013-01-27T08:24:34+00:00\",\"author\":{\"@id\":\"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3\"},\"breadcrumb\":{\"@id\":\"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/finaldie.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Profile with oprofile\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/finaldie.com\/blog\/#website\",\"url\":\"https:\/\/finaldie.com\/blog\/\",\"name\":\"Final Blog\",\"description\":\"As simple as possible...\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/finaldie.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3\",\"name\":\"final\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/finaldie.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g\",\"caption\":\"final\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Profile with oprofile - Final Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/","og_locale":"en_US","og_type":"article","og_title":"Profile with oprofile - Final Blog","og_description":"SUMMARY After my previous article of how to profile a program with gprof, I think many guys has recognize the importance of profile.\u00a0Today the new blog for introducing how to profile a program with oprofile. Why oprofile Many guys may asked why oprofile? There is gprof we can use. Ok, cool down, I&#8217;ll take a ... Read more","og_url":"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/","og_site_name":"Final Blog","article_publisher":"https:\/\/www.facebook.com\/hu.yuzhang","article_published_time":"2012-04-24T05:07:24+00:00","article_modified_time":"2013-01-27T08:24:34+00:00","author":"final","twitter_card":"summary_large_image","twitter_creator":"@hyzwowtools","twitter_site":"@hyzwowtools","twitter_misc":{"Written by":"final","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/","url":"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/","name":"Profile with oprofile - Final Blog","isPartOf":{"@id":"https:\/\/finaldie.com\/blog\/#website"},"datePublished":"2012-04-24T05:07:24+00:00","dateModified":"2013-01-27T08:24:34+00:00","author":{"@id":"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3"},"breadcrumb":{"@id":"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/finaldie.com\/blog\/profile-with-oprofile\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/finaldie.com\/blog\/profile-with-oprofile\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/finaldie.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Profile with oprofile"}]},{"@type":"WebSite","@id":"https:\/\/finaldie.com\/blog\/#website","url":"https:\/\/finaldie.com\/blog\/","name":"Final Blog","description":"As simple as possible...","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/finaldie.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/finaldie.com\/blog\/#\/schema\/person\/2d4c840d6e8e197f8ade98af2bd2fab3","name":"final","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/finaldie.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4c720545b79ddb0f23b527e0bbcfd9bc?s=96&r=g","caption":"final"}}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts\/76"}],"collection":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/comments?post=76"}],"version-history":[{"count":4,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":79,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/posts\/76\/revisions\/79"}],"wp:attachment":[{"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/media?parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/categories?post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/finaldie.com\/blog\/wp-json\/wp\/v2\/tags?post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}