91在线观看视频-91在线观看视频-91在线观看免费视频-91在线观看免费-欧美第二页-欧美第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

    文章

    11076

    瀏覽量

    217011
  • Linux
    +關注

    關注

    87

    文章

    11509

    瀏覽量

    213724
  • SQL
    SQL
    +關注

    關注

    1

    文章

    783

    瀏覽量

    45122

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

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

收藏 人收藏
加入交流群
微信小助手二維碼

掃碼添加小助手

加入工程師交流群

    評論

    相關推薦
    熱點推薦

    Linux性能分析工具大全

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

    中國鋰離子電池原材料市場調查分析報告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 ?383次閱讀

    Linux CPU性能應該如何優化

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

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

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

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

    我們可以看到,火焰顯示, func程序占用了近四分之一的CPU時間。但是由于我們把 func綁定在CPU0和1上執行,根據小學數學我們應該可以計算出來 func最多占用 2/32=6
    的頭像 發表于 06-23 10:15 ?2258次閱讀
    <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 ?2236次閱讀

    殺手級分析——bootchart

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

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

    的swap等。如下圖所示,紅色部分屬于on-cpu部分,藍色部分屬于off-cpu。 一般我們用的perf命令等都是采樣on-cpu的指令進行CPU的消耗
    的頭像 發表于 09-25 15:41 ?3401次閱讀
    基于<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 ?1167次閱讀
    <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 ?577次閱讀
    <b class='flag-5'>Linux</b>問題故障定位的小技巧

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

    分享作者在使用Arthas火焰工具進行Java應用性能分析和優化的經驗。
    的頭像 發表于 10-28 09:27 ?1274次閱讀
    使用Arthas<b class='flag-5'>火焰</b><b class='flag-5'>圖</b>工具的Java應用<b class='flag-5'>性能</b><b class='flag-5'>分析</b>和優化經驗
    主站蜘蛛池模板: 亚洲mm8成为人影院 亚洲qingse中文在线 | 色综合激情 | www.亚洲天堂.com | 久久草在线精品 | 四虎影视永久在线精品免费播放 | 男人午夜禁片在线观看 | 大尺度视频网站久久久久久久久 | 亚洲一区二区在线播放 | 久久婷婷综合五月一区二区 | 人人揉人人爽五月天视频 | 亚洲天堂导航 | 久久人人网 | 国产黄视频网站 | 五月天丁香激情 | 日本高清色视频在线观看免费 | 夜夜爽天天爽 | 国产亚洲高清视频 | 天天鲁天天爽天天视频 | 天天操天天干天天玩 | 深夜免费视频 | 亚洲成人在线免费观看 | 欧美视频一区二区三区四区 | 欧美成人全部费免网站 | 色日韩在线 | 国产亚洲精品激情都市 | 国产精品毛片一区二区三区 | 性猛交xxxx乱大交孕妇 | gogo亚洲肉体艺术100 | 久草视频这里只有精品 | 五月天亚洲婷婷 | 天天干夜夜叭 | www.色.com| 欧美视频一区二区三区在线观看 | 欧美性天天影视 | 91大神在线精品视频一区 | 嫩草影院播放地址一二三 | 日本黄色免费 | 色宅男午夜电影在线观看 | 天天色播 | 日本xxxx69日本 | xxxx性xxxx|