差分
このページの2つのバージョン間の差分を表示します。
次のリビジョン | 前のリビジョン | ||
freebsd:tuning_power_consumption [2015-03-23 12:46] Decomo 作成 |
freebsd:tuning_power_consumption [2019-12-01 19:16] Decomo |
||
---|---|---|---|
行 1: | 行 1: | ||
====== FreeBSD WikiのTuningPowerConsumptionの日本語訳 ====== | ====== FreeBSD WikiのTuningPowerConsumptionの日本語訳 ====== | ||
- | TuningPowerConsumption | + | 家鯖の消費電力を下げるべく情報を集めていたところ、FreeBSD Wikiの[[https:// |
- | Alexandar Motin writes: | + | ===== 消費電力チューニング ===== |
- | I would like to summarize some of my knowledge on reducing FreeBSD power consumption and describe some new things implemented in FreeBSD 8.x/9.x. The main character of this story is my 12" Acer TravelMate 6292 laptop with C2D T7700 2.4GHz CPU, 965GM chipset and SATA HDD. | + | Alexandar Motin 記す: |
- | Modern systems, especially laptops, are implementing big number of power-saving technologies. Some of them are working automatically, | + | FreeBSDでの消費電力削減に関して私の知るところをまとめ、FreeBSD 8.x/9.xで実装されたいくつかの新しい事柄を説明しようと思います。このストーリーの主人公は、C2D T7700 2.4GHz CPU、965GMチップセット、SATA HDDを搭載した私の12インチAcer TravelMate 6292ラップトップです。 |
- | So here is the steps: | + | 現代のシステム、とりわけラップトップは数多くの省エネ技術を搭載しています。それらのいくつかは自動で機能するものの、その他は効果を発揮するための明示的な設定と特別なシステムチューニング、トレードオフが存在します。 |
- | 1. CPU | ||
- | CPU is the most consuming part of the system. Under the full load it alone may consume more then 40W of power, but for real laptop usage the most important is idle consumption. Core2Duo T7700 CPU has 2 cores, runs on 2.4GHz frequency, supports EIST technology with P-states at 2400, 2000, 1600, 1200 and 800MHz levels, supports C1, C2 and C3 idle C-states, plus throttling. So how can we use it: | + | ここから順にみていきます: |
- | P-states and throttling | ||
- | Enabling powerd allows to effectively control | + | ==== 1. CPU ==== |
+ | CPUはシステム内で最も電力を消費する部分です。 | ||
+ | 最大負荷時では、CPUだけで40W以上を消費するでしょうが、実際のラップトップ利用において最も重要なのはアイドル時消費電力です。 | ||
+ | Core2Duo T7700 CPUは2つのコアを持ち、2.4GHzで駆動し、2400/ | ||
+ | ではどのようにそれらを使えばいいのでしょうか: | ||
+ | |||
+ | === Pステートとスロットリング === | ||
+ | |||
+ | '' | ||
+ | |||
+ | r265329以前では、周波数はEISTとスロットリング技術を混合して制御されていました。 | ||
+ | 前者がコア周波数と電圧の両方を制御し、後者はコア周波数のみを制御します。 | ||
+ | 両技術は電力削減に良い影響をもたらしますが、スロットリングの効果は小さく、C2ステートを使うことで完全に隠れてしまうでしょう。 | ||
+ | そんなわけで、''/ | ||
+ | |||
+ | <conf code> | ||
hint.p4tcc.0.disabled=1 | hint.p4tcc.0.disabled=1 | ||
hint.acpi_throttle.0.disabled=1 | hint.acpi_throttle.0.disabled=1 | ||
+ | </ | ||
- | After this sysctl | + | これ以後、'' |
+ | < | ||
dev.cpu.0.freq_levels: | dev.cpu.0.freq_levels: | ||
+ | </ | ||
- | ACPI may report extra performance level with frequency 1MHz above the nominal to control Intel Turbo Boost operation. For example, on Core i7-870 you may see: | + | 新規インストールにおいて、ACPIとP4TCCスロットリングは、今やデフォルトで無効になっています。 |
+ | Intel TurboBoost動作の制御のため、ACPIは公称周波数より1MHz高い追加の性能レベルを表示するかもしれません。 | ||
+ | 例えばCore i7-870では以下のように見えるでしょう: | ||
+ | |||
+ | |||
+ | < | ||
dev.cpu.0.freq_levels: | dev.cpu.0.freq_levels: | ||
+ | </ | ||
+ | |||
+ | 値の2933は2.93GHzを意味しますが、2934は状況に依存し3.2~3.6GHzを意味します。 | ||
- | , where value 2933 means 2.93GHz, but 2934, depending on situation, means 3.2-3.6GHz. | + | 私のケースでは、周波数/ |
- | In my case frequency/ | ||
- | C-states | + | === Cステート === |
- | C1 stops clock on some parts of CPU core during inactivity. It is safe, cheap and supported by CPUs for ages. System uses C1 state by default. | + | C1ステートはCPUが活動していない間、コアのいくつかの部分のクロックを停止します。 |
+ | これは安全で、性能へのインパクトも少なく、昔からCPUでサポートされています。 | ||
+ | システムは標準でC1ステートを使います。 | ||
- | C2 state allows | + | C2ステートは待機時にCPUの全コアクロックの停止を可能にします。 |
+ | これもまた安上がりですが、利用にあたりACPI/ | ||
+ | C2ステートの有効化は'' | ||
+ | <code conf> | ||
performance_cx_lowest=" | performance_cx_lowest=" | ||
economy_cx_lowest=" | economy_cx_lowest=" | ||
+ | </ | ||
- | Effect from this state is not so big when powerd | + | '' |
- | C3 state allows | + | C3ステートは、CPUの完全な内部クロック停止、電圧の削減、そしてシステムバスからの切り離しを可能にします。 |
+ | このステートは更なる省エネ効果をもたらすものの、安上がりではなく、トレードオフが求められます。 | ||
+ | C3ステートでCPUが完全に止まるや否や、FreeBSDがSMP環境でイベントソースとして利用する各CPUコア内のローカルAPICタイマーは機能しなくなります。システムタイムが止まり、スケジューリングを破壊し、これはシステムを死へと誘います。 | ||
+ | この問題に対する唯一の解決策は、いくつかの外部タイマを使う事です。 | ||
- | There is also pseudo-state known as C1E. It is a workaround in modern CPUs to work better with OS without | + | C1Eとして知られる疑似ステートもあります。 |
+ | これは、現代的なCPUとCステート非対応のOSとがより良く動くための次善策です。 | ||
+ | BIOSで有効にすると、OSからC1ステートが要求された際、CPUはより深いCステートに入れるようになります。 | ||
- | It is typical for AMD CPUs BIOSes to not expose real C-states to OS, but instead use only C1E mechanism. For example, it may work this way: when OS requests C1 for some CPU core, it enters | + | 典型的にAMD CPUとBIOSは実際のCステートをOSに見せませんが、かわりにC1Eメカニズムを用いるのみです。 |
+ | 例えば次のように働くでしょう:OSがいくつかのCPUコアにC1を要求するとコアはC2に入りますが、CPUパッケージの全コアがC2である時は、パッケージの全てがC3になるという具合です。 | ||
+ | あいにく、この働きはOSから完全に隠蔽されています。 | ||
- | FreeBSD 8.x | ||
- | Originally, before SMP era, FreeBSD used i8254 (for HZ) and RTC (for stats) chipset timers. | + | == FreeBSD 8.x == |
+ | もともと、SMP時代以前、FreeBSDはi8254(周波数用)とRTC(ステータス用)のチップセットタイマを使っていました。 | ||
+ | FreeBSD 8.xはこれらをSMPシステム用に復活させました。 | ||
+ | これらを使うために、''/ | ||
+ | |||
+ | <code conf> | ||
hint.apic.0.clock=0 | hint.apic.0.clock=0 | ||
+ | </ | ||
- | Also, to drop/rise voltage on C3, CPU needs time (57us for my system). It means that C3 state can't be effectively used when system is waking up often. To increase inactivity periods we should reduce interrupt rate as much as possible by adding to loader.conf: | + | C3の電圧昇降には、もちろんCPUは時間を必要とします(私のシステムでは57マイクロ秒)。 |
+ | これはつまり、頻繁にアクティブになるシステムにおいて、C3ステートは効率的に利用されないという事です。 | ||
+ | 非アクティブ期間を増やすため、可能な限り割り込みレートを下げるべきです。' | ||
+ | <code conf> | ||
kern.hz=100 | kern.hz=100 | ||
+ | </ | ||
- | It may increase system response time a bit, but it is not significant for laptop. Also we may avoid additional 128 interrupts per second per core, by the cost of scheduling precision, with using i8254 timer also for statistic collection purposes instead of RTC clock, by using another newly added option: | + | システムの応答時間がわずかに増えるかもしれませんが、ラップトップでは重大事ではありません。 |
+ | 同様に、RTCクロックの代わりに静的コレクション用途のi8254タイマーを用いて、スケジューリング精度に必要な1コアあたり秒間128回の追加割り込みを避けるとよいかもしれません。そのためには別の新規オプションを追加します: | ||
+ | <code conf> | ||
hint.atrtc.0.clock=0 | hint.atrtc.0.clock=0 | ||
+ | </ | ||
- | As result, system has only 100 interrupts per core and CPUs are using C3 with high efficiency: | + | 結果として、システムはコアあたり100回の割り込みで済み、CPUは効率的にC3を使っています: |
+ | < | ||
%sysctl dev.cpu |grep cx | %sysctl dev.cpu |grep cx | ||
dev.cpu.0.cx_supported: | dev.cpu.0.cx_supported: | ||
行 74: | 行 123: | ||
dev.cpu.1.cx_lowest: | dev.cpu.1.cx_lowest: | ||
dev.cpu.1.cx_usage: | dev.cpu.1.cx_usage: | ||
+ | </ | ||
- | Result of effective | + | 効率的なC3使用の結果、C2+powerdと比べて約2Wの削減です。 |
- | As soon as entering | + | AMD CPUにおいてC1Eステートへの突入は、予期せぬ制御不能なC3ステートへ突入しているかもしれず、ローカルAPICタイマーの停止を引き起こす可能性があるため、FreeBSD 8.xはC1E機能を完全にブロックします。 |
- | FreeBSD 9.x | ||
- | FreeBSD 9.x included new event timers subsystem -- eventtimers(4), | + | == FreeBSD 9.x == |
- | Also eventtimers(4) | + | FreeBSD 9.xは新イベントタイマーサブシステム'' |
+ | システムは最適と思われるタイマーを自動的に選択しますが、'' | ||
- | FreeBSD 9.x adds check whether it safe to use specific C-state with present event timer and may automatically block C2/C3 states, making it mostly safe. Nevertheless, | + | また'' |
+ | これにより'' | ||
+ | それでもなお'' | ||
- | On AMD CPUs FreeBSD 9.x blocks C1E only when local APIC timer is used. If the local APIC timer was ever used since boot, C1E will be blocked till the next reboot. You may want to force some other timer to be used in order to allow C1E to work. | + | FreeBSD 9.xでは具体的なCステートと現在のイベントタイマが安全に使えるかどうかのチェックが追加され、場合によってはより安全となるようC2/ |
+ | そうはいっても、いくつかのワークロードにおいて性能低下の可能性があるため、Cステートの利用は現在デフォルトでは有効になっておらず、手動で有効にしなければなりません。 | ||
+ | それと同時に、より新しいCPUにおいて、深いCステートを有効にすることはTurboBoost技術の利用を可能とし、これはシングルスレッドアプリケーションの性能向上につながります。 | ||
- | 2. Screen / Video | + | AMD CPUの場合、FreeBSD 9.xはローカルAPICタイマが使われている場合のみC1Eステートをブロックします。 |
+ | 起動の時点でローカルAPICタイマが使われていた場合、次回再起動までC1Eはブロックされるでしょう。 | ||
+ | C1Eの動作を許可するには、他のタイマが使われるよう強制する必要があるかもしれません。 | ||
- | Screen back light can consume much power. From 1.5W with minimal, up to 4W with maximal brightness on my laptop. So you should find the way (hardware or software) to control it and tune for level minimally required in specific conditions. In my case it is controlled via hardware buttons. Some other laptops allow to control brightness via hw.acpi.video.lcd0.brightness sysctl, supported by acpi_video(4). Graphics chip may consume significant amount of power, that may depend on used driver and its settings. | + | ==== 2. 画面/ |
- | Intel GPUs | + | 画面のバックライトは、そこそこ電気を食います。 |
+ | 私のラップトップでは、明るさによって最小1.5W~最大4Wでした。 | ||
+ | したがって、明るさを(ハード的またはソフト的に)制御する方法を見つけ、状況に応じて最小限のレベルに合わせるのが良いでしょう。 | ||
+ | 私の場合、それはハードウェアのボタンで制御されます。 | ||
+ | 他のいくつかのラップトップでは、明るさ制御を'' | ||
+ | グラフィックチップは使うドライバやその設定に応じて、著しい量の電力を消費する可能性があります。 | ||
- | On laptops with SandyBridge/ | ||
+ | === Intel GPU === | ||
+ | |||
+ | SandyBridge/ | ||
+ | ''/ | ||
+ | |||
+ | <code conf> | ||
drm.i915.enable_rc6=7 | drm.i915.enable_rc6=7 | ||
+ | </ | ||
- | enables using power-saving idle states of the GPU and reduces power consumption. | + | 電力を抑えるGPUの待機ステートの使用を有効化し、消費電力を削減します。 |
- | NVIDIA Optimus | + | <note warning> |
- | If you have a Laptop with an NVIDIA Optimus GPU where you cannot switch off either GPU off in the Laptop' | + | 参考: |
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * '' | ||
+ | === NVIDIA Optimus === | ||
+ | |||
+ | NVIDIA Optimus対応GPU搭載のラップトップを持っており、BIOSでGPUオフができなければ、単体NVIDIA GPUの無効化に使われる全ての基地のACPIコールを調査するお手製スクリプトがあります: | ||
+ | |||
+ | < | ||
% fetch https:// | % fetch https:// | ||
% make -C / | % make -C / | ||
% vim turn_off_gpu.sh | % vim turn_off_gpu.sh | ||
% sh turn_off_gpu.sh | % sh turn_off_gpu.sh | ||
+ | </ | ||
- | Once successful, it will store the succeeded call in | + | 成功したACPIコールは、以下に格納されます。 |
+ | < | ||
/ | / | ||
+ | </ | ||
+ | |||
+ | そして後続の処理で使用されます。 | ||
+ | ASUSのウルトラブックにおいて、これは6~8Wを節約し、バッテリー駆動時間を少なくとも3時間延ばします。 | ||
+ | 起動時にGPUを無効化するために、'' | ||
+ | 上述のIntel GPUセクションに加えて''/ | ||
+ | |||
- | and use it on subsequent tries. On an ASUS UltraBook, this saves about 6-8W and raises battery lifetime by a third at least. It can be put into rc.local or other custom rc.d scripts to disable the GPU on boot. It can be used in addition to the / | + | ==== 3. メモリ ==== |
- | 3. Memory | + | このラップトップは2枚の1GB DDR2-667 SODIMMメモリモジュールが組み込まれています。 |
+ | そのうち1枚を取ることで約1Wの節約、2枚の1GBモジュールを1枚の2GBモジュールに置き換えることでも約0.5Wの節約です。 | ||
- | This laptop has two 1GB DDR2-667 SODIMM memory modules installed. Removing one of them saves about 1W, Replacing two 1GB modules with single 2GB module also saves about 0.5W. | ||
- | 4. PCI devices | + | ==== 4. PCIデバイス ==== |
- | PCI bus provides method to control device power. For example, I have completely no use for my FireWire | + | PCIバスはデバイスの電源管理手法を提供します。 |
+ | たとえば、私は全く使わないFireWireコントローラと殆ど使うことがないEHCI USBコントローラを持っています。 | ||
+ | これらを無効化することで3Wの電力削減ができます。 | ||
+ | 全ての不要なPCIデバイスの無効化のために、それらのドライバを外したカーネルをビルドし、'' | ||
+ | <code conf> | ||
hw.pci.do_power_nodriver=3 | hw.pci.do_power_nodriver=3 | ||
+ | </ | ||
- | To enable devices back all you need to do is just load their drivers as modules. New EHCI USB driver in 8.x consumes much less power then previous one. | + | デバイスを再び有効化するために必要なことは、それらのドライバをモジュールとして単に読み込むだけです。 |
+ | 8.xの新しいEHCI USBドライバは以前のものよりも消費電力が少なくなっています。 | ||
- | 5. Radios | ||
- | WiFi and Bluetooth adapters can consume significant power when used (up to 2W when my iwn(4) WiFi is connected) or just enabled (0.5W). | + | ==== 5. 無線 ==== |
- | Some WiFi adapters (like my iwn(4)) support power-saving mode, disabling radio during inactivity periods. It can be enabled by adding | + | WiFiとBluetoothアダプタは、使用時(私の場合'' |
+ | ある種のWiFiアダプタ(私の'' | ||
+ | これは | ||
+ | <code conf> | ||
powersave | powersave | ||
+ | </ | ||
+ | オプションを'' | ||
+ | わずかな接続レイテンシの増加と引き換えに、大幅なWiFi消費電力を削減するでしょう。 | ||
- | option to the ifconfig interface options. This may significantly reduce WiFi power consumption by the price of slightly increased link latency. | ||
- | 6. HDA modem | + | ==== 6. HDAモデム ==== |
- | I was surprised, but integrated | + | 私は驚いたのですが、内蔵HDAモデムは使用していなくとも約1Wの電力を消費していました。 |
+ | 私は最も過激な解決策、すなわちソケットから物理的に取り外す選択をしました。 | ||
+ | モデムがあった場所のケース表面温度は下がりました。 | ||
- | 7. HDA sound | + | ==== 7. HDAサウンド ==== |
- | To reduce number of sound generated interrupts I have added to the loader.conf: | + | サウンドが生成する割り込み数を減らすため、'' |
+ | <code conf> | ||
hw.snd.latency=7 | hw.snd.latency=7 | ||
+ | </ | ||
- | On FreeBSD before 9-STABLE of 2012-03-10 | + | 2012-03-10のFreeBSD 9-STABLE以前では、最大バッファサイズを増やすことも有益かもしれません: |
+ | <code conf> | ||
hint.pcm.0.buffersize=65536 | hint.pcm.0.buffersize=65536 | ||
hint.pcm.1.buffersize=65536 | hint.pcm.1.buffersize=65536 | ||
+ | </ | ||
- | 8. HDD | + | ==== 8. HDD ==== |
- | First common recommendation is use tmpfs for temporary files. | + | まず、よくある推奨方法は一時ファイル用に'' |
+ | RAMは消費電力への影響が少なく、速くanyway with you。 | ||
+ | 待機ドライブの自動スピンダウン設定を試したくなるかもしれませんが、システムドライブしかないのであれば注意すべきです。スピンアップはドライブの寿命を縮めます。 | ||
+ | (SATA SSDを買うまでの)数ヵ月間、私は内蔵のPCI '' | ||
+ | ランダムリード要求についてはHDDより高速ですが、ランダムライトは非常に低速です。 | ||
+ | 加えて、SDカードは殆ど電力を食いません。 | ||
+ | USBフラッシュドライブを使う事も可能ですが、EHCI USBコントローラの消費電力に比べれば効果は限定的です。 | ||
+ | 私の2.5インチ日立製SATA HDDをスピンダウンすると、約1Wの削減です。 | ||
+ | 完全に取り外すと2Wの削減です。 | ||
- | 9. SATA | ||
- | Comparing to PATA, SATA interface uses differential signaling for data transfer. To work properly it has to transmit pseudo-random scrambled sequence even when idle. As you understand, that requires power. But SATA implements two power saving modes: PARTIAL and SLUMBER. These modes could be activated by either host or device if both sides support them. PARTIAL mode just stops scrambling, but keeps neutral link state, resume time is 50-100us. SLUMBER mode powers down interface completely, but respective resume time is 3-10ms. | + | ==== 9. SATA ==== |
- | The ata(4) driver has support for the SATA power management. There are hint.ata.X.pm_level loader tunables can be used to control it. Setting it to 1 allows drive itself to initiate power saving, when it wish. Values | + | PATAと比べると、SATAインタフェースはデータ転送に差動シグナルを用います。 |
+ | 正常動作のため、アイドル時でも疑似的なランダムスクランブルシーケンスを転送しなければなりません。 | ||
+ | お察しの通り、これは電力を要求します。 | ||
+ | しかしSATAは2つの省エネモードを実装しています:PARTIALとSLUMBERです。 | ||
+ | これらモードは、ホストとデバイの両方が対応していれば、どちらからでも有効にできます。 | ||
+ | PARTIALモードはスクランブル化を止めるだけで、ニュートラルなリンク状態を保ち、復帰時間は50~100マイクロ秒です。 | ||
+ | SLUMBERモードはインタフェースの電源を完全に落とし、各復帰時間は3~10ミリ秒です。 | ||
- | In my case PARTIAL mode saves 0.5W and SLUMBER | + | '' |
+ | '' | ||
+ | 1にするとドライブ自身の省エネ状態が開始されます。 | ||
+ | 2と3で、AHCI互換コントローラが毎コマンド完了後にPARTIAL/ | ||
+ | 新しい'' | ||
+ | これは4と5のモードもサポートし、性能劣化を最小化するモードです。 | ||
+ | SATA省エネモードはドライブのホットスワップを困難にすることに留意してください。なぜなら、リンクの電源が落ちている時、コントローラはドライブの存在を検出することが不可能だろうからです。 | ||
- | 10. USB | + | 私の場合、PARTIALモードは0.5W、SLUMBERは0.8Wの削減です。 |
- | USB devices can individually be switched to and from power save mode by running the following commands: | + | ==== 10. USB ==== |
- | # This command will enable automatic suspend of the USB device when no data traffic is pending. | + | 以下のコマンドを実行することで、USBデバイスは個々に省エネモードの切り替えができます: |
+ | |||
+ | < | ||
+ | # このコマンドはデータトラフィックがない間のUSBデバイスの自動サスペンドを有効にします | ||
usbconfig -d X.Y power_save | usbconfig -d X.Y power_save | ||
+ | </ | ||
- | # This command will disable | + | < |
+ | # このコマンドは与USBデバイスの省エネモードを無効にします | ||
usbconfig -d X.Y power_on | usbconfig -d X.Y power_on | ||
+ | </ | ||
- | The default for all devices except | + | USBハブを除く全てのデバイスのデフォルト値は" |
+ | USBデバイスの省エネモードを有効にする前に、デバイスのコンフィギュレーションでスクリプタ、すなわち" | ||
+ | USBのサスペンド/ | ||
+ | 省エネ機能は同様にUSBデバイス/ガジェットモードにも適用可能です。 | ||
- | Results | ||
- | So what have I got? To monitor real system power consumption I am using information provided by ACPI battery via acpiconf -i0 command: | + | ==== 結果 ==== |
- | Original system: | + | 私は何を得たでしょうか? |
+ | 実際のシステム消費電力をモニタするため、'' | ||
+ | 元のシステム: | ||
+ | < | ||
Design capacity: | Design capacity: | ||
Last full capacity: | Last full capacity: | ||
行 200: | 行 330: | ||
Present rate: 1621 mA | Present rate: 1621 mA | ||
Voltage: | Voltage: | ||
+ | </ | ||
- | Tuned system: | + | チューニングしたシステム: |
+ | < | ||
%acpiconf -i0 | %acpiconf -i0 | ||
Design capacity: | Design capacity: | ||
行 221: | 行 352: | ||
Present rate: 826 mA | Present rate: 826 mA | ||
Voltage: | Voltage: | ||
+ | </ | ||
- | So I have really doubled my on-battery time by this tuning - 4:47 hours instead of 2:24 with default settings. Cooling fan, previously running all the time, now idle most of time, when system is idle. Preinstalled vendor-tuned | + | このチューニングにより、なんとバッテリー駆動時間が2倍、デフォルト設定の2時間24分から4時間47分になりました。 |
+ | 冷却ファンは以前は常に動いていましたが、今ではシステムがアイドル時は殆ど待機状態です、 | ||
+ | 同じシステムのメーカーチューニングされたプリインストールのWindows XPでは、最大3時間20分ということでした。 | ||
-- Alexander Motin | -- Alexander Motin | ||
+ | |||
+ | ===== 翻訳履歴 ===== | ||
+ | |||
+ | * 2019-12-01 [[https:// | ||
+ | * 2015-03-23 翻訳開始 | ||
+ |