在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

如何使用OFF-CPU火焰圖調查分析Linux性能問題概述

Linux閱碼場 ? 來源:未知 ? 2018-12-23 13:47 ? 次閱讀

本文用off-cpu火焰圖分析一個程序的延遲(主要在拿鎖上),找出來瓶頸,并消除的故事。本文非常值得一讀,但是閱碼場沒有足夠的時間將其翻譯為中文,希望童鞋們直接讀英文。

The Setup

As a performance engineer at MemSQL, one of my primary responsibilities is to ensure that customer Proof of Concepts (POCs) run smoothly. I was recently asked to assist with a big POC, where I was surprised to encounter an uncommon Linux performance issue. I was running a synthetic workload of 16 threads (one for each CPU core). Each one simultaneously executed a very simple query (select count(*) from t where i > 5) against a columnstore table.

In theory, this ought to be a CPU bound operation since it would be reading from a file that was already in disk buffer cache. In practice, our cores were spending about 50% of their time idle

In this post, I’ll walk through some of the debugging techniques and reveal exactly how we reached resolution.

What were our threads doing?

After confirming that our workload was indeed using 16 threads, I looked at the state of our various threads. In every refresh of myhtopwindow, I saw that a handful of threads were in theDstate corresponding to “Uninterruptible sleep”:

Why were we going off CPU?

At this point, I generated anoff-cpu flamegraphusing Linuxperf_eventsto see why we entered this state.Off-CPUmeans that instead of looking at what is keeping the CPU busy, you look at what is preventing it from being busy by things happening elsewhere (e.g. waiting for IO or a lock). The normal way to generate these visualizations is to useperf inject -s, but the machine I tested on did not have a new enough version ofperf. Instead I had to use anawkscriptI had previously written:

$ sudoperfrecord --call-graph=fp -e 'sched:sched_switch' -e 'sched:sched_stat_sleep' -e 'sched:sched_stat_blocked' --pid $(pgrep memsqld | head -n 1) -- sleep 1

[ perf record: Woken up 1 times to write data ]

[ perf record: Captured and wrote 1.343 MB perf.data (~58684 samples) ]

$ sudoperfscript -f time,comm,pid,tid,event,ip,sym,dso,trace -i sched.data | ~/FlameGraph/stackcollapse-perf-sched.awk | ~/FlameGraph/flamegraph.pl --color=io --countname=us >off-cpu.svg

Note: recording scheduler events viaperf recordcan have a very large overhead and should be used cautiously in production environments. This is why I wrap theperf recordaround asleep 1to limit the duration.

In an off-cpu flamegraph, the width of a bar is proportional to the total time spent off cpu. Here we see a lot of time is spent inrwsem_down_write_failed.

From the repeated calls torwsem_down_read_failedandrwsem_down_write_failed, we see that culprit wasmmapcontending in the kernel on themm->mmap_semlock:

down_write(&mm->mmap_sem);

ret = do_mmap_pgoff(file, addr, len, prot, flag, pgoff,&populate);

up_write(&mm->mmap_sem);

This was causing everymmapsyscall to take 10-20ms (almost half the latency of the query itself). MemSQL was so fast that that we had inadvertently written a benchmark for Linuxmmap!

The fix was simple — we switched from usingmmapto using the traditional filereadinterface. After this change, we nearly doubled our throughput and became CPU bound as we expected:

For more information and discussion around Linux performance,check out the original post on my personal blog.

Download MemSQL Community Edition to run your own performance tests for free today:memsql.com/download

Alex Reece is a systems and performance engineer. He believes in active benchmarking, root cause analysis, and fast code.

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • cpu
    cpu
    +關注

    關注

    68

    文章

    11013

    瀏覽量

    215305
  • Linux
    +關注

    關注

    87

    文章

    11425

    瀏覽量

    212407
  • SQL
    SQL
    +關注

    關注

    1

    文章

    780

    瀏覽量

    44727

原文標題:用off-cpu火焰圖調查Linux性能問題

文章出處:【微信號:LinuxDev,微信公眾號:Linux閱碼場】歡迎添加關注!文章轉載請注明出處。

收藏 人收藏

    評論

    相關推薦
    熱點推薦

    Linux性能分析工具大全

    今天浩道跟大家分享關于linux性能分析過程中常用到的分析工具!
    發表于 01-05 09:52 ?683次閱讀

    中國鋰離子電池原材料市場調查分析報告2008-2009版

    中國鋰離子電池原材料市場調查分析報告2008-2009版 詳細內容請見:http://www.boomingfield.com/Html/yjxxcl/2008-9/18
    發表于 12-29 15:12

    _首屆中國嵌入式應用狀況_調查分析報告

    _首屆中國嵌入式應用狀況_調查分析報告
    發表于 08-20 14:48

    全志Tina中使用perf分析CPU使用率

    perf簡介Perf是是內置于Linux內核源碼樹中的性能剖析(profiling)工具。不僅可以用于應用程序的性能統計分析,還可以用于內核的性能
    發表于 05-20 14:25

    火焰識別

    本人長期從事Linux系統的圖像處理產品研發,近期在做火焰識別,火爐溫度控制,智能精準滅火,最近在用樹莓派,期待本產品有更好的性能,我希望可以有機會試用該開發版,體驗新產品的強大功能,同時及時反饋自己的用戶體驗,使雙方共贏。
    發表于 07-23 10:18

    CPU核心工作性能

    CPU核心工作性能 CPU核心概述       
    發表于 12-17 10:59 ?356次閱讀

    Linux CPU性能應該如何優化

    Linux系統中,由于成本的限制,往往會存在資源上的不足,例如 CPU、內存、網絡、IO 性能。本文,就對 Linux 進程和 CPU
    的頭像 發表于 01-18 08:52 ?3561次閱讀

    疫情之下,中國LED顯示屏市場活力調查分析

    疫情之下,中國LED顯示屏市場活力調查分析 眾所周知市場活躍是行業發展的主要動力,而2020年初突如其來的疫情,給中國市場帶來了巨大的沖擊,LED顯示屏市場也不例外。而我們收到了行業多方面的市場反饋
    發表于 04-02 11:23 ?1977次閱讀

    火焰系列之使用火焰隱藏功能提高繪制精度

    我們可以看到,火焰顯示, func程序占用了近四分之一的CPU時間。但是由于我們把 func綁定在CPU0和1上執行,根據小學數學我們應該可以計算出來 func最多占用 2/32=6
    的頭像 發表于 06-23 10:15 ?2171次閱讀
    <b class='flag-5'>火焰</b><b class='flag-5'>圖</b>系列之使用<b class='flag-5'>火焰</b><b class='flag-5'>圖</b>隱藏功能提高繪制精度

    火焰:全局視野的Linux性能剖析

    CPU火焰圖中的每一個方框是一個函數,方框的長度,代表了它的執行時間,所以越寬的函數,執行越久。火焰的樓層每高一層,就是更深一級的函數被調用,最頂層的函數,是葉子函數。
    的頭像 發表于 06-28 09:44 ?2166次閱讀

    殺手級分析——bootchart

    之前小弟一直在宣傳推廣火焰,結果是很多童鞋凡事都用火焰。說實話,火焰特別適合
    的頭像 發表于 09-08 09:13 ?7946次閱讀
    殺手級<b class='flag-5'>分析</b>——bootchart

    基于linux eBPF的進程off-cpu的方法

    的swap等。如下圖所示,紅色部分屬于on-cpu部分,藍色部分屬于off-cpu。 一般我們用的perf命令等都是采樣on-cpu的指令進行CPU的消耗
    的頭像 發表于 09-25 15:41 ?3288次閱讀
    基于<b class='flag-5'>linux</b> eBPF的進程<b class='flag-5'>off-cpu</b>的方法

    Linux問題分析性能優化

    文章來源于:https://mp.weixin.qq.com/s/d1NLXGp7teOgskussBXNMQ作者:alex目錄排查順序方法論性能分析工具CPU分析思路內存
    的頭像 發表于 09-06 19:01 ?1074次閱讀
    <b class='flag-5'>Linux</b>問題<b class='flag-5'>分析</b>與<b class='flag-5'>性能</b>優化

    Linux問題故障定位的小技巧

    a. on-CPU:執行中,執行中的時間通常又分為用戶態時間user和系統態時間sys。 b. off-CPU:等待下一輪上CPU,或者等待I/O、鎖、換頁等等,其狀態可以細分為可執行、匿名換頁、睡眠、鎖、空閑等狀態。
    的頭像 發表于 07-09 16:30 ?523次閱讀
    <b class='flag-5'>Linux</b>問題故障定位的小技巧

    使用Arthas火焰工具的Java應用性能分析和優化經驗

    分享作者在使用Arthas火焰工具進行Java應用性能分析和優化的經驗。
    的頭像 發表于 10-28 09:27 ?936次閱讀
    使用Arthas<b class='flag-5'>火焰</b><b class='flag-5'>圖</b>工具的Java應用<b class='flag-5'>性能</b><b class='flag-5'>分析</b>和優化經驗
    主站蜘蛛池模板: 性夜影院午夜看片 | 奇米影色777四色在线首页 | 一区二区三区福利 | 推倒都市极品贵妇 | 狠狠色狠狠色综合日日小蛇 | 黄色自拍偷拍 | aaaa级毛片| 国产精品一区二区三区免费视频 | 国产成人综合日韩精品婷婷九月 | 中日韩毛片 | 日本精品一卡二卡≡卡四卡 | 深夜大尺度视频在线观看 | 亚洲天堂最新地址 | 狠狠色噜噜狠狠狠狠黑人 | 男人呻吟双腿大开男男h互攻 | 99久久网站 | 天堂网视频在线 | 在线观看播放视频www | 五月婷婷欧美 | 35qao强力打造免费上线高清 | 手机看片国产免费现在观看 | 亚洲色图综合网 | 日本久久综合视频 | 久久国产精品99精品国产987 | 四虎午夜剧场 | 看日本黄大片在线观看 | 一区免费 | 男女交性视频免费 | 欧美性free| 国产人成午夜免费看 | 国产亚洲高清在线精品不卡 | 操日韩 | 狠狠狠色丁香婷婷综合激情 | 色135综合网| 欧美一区二区三区视频 | 2018天天射| 加勒比一区二区三区 | 日本a级特黄三级三级三级 日本边添边爱边摸边做边爱 | 色丁香六月 | 美女张开大腿让男人捅 | 国产情侣真实露脸在线最新 |