⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch39_12.htm

📁 the unix power tools
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 39] 39.12 What Makes Your Computer Slow? How Do You Fix It?</TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:50:25Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch39_01.htm"TITLE="39. Time and Performance"><LINKREL="prev"HREF="ch39_11.htm"TITLE="39.11 Changing a Job's Priority Under BSD UNIX "><LINKREL="next"HREF="ch40_01.htm"TITLE="40. Delayed Execution"></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch39_11.htm"TITLE="39.11 Changing a Job's Priority Under BSD UNIX "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 39.11 Changing a Job's Priority Under BSD UNIX "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 39<BR>Time and Performance</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="CHAPTER"HREF="ch40_01.htm"TITLE="40. Delayed Execution"><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 40. Delayed Execution"BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-0067">39.12 What Makes Your Computer Slow? How Do You Fix It?</A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-44273"></A><ACLASS="indexterm"NAME="AUTOID-44276"></A><ACLASS="indexterm"NAME="AUTOID-44279"></A>Article<ACLASS="xref"HREF="ch39_05.htm"TITLE="Why Is the System So Slow? ">39.5</A>discussed the various components that make up a user'sperception of system performance. There is another equally importantapproach to this issue: the computer's view of performance.All system performance issues are basically resource contention issues.In any computer system, there are three fundamental resources: the CPU,memory, and the I/O subsystem (e.g., disks and networks). From thisstandpoint, performance tuning means ensuring that every user getsa fair share of available resources.</P><PCLASS="para">Each resource has its own particular set of problems. Resourceproblems are complicated because all resources interact with oneanother. Your best approach is to consider carefully what each systemresource does: CPU, I/O, and memory. To get you started, here's aquick summary of each system resource and the problems it can have.</P><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="UPT-ART-67-SECT-1.1">39.12.1 The CPU </A></H3><PCLASS="para">On any time-sharing system, even single-user time-sharing systems(such as UNIX on a personal computer), many programs want touse the CPU at the same time. Under most circumstances the UNIXkernel is able to allocate the CPU fairly; however, each process (orprogram) requires a certain number of CPU cycles to execute and thereare only so many cycles in a day. At some point the CPU just can't getall the work done.</P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-44288"></A><ACLASS="indexterm"NAME="AUTOID-44291"></A><ACLASS="indexterm"NAME="AUTOID-44294"></A>There are a few ways to measure CPU contention. The simplest is theUNIX load average, reported by the BSD<SPANCLASS="link"><EMCLASS="emphasis">uptime</EM> (<ACLASS="linkend"HREF="ch39_07.htm"TITLE="Checking System Load: uptime ">39.7</A>)</SPAN>command.  Under System V, <EMCLASS="emphasis">sar -q</EM> provides the same sort ofinformation. The load average tries to measure the number of activeprocesses at any time (a <EMCLASS="emphasis">process</EM> is a single stream ofinstructions). As a measure of CPU utilization, the load average issimplistic, poorly defined, but far from useless.</P><PCLASS="para">Before you blame the CPU for your performance problems, think a bitabout what we <EMCLASS="emphasis">don't</EM> mean by CPU contention. We don't mean thatthe system is short of memory or that it can't do I/O fastenough. Either of these situations can make your system appear veryslow. But the CPU may be spending most of its time idle; therefore,you can't just look at the load average and decide that you need afaster processor.  Your programs won't run a bit faster.  Before youunderstand your system, you also need to find out what your memory andI/O subsystems are doing.  Users often point their fingers at the CPU,but I would be willing to bet that in most situations memory and I/Oare equally (if not more) to blame.</P><PCLASS="para">Given that you are short of CPU cycles, you have three basicalternatives:</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para">You can get users to run jobs at night or at other low-usage times -suring the computer is doing useful work 24 hours a day)with<SPANCLASS="link"><EMCLASS="emphasis">batch</EM> or <EMCLASS="emphasis">at</EM> (<ACLASS="linkend"HREF="ch40_01.htm#UPT-ART-2313"TITLE="Off-Peak Job Submission ">40.1</A>)</SPAN>.</P></LI><LICLASS="listitem"><PCLASS="para">You can prevent your system from doing unnecessary work.</P></LI><LICLASS="listitem"><PCLASS="para">You can get users to<SPANCLASS="link">run their big jobs at lower priority (<ACLASS="linkend"HREF="ch39_09.htm"TITLE='Know When to Be "nice&quot; to OTher Users...and WhenNot to'>39.9</A>)</SPAN>.</P></LI></UL><PCLASS="para">If none of these options is viable, you may need to upgrade your system.</P></DIV><DIVCLASS="sect2"><H3CLASS="sect2"><ACLASS="title"NAME="UPT-ART-67-SECT-1.2">39.12.2 The Memory Subsystem </A></H3><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-44318"></A><ACLASS="indexterm"NAME="AUTOID-44321"></A><ACLASS="indexterm"NAME="AUTOID-44324"></A><ACLASS="indexterm"NAME="AUTOID-44326"></A><ACLASS="indexterm"NAME="AUTOID-44328"></A><ACLASS="indexterm"NAME="AUTOID-44330"></A><ACLASS="indexterm"NAME="AUTOID-44332"></A><ACLASS="indexterm"NAME="AUTOID-44334"></A>Memory contention arises when the memory requirements of the activeprocesses exceed the physical memory available on the system; at thispoint, the system is out of memory.  To handle this lack of memorywithout crashing the system or killing processes, the system starts<EMCLASS="emphasis">paging</EM>: moving portions of active processes to disk in orderto reclaim physical memory. At this point, performance decreasesdramatically. Paging is distinguished from <EMCLASS="emphasis">swapping</EM>, which meansmoving entire processes to disk and reclaiming their space. Paging andswapping indicate that the system can't provide enough memory for theprocesses that are currently running, although under somecircumstances swapping can be a part of normal housekeeping. Under BSDUNIX, tools such as <EMCLASS="emphasis">vmstat</EM> and <EMCLASS="emphasis">pstat</EM> show whetherthe system is paging; <EMCLASS="emphasis">ps</EM> can report the memory requirementsof each process. The System V utility <EMCLASS="emphasis">sar</EM> provides informationabout virtually all aspects of memory performance.</P><PCLASS="para">To prevent paging, you must either make more memory available ordecrease the extent to which jobs compete. To do this, you cantune system parameters, which is beyond the scope of this book(see O'Reilly &amp; Associates' <EMCLASS="emphasis">System Performance Tuning</EM> by Mike Loukidesfor help).You can also<SPANCLASS="link">terminate (<ACLASS="linkend"HREF="ch38_10.htm"TITLE="Destroying Processes with kill ">38.10</A>)</SPAN>the jobs with the largest memory requirements.If your system has a lot of memory, the kernel's memory requirements will berelatively small; the typicalantagonists are very large application programs.</P

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -