我的计算机配备如下∶
处理器∶Intel 赛扬 500 MHz
记忆体∶256 Mb PC100 RAM
硬碟∶80Gb 7200 rpm ATA100
显示卡∶tnt2 AGP
声卡∶sb live!
网络卡∶8139
显示器∶mac 796fd2
操作系统∶安装 Win2k server 与 RH7.3 + suse 8.1
一、开启硬盘 DMA 支持。
系统安装完毕後,硬盘的 DMA 是没有打开的,我的方法是在
/etc/rc.d/rc.local 最後面加上一行 /sbin/hdparm -d1 -c3 -m16 /dev/hda 这样每次开机後,硬盘的 DMA 就会开启,不必每次手动设定。
如果您的硬盘机支持 ATA33 可以加上 -X66 这个参数,ATA66则是 -X68,像我的硬盘是 ATA66 那麽完整参数就是 /sbin/hdparm -d1 -X68 -c3 -m16 /dev/hda 经过我的测试 ,在 DMA 未开启以前,实际读取效率是每秒约 4.10 Mb 左右,开启 DMA 後,每秒实际读取效率跃升为 20 Mb 大约提升 5 倍之多。
§未开启 DMA 时的测试
[root@firefly /root]# hdparm -d0 /dev/hda
/dev/hda:
setting using_dma to 0 (off)
using_dma = 0 (off)
[root@firefly /root]# hdparm -Tt /dev/hda
/dev/hda:
Timing buffer-cache reads: 128 MB in 2.75 seconds = 46.55 MB/sec
Timing buffered disk reads: 64 MB in 15.58 seconds = 4.11 MB/sec
§开启 DMA 後的测试结果
[root@firefly /root]# hdparm -d1 -X68 -c3 -m16 /dev/hda
/dev/hda:
setting 32-bit I/O support flag to 3
setting multcount to 16
setting using_dma to 1 (on)
setting xfermode to 69 (UltraDMA mode5)
multcount = 16 (on)
I/O support = 3 (32-bit w/sync)
using_dma = 1 (on)
[root@firefly /root]# hdparm -Tt /dev/hda/dev/hda:
Timing buffer-cache reads: 128 MB in 2.75 seconds = 46.55 MB/sec
Timing buffered disk reads: 64 MB in 3.20 seconds = 20.00 MB/sec
由以上的数据,可以看得出来,硬盘 DMA 是否开启,对读取效率影响很大。
二、关闭多馀的系统服务。
这是老生常谈的题目了,一般我们当作桌上型工作站的时候,只需要激活几个基本的?Service 即可,其他的不但没用,一方面会占用系统资源,另一方面则会有安全上的顾虑,我平常只用来连网、打打文件、听听音乐、看看电影,多半时间只是一个 Client 端,实在没必要激活 Server 端的服务,所以,我在 Setup System Services时,只留下以下几个 Service,其馀的都关闭。
1. crond
2. network
3. syslogd
真的,相信我,只要这3个就足够了!
三、下载 Kernel 重新编程。
因为系统所默认安装的 Kernel 是为了适用大部分的计算机而做的,并未对你的计算机作最优化,所以显得臃肿肥大,因为 Kernel 直接掌控著计算机的一切,所以对系统效率影响当然很大。
我的作法是∶下载最新的 Kernel 重新编程,将我计算机上的硬件直接编程进 Kernel 里面,不要作成 Module ,对於不需要的就不编程,这样,打造出完全面向自己环境的 Kernel ,才能完全发挥计算机的威力。
至於 Kernel 怎样编程?这就不是我的主题了,大家可以到CLDP 自行参考 KERNEL HOW-TO 中译版。
四、减少虚拟终端机的数量。
系统默认是6个,也就是 CTRL+ALT F1~F6 那六个,我关掉其中四个,只留下 CTRL+ALT F1~F2,大约省下 4 Mbytes 的记忆体,但是这样一来,X-Window 会从原来的 CTRL+ALT F7 变成 CTRL+ALT F3 。
修改 /etc/inittab 中,将 mingetty 3 ~6 全部加上 # 字号,然後下指令 #init q
五、调整 X-Windows 环境
我习惯操作 KDE ,对 GNOME 不熟,所以,以下是都是面向 KDE而设,GNOME 的使用者,我想,应该也差不多啦!
1、颜色数设为 16 Bit 就有很好的效果了,24 Bit 除了浪费资源,看不出有何好处。
2、不要使用屏幕保护程序。
3、取消动画窗口功能。
4、尽量使用同一种字型。
5、浏览器用 Mozilla 不要用 Netscape。
6、不要激活音效服务器 artd
Speed Up X by Managing Font Setting 在你抱怨 X 跑得不够快之前,
先检查字型设定, 很可能就是影响效能的一大元凶。
先看一下 /etc/X11/XF86Config-4 档案里的 FontPath 设定值, 如果是
如下∶
Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
# Multiple FontPath entries are allowed (they are concatenated together)
# By default, Mandrake 6.0 and later now use a font server independent of
# the X server to render fonts.
FontPath "unix/:-1"
EndSection
可参考 /etc/X11/fs/config 档案里的字型设定值, 挑选几个喜欢的字型目录(全部比较不会错)
来修改, 例如我直接设定下列几个字型目录∶
Section "Files"
RgbPath "/usr/X11R6/lib/X11/rgb"
# Multiple FontPath entries are allowed (they are concatenated together)
# By default, Mandrake 6.0 and later now use a font server independent of
# the X server to render fonts.
FontPath "/usr/X11R6/lib/X11/fonts/misc:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled"
FontPath "/usr/X11R6/lib/X11/fonts/Type1"
FontPath "/usr/X11R6/lib/X11/fonts/mdk:unscaled"
FontPath "/usr/share/fonts/ttf/big5"
EndSection
修改之後, 重新激活 startx 感受看看棉。
原本的 FontPath "unix/:-1" 将字型由 X Font Server 来提供,
一般使用者未蒙其利、先受其害, 可以考虑等熟悉 X Font Server 功能後再使用。
如此就可以关掉xfs了
ps:试用时不要用默认开机直接进x-window,若不行会卡在x-window
ps:引用自http://twopensource.org/~marr/xfont_tip.html
六、调整应用程序优先权。
一般时候,我们使用任何程序时,其 NICE 值都是 0,意思是CPU 的使用权值。如果我们常用程序有较高的优先权的话,自然效率就会比较好,优先权的值从 -20 到 19 ,数字越小优先权就越高,但要注意的是一般使用者只能调低( 0~19),只有 root 有权调高优先权( -20 ~ 19 javascript:window.open(this.src);" style="CURSOR: pointer" onload="return imgzoom(this,550)">。我们可以用 ps -fel 来观察 NI 那栏就知道。
说了半天,到底如何调整呢?有一个指令 /bin/nice 就是用来作这件事的,用法如下∶nice?-n?程序名称?参数....
n 的值从 -20 到 19,这是手动操作,在 KDE 中,可以用选单编辑器来设定,方法是在你要调整优先权的程序的 [ 命令 ] 那一栏的前面,加上 /bin/nice --n 就可以了。
比方说我常用 Mozilla 来浏览网页,我改成 /bin/nice --10 /usr/local/mozilla/mozilla 这样我的 Mozilla 执行时,就比其他程序有更高的优先权,在实际测试的时候,Mozilla 激活速度以及回应都快了不少,其他一些常用的程序,也可以比照办理。
後记
Linux 真的是一套很棒的操作系统,经过这样调整後,光是开机到登入窗口画面出现,从原来的 48 秒,变成 30 秒,用 top 指令(每秒)观察CPU idle 时间也从 82% 提升到 93%,而窗口程序的反应感觉上与 Win me 差不多了。
nmgzw 回复于:2003-05-15 08:16:19 |
怎么才能知道硬盘支持什么参数呢?我的是单位机子,随便开机箱看的!手上也没又硬盘的说明书什么的! |
弱智 回复于:2003-05-15 08:58:08 |
呵呵,可以看到硬盘的品牌,型号。够了,到它的官方网站查查。 |
Bluebear1218 回复于:2003-05-15 10:26:18 |
Nice topic!Very useful,especially the Font path change! |
Bluebear1218 回复于:2003-05-15 11:32:36 |
A little question.How to stop the xfs?I can't find this service in the "services". |
forrestrun 回复于:2003-05-15 16:42:33 |
rh9是不是默认开启DMA? |
jfcat 回复于:2003-05-15 19:43:30 |
好好学习,天天向上 |
darkbug 回复于:2003-05-15 21:48:34 |
好文,ding |
清茶淡淡 回复于:2003-05-16 08:05:30 |
问一下,如果是要支持ATA100 ,那参数因该是多少呢? X6? 谢谢 |
弱智 回复于:2003-05-16 08:32:14 |
[quote:801dacdbca="清茶淡淡"]问一下,如果是要支持ATA100 ,那参数因该是多少呢? X6? 谢谢[/quote:801dacdbca] http://www.chinaunix.net/forum/viewtopic.php?t=8576 |
wolf2602 回复于:2003-05-16 10:02:02 |
好东西! |
flying-dance big big pig 回复于:2003-05-29 00:50:35 |
[quote:f139a30e66="feming"]那一栏的前面,加上 /bin/nice --n 就可以了。 比方说我常用 Mozilla 来浏览网页,我改成 /bin/nice --10 /usr/local/mozilla/mozilla 这样我的 Mozilla 执行时,就比其他程序有更高的优先权,在实际测试的时候,..........[/quote:f139a30e66] Speeding up Linux Using hdparm by Rob Flickenger 06/29/2000 Are you running an Intel Linux system with at least one (E)IDE hard drive? Wouldn't it be neat if there were a magical command to instantly double the I/O performance of your disks? Or, in some cases, show 6 to 10 times your existing throughput? Did you ever just wonder how to tell what kind of performance you're getting on your "tricked-out" Linux box? Don't overlook hdparm(. If you've never heard of it, don't worry. Most people I've talked to haven't either. But if you're running an IDE/Linux system (as many folks are,) you'll wonder how you ever got this far without it. I know I did. What's the big deal? So, you've got your brand-new UltraATA/66 EIDE drive with a screaming brand-new controller chipset that supports multiple PIO modes and DMA and the leather seat option and extra chrome... But is your system actually taking advantage of these snazzy features? The hdparm( command will not only tell you how your drives are performing, but will let you tweak them out to your heart's content. Now before you get too excited, it is worth pointing out that under some circumstances, these commands CAN CAUSE UNEXPECTED DATA CORRUPTION! Use them at your own risk! At the very least, back up your box and bring it down to single-user mode before proceeding. With the usual disclaimer out of the way, I'd like to point out that if you are using current hardware (i.e. your drive AND controller AND motherboard were manufactured in the last two or three years), you are at considerably lower risk. I've used these commands on several boxes with various hardware configurations, and the worst I've seen happen is the occasional hang, with no data problems on reboot. And no matter how much you might whine at me and the world in general for your personal misfortune, we all know who is ultimately responsible for the well-being of YOUR box: YOU ARE. Caveat Fair Reader. Now, then. If I haven't scared you away yet, try this (as root, preferably in single-user mode): hdparm -Tt /dev/hda You'll see something like: /dev/hda: Timing buffer-cache reads: 128 MB in 1.34 seconds =95.52 MB/sec Timing buffered disk reads: 64 MB in 17.86 seconds = 3.58 MB/sec What does this tell us? The -T means to test the cache system (i.e., the memory, CPU, and buffer cache). The -t means to report stats on the disk in question, reading data not in the cache. The two together, run a couple of times in a row in single-user mode, will give you an idea of the performance of your disk I/O system. (These are actual numbers from a PII/350 / 128M Ram / newish EIDE HD; your numbers will vary.) But even with varying numbers, 3.58 MB/sec is PATHETIC for the above hardware. I thought the ad for the HD said something about 66MB per second!!?!? What gives? Well, let's find out more about how Linux is addressing your drive: hdparm /dev/hda /dev/hda: multcount = 0 (off) I/O support = 0 (default 16-bit) unmaskirq = 0 (off) using_dma = 0 (off) keepsettings = 0 (off) nowerr = 0 (off) readonly = 0 (off) readahead = 8 (on) geometry = 1870/255/63, sectors = 30043440, start = 0 These are the defaults. Nice, safe, but not necessarily optimal. What's all this about 16-bit mode? I thought that went out with the 386! And why are most of the other options turned off? Well, it's generally considered a good idea for any self-respecting distribution to install itself in the kewlest, slickest, but SAFEST way it possibly can. The above settings are virtually guaranteed to work on any hardware you might throw at it. But since we know we're throwing something more than a dusty, 8-year-old, 16-bit multi-IO card at it, let's talk about the interesting options: multcount: Short for multiple sector count. This controls how many sectors are fetched from the disk in a single I/O interrupt. Almost all modern IDE drives support this. The man page claims: When this feature is enabled, it typically reduces operating system overhead for disk I/O by 30-50%. On many systems, it also provides increased data throughput of anywhere from 5% to 50%. I/O support: This is a big one. This flag controls how data is passed from the PCI bus to the controller. Almost all modern controller chipsets support mode 3, or 32-bit mode w/sync. Some even support 32-bit async. Turning this on will almost certainly double your throughput (see below.) unmaskirq: Turning this on will allow Linux to unmask other interrupts while processing a disk interrupt. What does that mean? It lets Linux attend to other interrupt-related tasks (i.e., network traffic) while waiting for your disk to return with the data it asked for. It should improve overall system response time, but be warned: Not all hardware configurations will be able to handle it. See the manpage. using_dma: DMA can be a tricky business. If you can get your controller and drive using a DMA mode, do it. But I have seen more than one machine hang while playing with this option. Again, see the manpage (and the example on the next page)! Turbocharged So, since we have our system in single-user mode like a good little admin, let's try out some turbo settings: hdparm -c3 -m16 /dev/hda /dev/hda: setting 32-bit I/O support flag to 3 setting multcount to 16 multcount = 16 (on) I/O support = 3 (32-bit w/sync) Great! 32-bit sounds nice. And some multi-reads might work. Let's re-run the benchmark: hdparm -tT /dev/hda /dev/hda: Timing buffer-cache reads: 128 MB in 1.41 seconds =90.78 MB/sec Timing buffered disk reads: 64 MB in 9.84 seconds = 6.50 MB/sec WOW! Almost double the disk throughput without really trying! Incredible. But wait, there's more: We're still not unmasking interrupts, using DMA, or even a using decent PIO mode! Of course, enabling these gets riskier. (Why is it always a trade-off between freedom and security?) The man page mentions trying Multiword DMA mode2, so: hdparm -X34 -d1 -u1 /dev/hda ...Unfortunately this seems to be unsupported on this particular box (it hung like an NT box running a Java app.) So, after rebooting it (again in single-user mode), I went with this: hdparm -X66 -d1 -u1 -m16 -c3 /dev/hda /dev/hda: setting 32-bit I/O support flag to 3 setting multcount to 16 setting unmaskirq to 1 (on) setting using_dma to 1 (on) setting xfermode to 66 (UltraDMA mode2) multcount = 16 (on) I/O support = 3 (32-bit w/sync) unmaskirq = 1 (on) using_dma = 1 (on) And then checked: hdparm -tT /dev/hda /dev/hda: Timing buffer-cache reads: 128 MB in 1.43 seconds =89.51 MB/sec Timing buffered disk reads: 64 MB in 3.18 seconds =20.13 MB/sec 20.13 MB/sec. A far cry from the miniscule 3.58 we started with... By the way, notice how we specified the -m16 and -c3 switch again? That's because it doesn't remember your hdparm settings between reboots. Be sure to add the above line to your /etc/rc.d/* scripts once you're sure the system is stable (and preferably after your fsck runs; having an extensive fs check run with your controller in a flaky mode may be a good way to generate vast quantities of entropy, but it's no way to administer a system. At least not with a straight face...) Now, after running the benchmark a few more times, reboot in multi-user mode and fire up X. Load Netscape. And try not to fall out of your chair. In conclusion This is one of those interesting little tidbits that escapes many "seasoned" Linux veterans, especially since one never sees any indication that the system isn't using the most optimal settings. (Gee, all my kernel messages have looked fine....) And using hdparm isn't completely without risk, but is well worth investigating. And it doesn't stop at performance: hdparm lets you adjust various power saving modes as well. See the hdparm( for the final word. Many thanks to Mark Lord for putting together this nifty utility. If your particular distribution doesn't include hdparm (usually in /sbin or /usr/sbin), get it from the source at http://metalab.unc.edu/pub/Linux/system/hardware/ Happy hacking! Rob Flickenger is the author of two O'Reilly books: Building Wireless Community Networks and Linux Server Hacks. |
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/