忙しいサーバやゲートウェイ、ファイアーウォールを動かしているなら、以下に説明するようなカーネルのいろんなところでメモリが枯渇するのは絶対に防ごう。
options(4) man ページは、使えるオプションについて説明している。
忙しいサーバやゲートウェイ、ファイアーウォールの場合に変えた方がいいかもしれないオプションは、 NMBCLUSTERS だ。これはカーネル mbuf クラスターマップのサイズを左右する。 きみのマシンで "mb_map full"みたいなメッセージが出てきたら、この値を増やそう。ネットワークインターフェース上のトラフィックが、特に理由もなくとまるようなら、それもこの値を増やせというしるしかもしれない。i386 でほとんどの 100Mbps イーサネットカードの場合(カードが何枚ささっていても)、推奨される値は 8192 だ。
option NMBCLUSTERS=8192
ディスク I/O 速度は、マシンの総合スピード上ではだいじな要素だ。コンピュータがマルチユーザ環境を提供しているなら、なおさらのこと(これは対話型のログインをするユーザから、単にファイルサーバやwebサーバとして見ているユーザまで含む)。
データ保存は、いつも注意しておかなきゃいけない。特にパーティションの空きがなくなったりディスクがおしゃかになったりした場合には。OpenBSD は、ディスク操作の速度をあげて、フォールトトレランスを高めるようなオプションをいくつか持っている。
Table Of Contents
最初のオプションは ccd(4)、Concatenated Disk Driverを使うことだ。これはいくつかのパーティションをくっつけて一つの仮想ディスクにするものだ(だからいくつかのディスクが一つのディスクに見えるようになる)。コンセプトからいうと、各種商業Unix で使われている LVM (論理ボリューム管理)に近い。
GENERIC カーネルを使っているなら、ccd はもう有効になっている。そうでなければ、これをカーネル設定に追加してコンパイルしなおそう。ccd設定をするには、カーネルがサポートしている必要がある。こんな一行:
pseudo-device ccd 4 # concatenated disk devices
上の例では、最大 4 つのccd デバイス(仮想ディスク)が使える。ではまず、実際のディスクでどのパーティションをccd 専用にしたいか考えよう。disklabel を使ってこれらのパーティションのタイプを 'ccd'にしよう。 一部のアーキテクチャでは、disklabel がこれをいやがるかもしれない。その場合には 'ffs'にしておこう。
ストライピングによる性能向上をはかるために ccd を使うなら、同じ種類・型番のディスクを同じ disklabel 設定で使わないと何の役にもたたないことをお忘れなく。
/etc/ccd.conf を編集して、次のような感じにしたてよう:
# Configuration file for concatenated disk devices # # ccd ileave flags component devices ccd0 16 none /dev/sd2e /dev/sd3e
(ccd の設定について詳しくは、
ccdconfig(8)を参照。)
上記の変更を有効にするには、次を実行しよう
# ccdconfig -C
/etc/ccd.conf があれば、ccd は自動的に起動時に自分を設定する。さて、これで新しいディスクccd0 ができた。これは /dev/sd2e と /dev/sd3e の組み合わせだ。ここでふつうと同じように disklabel を使って、使いたいパーティションを切ろう。ここでも、'c' パーティションは実際にファイルをのせる本当のパーティションとしては使わないこと。使用可能なパーティションが最低でもディスクの先頭から1シリンダは離れているようにすること。
もう一つの解決方法は raid(4) だ。この場合には raidctl(8) を使って raid デバイスをコントロールするしかない。OpenBSD のRAID は CMU RAIDframe を Greg Osterが NetBSD に移植したものをもとにしている。OpenBSD は RAID 0, 1, 4, 5をサポートしている。
raid でも ccd と同じく、カーネルにサポートが入っている必要がある。ccd とはちがって、GENERIC にはサポートが入っていないから、カーネルにコンパイルして入れ込む必要がある (RAID サポートを入れると、i386 カーネルのサイズは 500K も増えるのだ!)
pseudo-device raid 4 # RAIDframe disk device
一部の OS で RAID を設定するのは、控えめに言ってもややこしくて頭痛がする。でもRAIDframeはちがう。raid(4) と raidctl(8) man ページを読むと、細かい話も全部わかる。オプションや可能な設定はいろいろあって、詳細な説明はこのドキュメントの範囲を超える。
メモリの余っているファイルサーバの場合には、BUFCACHEPERCENTを増やしてみよう。つまり、RAM のうちどの程度をファイルシステムバッファとして使うか、というサイズだ。このオプションは Unified Buffer Cache が完成してOpenBSD に統合されたら、また変わるかもしれない。それまでは BUFCACHEPERCENT を増やすなら、カーネル設定にこんな一行を入れよう:
option BUFCACHEPERCENT=30
これは 30% にしてあるけれど、下は 5% (デフォルト)から上は50%超まで設定できる。
システムの高速化に使えるもう一つのツールが softupdates だ。これまでの BSD ファイルシステム操作でいちばんグズなのが、metainfoの更新だった(これはいろんなところで起こるけれど、とくにファイルやディレクトリを作成・削除するときに起きる)。Softupdates は、metainfo を更新ごとにいちいちハードディスクに書き込むのではなく、RAM で更新する。この影響はもう一つあって、ディスク上の metainfo はつねに最新ではなくても、いつも完全だということだ。だからシステムクラッシュが起きても、起動時に fsck はいらなくて、単にバックグラウンド版の fsck が RAM 上の metainfo に更新を(softupdates経由で)やってくれればいい。これはつまりサーバの再起動は、fsck を待たなくていいのでずっと高速になるということだ(ただしOpenBSD はまだこの機能はもっていない)。softupdates について詳しくは softupdates FAQ を読もう。
これはOpenBSD 2.5 情報に移動。
(注- この部分はほとんどが i386 pc アーキテクチャを中心にしている。つまり……ほかのアーキテクチャではそんなに選択の余地がないというわけだ!)
アプリケーションの速度は OS とそれが提供する機能に大きく依存する。それだからこそ、きみも OpenBSD を使ってるわけだ。アプリケーションの速度はまた、ハードウェアにも大きく依存する。多くの人々にとって、Pentium III やAMD Athlon プロセッサを載せた新品の PC の価格性能比は、Sun UltraSparc 60 の価格性能比よりもずっと高い。それに もちろん OpenBSD のお値段は無敵ね。
もし新品の PC のお買い物をするんなら、パーツごとに買うにしても組み立てずみのものを買うにしても、まず信用できるパーツを買うこと。PC の世界で、これはなかなかむずかしい。 不良品や信頼性の低いマッチしないパーツは、OpenBSDの足をひっぱってしょっちゅうクラッシュさせることもある。ぼくたちにできる最高のアドバイスは、とにかく慎重に、信用できる権威がレビューしたパーツやブランドを選びなさい、ということだ。お値段をケチった分が、品質に響いてくることはよくあるのだ。
ハードから最大の性能を引き出すために役立つアドバイスをいくつか:
ご質問:「あたしは、パッケージの一つを使えるようにするために『mount -u -o async /』とします。このパッケージは、ときどき何百ものファイルにどうしてもさわりたがるのよ。なんでasync マウントはいやな顔されて、デフォルトになってないの(ほかの Unix ではデフォルトになってるのもあるわよ)?一部のアプリケーションで性能をあげるのに、ずっと簡単だし安全でしょうに?」
お答え: 「Async マウントは確かに sync マウントよりは高速でございますが、安全性が劣るのでございます。停電したらどうなります? ハードがトラブったら? 速度の追求のために、信頼性やシステムの安定性を犠牲にしてはなりませぬ。 mount(8)の man ページをごらんあそばせ:」
async ファイルシステムへの I/O が非同期で行われる。 これは設定すると危険なフラグだ。ディスク上のファイルシステム の一貫性が保証されなくなるからだ。このフラグは、システムが クラッシュしたときにファイルシステムをつくりなおす覚悟がなけ れば使ってはいけない。このフラグを使ういちばん一般的な場合は、 restore(8) を高速する場合で、速度が二倍くらいにはなる。
一方では、もしクラッシュしてもあとから作り直せる一時データを扱っているなら、別のパーティションをそのデータだけに使って async マウントしてやると高速になる。もしなにかがヘタったときにそのパーティション内のデータ全部なくしてもいいってんなら……
Getting an X server working at an acceptable resolution with many multi-sync monitors is possible. If anyone has tried to do this with the standard xf86config or XF86Setup utilties, they probably didn't get the best possible results. One of the more painful aspects is simply getting your monitor running with your preferred resolution, and then getting the veritcal scan rate set to at least 72-75 Hz, a rate where the screen flicker is much less visible to humans. Conversely, what if you are trying to set the vertical scan rate so it is very low? You can set it at 50 Hz so that it can be captured on to video without flicker, but the methods to do this are non-obvious with the standard XFree86 tools and documentation.
Finally, at the resolutions many people normally use with inexpensive VGA monitors (800x600, 1024x768, 1152x900, 1280x1024), it is possible (at least on newer monitors) to use vertical scan rates of 85MHz and above, to achieve an extremely clean, palatable picture. The XFree86 X server has a mechanism which allows you to describe in detail the video mode you want to use, this is the ModeLine. A ModeLine has four sections, a single number for the pixel clock, four numbers for horizontal timings, four numbers for vertical timings, and an optional section with a list of flags specifying other characteristics of the mode (such as Interlace, DoubleScan, and more...See the XF86Config(5) manual page for more ModeLine details.)
Generating a ModeLine is a black art... Luckily, there is a script which can do this for you. It is the Colas XFree86 ModeLine Generator. Before you can use the Colas generator, you need to figure out the vertical and horizontal sync limits for your monitor. This is often documented in the manual, or on the manufacturer's web site. If you can't find either of those, simply search the web for the monitor make and model, several people have been kind enough to compile lists with this information.
For example, say you have a Dell D1226H monitor. You searched in agony at Dell's web site to find that it has a 30-95 kHz horizontal scan range, and a 50-160 Hz vertical scan range. Visit the ModeLine generator page, enter this information. Next, you need to enter the minimum vertical scan rate you want. Any rate at or above 72 Hz should generally have low visible flicker. As you go higher, the clearer and crisper your screen image becomes.
With all of these bits of information, the script will generate a ModeLine for every possible 4x3 resolution which your monitor can support, above the minimum vertical scan rate which you enter. If someone enters the Dell specs above and a 75 Hz vertical scan minimum, the script gives out something like the following:
ModeLine "320x240" 20.07 320 336 416 448 240 242 254 280 #160Hz ModeLine "328x246" 20.86 328 344 424 456 246 248 260 286 #160Hz ... ModeLine "816x612" 107.39 816 856 1056 1136 612 614 626 652 #145Hz ModeLine "824x618" 108.39 824 864 1064 1144 618 620 632 658 #144Hz ModeLine "832x624" 109.38 832 872 1072 1152 624 626 638 664 #143Hz ... ModeLine "840x630" 109.58 840 880 1080 1160 630 632 644 670 #141Hz ModeLine "848x636" 110.54 848 888 1088 1168 636 638 650 676 #140Hz ... ModeLine "1048x786" 136.02 1048 1096 1336 1432 786 788 800 826 #115Hz ModeLine "1056x792" 136.58 1056 1104 1344 1440 792 794 806 832 #114Hz ModeLine "1064x798" 137.11 1064 1112 1352 1448 798 800 812 838 #113Hz ... ModeLine "1432x1074" 184.07 1432 1496 1816 1944 1074 1076 1088 1114 #85Hz ModeLine "1576x1182" 199.86 1576 1648 2008 2152 1182 1184 1196 1222 #76Hz ModeLine "1584x1188" 198.93 1584 1656 2016 2160 1188 1190 1202 1228 #75Hz
Now, this monitor claims to do 1600x1200 @ 75 Hz, but the script does not say this is within 75 Hz. So, if you really want exactly 1600x1200, go down a notch with your minimum vertical rate... (Here, we go down to 70 Hz)
ModeLine "1592x1194" 197.97 1592 1664 2024 2168 1194 1196 1208 1234 #74Hz ModeLine "1600x1200" 199.67 1600 1672 2032 2176 1200 1202 1214 1240 #74Hz ModeLine "1608x1206" 198.65 1608 1680 2040 2184 1206 1208 1220 1246 #73Hz ModeLine "1616x1212" 197.59 1616 1688 2048 2192 1212 1214 1226 1252 #72Hz ModeLine "1624x1218" 199.26 1624 1696 2056 2200 1218 1220 1232 1258 #72Hz ModeLine "1632x1224" 198.15 1632 1704 2064 2208 1224 1226 1238 1264 #71Hz ModeLine "1640x1230" 199.81 1640 1712 2072 2216 1230 1232 1244 1270 #71Hz ModeLine "1648x1236" 198.64 1648 1720 2080 2224 1236 1238 1250 1276 #70Hz
Here, we see the monitor really does 1600x1200 @ 74 Hz when the dot clock (bandwidth) is limited to 200MHz. Set the bandwidth according to the limits defined by the monitor.
Once you have your ModeLines, put them into your /etc/XF86Config file. Comment out the old ModeLines, so that you can use them again if the new ones don't work. Next, choose what resolution you actually want to run at. First, figure out if X is running in accelerated mode (which it does with most video cards), so you know which "Screen" section of the XF86Config to modify. Or, just modify all of the Screen sections.
Section "Screen" Driver "Accel" Device "Primary Card" Monitor "Primary Monitor" DefaultColorDepth 32 SubSection "Display" Depth 32 Modes "1280x1024" "1024x768" EndSubSection
The first frequency you see after the "Modes" line is the frequency that X is going to start in. By pressing CTRL-ALT-KEYPAD MINUS, or CTRL-ALT-KEYPAD PLUS, you can switch between any frequencies that you list here. According to the section above, X will try to start in 32-bit color mode (via the DefaultColorDepth directive, without it X will start in 8-bit color mode.) The first resolution it will try to use is 1280x1024 (it follows the order of the Modes line.) Note that "1280x1024" is just a level for the values in the ModeLine.
Note that the ModeLine generator script has options to relax its' timings for older or smaller monitors, and also has the ability to provide ModeLines for specific resolutions. Depending on the type of hardware you have, it may not be very easy to use with the default options. If the picture is too tall, too wide, or too small, or is shifted horizontally or vertically, and the controls of the monitor aren't enough to correct its appearance, once can use xvidtune(1) to adjust the ModeLine to better fit with the monitor's timings.
On most modern monitors, there is no fixed limit on the bandwidth, thus they are often not listed anymore in the specs. What happens is that the more you go up in BW, the fuzzier the screen image becomes. So you may want to put in the bandwith of your card (also named "dotclock") to test (you cannot damage your monitor this way), and go progressively down in BW down to have a nice crisp image.
If this seems needlessly complex, that's because it is. XFree86 4.0 addresses this, and makes this process much easier since it has several builtin modes and is capable of reading back capabilities from "plug and play" monitors through DDC and DDC2. Unfortunately, it is not quite ready for prime time because it does not support many devices supported in XFree86 3.3.
You can download the Colas XFree86 ModeLine Generator script at: ftp://koala.inria.fr/pub/Klone/. You need to grab the Klone interpreter, and compile it. The scripts exist under the scripts directory in the Klone distribution. There are two versions, a CGI version and a non-CGI version which will take your complete XF86Config file, decode the monitor specs that you entered into xf86config/XF86Setup (Now, think, did you actually enter the specs for your monitor or just choose generic ones?), and fix the existing ModeLines accordingly.
[FAQ トップに戻る] [10.0 - システム管理] [12.0 - 高度なユーザのために]
www@openbsd.org 翻訳上の問題はhiyori13@alum.mit.edu
$OpenBSD: faq11.html,v 1.10 2000/09/20 00:43:02 ericj Exp $