In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Most people don't understand the knowledge points of this article "Who is switching process in Linux server", so Xiaobian summarizes the following contents for everyone, the contents are detailed, the steps are clear, and it has certain reference value. I hope everyone can gain something after reading this article. Let's take a look at this article "Who is switching process in Linux server".
We often need to know who is doing process switching and why when we are doing Linux servers. Because process switching is expensive, I give you a number from the LMbench test:
Context switching – times in microseconds – smaller is better-------------------------Host OS 2p/0K 2p/16K 2p/64K 8p/16K 8p/64K 16p/16K 16p/64Kctxsw ctxsw ctxsw ctxsw ctxsw ctxsw ctxsw--- ----- -- -- -- -- -- --- ---my174.cm4 Linux 2.6.18- 6.1100 7.0200 6.1100 8.7400 7.7200 8.96000 9.62000
On my very high-end servers, the process switching overhead is around 8us, which is unacceptable relative to high-performance servers, so we want to do as much as possible in a time slice, rather than wasting time on unnecessary switching.
Curiosity killed the cat, let's investigate who is switching our process:
[root@my174 admin]# dstat 1--total-cpu-usage-- -dsk/total- -net/total- -paging– -system–usr sys idl wai hiq siq| read writ| recv send| in out | int csw0 0 100 0 0 0| 0 0 | 796B 1488B| 0 0 |1004 1280 0 100 0 0 0| 0 0 | 280B 728B| 0 0 |1005 1140 0 100 0 0 0| 0 0 | 280B 728B| 0 0 |1005 1280 0 100 0 0 0| 0 0 | 280B 728B| 0 0 |1005 1140 0 100 0 0 0| 0 320k| 280B 728B| 0 0 |1008 143…
We can see that the number of csw is 120/S, but tools like dstat or vmstat don't tell us who's doing the wrong thing. All right! Let's do it ourselves.
Bring out our lovely systemtap!
[root@my174 admin]# cat >cswmon.stp#! /usr/bin/env stap## global csw_countglobal idle_count probe scheduler.cpu_off {csw_count[task_prev, task_next]++idle_count+=idle} function fmt_task(task_prev, task_next){return sprintf("%s(%d)->%s(%d)",task_execname(task_prev),task_pid(task_prev),task_execname(task_next),task_pid(task_next))} function print_cswtop () {printf ("%45s s\n", "Context switch", "COUNT")foreach ([task_prev, task_next] in csw_count- limit 20) {printf("%45s d\n", fmt_task(task_prev, task_next), csw_count[task_prev, task_next])}printf("%45s d\n", "idle", idle_count) delete csw_countdelete idle_count} probe timer.s($1) {print_cswtop ()printf("--------------------–\n")}CTRL+D
This script will print out the TOP 20 most switched processes and their pid every set time. Let's see the results:
[root@my174 admin]# stap cswmon.stp 5Context switch COUNTswapper(0)->systemtap/11(908) 500systemtap/11(908)->swapper(0) 498swapper(0)->fct1-worker(2492) 50fct1-worker(2492)->swapper(0) 50swapper(0)->fct0-worker(2191) 50fct0-worker(2191)->swapper(0) 50swapper(0)->bond0(3432) 50bond0(3432)->swapper(0) 50stapio(879)->swapper(0) 26swapper(0)->stapio(879) 25stapio(879)->swapper(0) 19swapper(0)->stapio(879) 17swapper(0)->watchdog/9(31) 5watchdog/9(31)->swapper(0) 5swapper(0)->mysqld(18346) 5mysqld(18346)->swapper(0) 5swapper(0)->watchdog/13(43) 5watchdog/13(43)->swapper(0) 5swapper(0)->watchdog/14(46) 5watchdog/14(46)->swapper(0) 5idle 859--------------------–…
We can see where the process switched from, and how many times it happened, *** line, I printed out the number of idle times, which means that at this time the system has nothing to do, it switches to idle(0) this process to rest.
Through the above survey, we will have a clear understanding of where our system overhead occurs, so that we can locate the problem.
The above is the content of this article about "who is switching process in Linux server". I believe everyone has a certain understanding. I hope the content shared by Xiaobian will be helpful to everyone. If you want to know more relevant knowledge content, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.