{"id":88,"date":"2025-08-15T11:13:06","date_gmt":"2025-08-15T03:13:06","guid":{"rendered":"http:\/\/www.liumx.com\/?p=88"},"modified":"2025-08-28T15:11:45","modified_gmt":"2025-08-28T07:11:45","slug":"perfetto_chang_yong_cha_xun","status":"publish","type":"post","link":"http:\/\/www.liumx.com\/index.php\/2025\/08\/15\/perfetto_chang_yong_cha_xun\/","title":{"rendered":"perfetto \u5e38\u7528\u67e5\u8be2"},"content":{"rendered":"<p>### \u8fdb\u7a0b\u4e2d\u5404\u7ebf\u7a0b\u4f18\u5148\u7ea7\u67e5\u8be2<br \/>\n&#8220;`<br \/>\nselect process.name as process_name,<br \/>\n       process.pid as process_pid,<br \/>\n       thread.name as thread_name,<br \/>\n       thread.tid,<br \/>\n       sched.priority as priority<br \/>\nfrom sched<br \/>\n    inner join thread using(utid)<br \/>\n    inner join process using(upid)<br \/>\nwhere process.pid in(28058,28011) \/*\u8f93\u5165\u591a\u4e2a\u53c2\u6570*\/<br \/>\ngroup by thread.tid<br \/>\norder by priority<br \/>\n&#8220;`<br \/>\n### \u8fdb\u7a0b\u5728\u5404cpu\u8fd0\u884c\u65f6\u95f4<br \/>\n&#8220;`<br \/>\nselect process.name as process_name,<br \/>\n       process.pid as process_pid,<br \/>\n       sched.cpu,<br \/>\n       sum(sched.dur)\/1e6<br \/>\nfrom sched<br \/>\n    inner join thread using(utid)<br \/>\n    inner join process using(upid)<br \/>\nwhere process.pid in(28058) \/*\u8f93\u5165\u8fdb\u7a0bpid\u53c2\u6570*\/<br \/>\n      and sched.ts>= 16850396073998 and sched.ts <= 16851833181075\/*\u8f93\u5165\u5f00\u59cb\u4e0e\u7ed3\u675f\u65f6\u95f4 eg:16850396073998 \u5f00\u59cb\u65f6\u95f4 16851833181075 \u7ed3\u675f\u65f6\u95f4*\/\ngroup by sched.cpu\norder by sched.cpu \n```\n### \u5404\u7ebf\u7a0bD\u72b6\u6001block_function \u76f8\u5173\u65b9\u6cd5\u7edf\u8ba1\n```\nselect * \nfrom (\n  select process.name as process_name,\n        process.pid as process_pid,\n        thread.name as thread_name,\n        thread.tid as thread_tid,\n        blocked_function,\n        sum(dur)\/1e3 as dur_time_ms\n  from thread_state \n    inner join thread using(utid)\n    inner join process using(upid)\n  where thread.tid in (5593,5594,5595,5596,5597,5598,5599,5600) \/*\u987a\u5e8f\u5199\u7ebf\u7a0b\uff1a5576   \u968f\u673a\u8bfb\u5199\u7ebf\u7a0b\uff1a5593,5594,5595,5596,5597,5598,5599,5600*\/\n        and blocked_function not null \n  group by  blocked_function\n  )\norder by dur_time_ms desc\n```\n\n### \u7edf\u8ba1\u7ebf\u7a0b\u5728\u4e00\u6bb5\u65f6\u95f4\u5185\u5404cpu\u8fd0\u884c\u65f6\u95f4\n```\nselect thread.name as thread_name,\n       thread.tid as thread_tid,\n       sched.cpu as run_cpu_idx ,\n       sum(dur)\/1e6 as run_cpu_duration_ms\nfrom sched \ninner join thread using (utid)\nwhere thread.tid = 13087 \n      and sched.ts >= (113286094474357 -1) and sched.ts <= ( 113286094474357 + 347372616)\ngroup by  thread.tid,sched.cpu\n```\n### \u7edf\u8ba1\u8fdb\u7a0b\u5728\u4e00\u6bb5\u65f6\u95f4\u5185\u5404cpu\u8fd0\u884c\u65f6\u95f4\nselect process.name as process_name,\n       sched.cpu as run_cpu_idx ,\n       sum(dur)\/1e6 as run_cpu_duration_ms\nfrom sched \ninner join thread using (utid)\ninner join process using (upid)\nwhere process.pid = 13087 \n      and sched.ts >= (113286094474357 -1) and sched.ts <= ( 113286094474357 + 347372616)\ngroup by sched.cpu\n\n\n\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>### \u8fdb\u7a0b\u4e2d\u5404\u7ebf\u7a0b\u4f18\u5148\u7ea7\u67e5\u8be2 &#8220;` select process.name as process &#8230; <a title=\"perfetto \u5e38\u7528\u67e5\u8be2\" class=\"read-more\" href=\"http:\/\/www.liumx.com\/index.php\/2025\/08\/15\/perfetto_chang_yong_cha_xun\/\" aria-label=\"\u9605\u8bfb perfetto \u5e38\u7528\u67e5\u8be2\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,10,9],"tags":[],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-android-performance","category-io_xiang_guan","category-xing_neng_gong_ju"],"_links":{"self":[{"href":"http:\/\/www.liumx.com\/index.php\/wp-json\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.liumx.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.liumx.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.liumx.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.liumx.com\/index.php\/wp-json\/wp\/v2\/comments?post=88"}],"version-history":[{"count":12,"href":"http:\/\/www.liumx.com\/index.php\/wp-json\/wp\/v2\/posts\/88\/revisions"}],"predecessor-version":[{"id":189,"href":"http:\/\/www.liumx.com\/index.php\/wp-json\/wp\/v2\/posts\/88\/revisions\/189"}],"wp:attachment":[{"href":"http:\/\/www.liumx.com\/index.php\/wp-json\/wp\/v2\/media?parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.liumx.com\/index.php\/wp-json\/wp\/v2\/categories?post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.liumx.com\/index.php\/wp-json\/wp\/v2\/tags?post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}