差分
このページの2つのバージョン間の差分を表示します。
次のリビジョン | 前のリビジョン 次のリビジョン 両方とも次のリビジョン | ||
freebsd:tuning_power_consumption [2015-03-23 12:46] Decomo 作成 |
freebsd:tuning_power_consumption [2019-11-29 13:09] Decomo |
||
---|---|---|---|
行 1: | 行 1: | ||
====== FreeBSD WikiのTuningPowerConsumptionの日本語訳 ====== | ====== FreeBSD WikiのTuningPowerConsumptionの日本語訳 ====== | ||
- | TuningPowerConsumption | + | ===== 消費電力チューニング ===== |
- | Alexandar Motin writes: | + | Alexandar Motin 記す: |
- | I would like to summarize some of my knowledge on reducing | + | FreeBSDでの消費電力削減に関して私の知るところをまとめ、FreeBSD 8.x/9.xで実装されたいくつかの新しい事柄を説明しようと思います。このストーリーの主人公は、C2D T7700 2.4GHz CPU、965GMチップセット、SATA HDDを搭載した私の12インチAcer TravelMate 6292ラップトップです。 |
- | Modern systems, especially laptops, are implementing big number of power-saving technologies. Some of them are working automatically, | + | 現代のシステム、とりわけラップトップは数多くの省エネ技術を搭載しています。それらのいくつかは自動で機能するものの、その他は効果を発揮するための明示的な設定と特別なシステムチューニング、トレードオフが存在します。 |
- | 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: | + | ==== 1. CPU ==== |
- | P-states and throttling | + | CPUはシステムで最も消費する部分です。 |
+ | フル稼働下ではそれだけで40W以上の電力を消費しますが、実際のラップトップ利用で最も重要なのはアイドル消費電力です。 | ||
+ | Core2Duo T7700 CPUは2つのコアを持ち、2.4GHzで動作し、2400, | ||
+ | では、どうやってそれを使うのでしょうか: | ||
- | Enabling powerd allows to effectively control CPU frequency/ | + | === Pステートとスロットリング === |
+ | powerdを有効にすると、CPU負荷に応じてCPUの周波数/ | ||
+ | 最近のシステムではpowerdがそれらを完全に透過的に扱うことが可能です。 | ||
+ | デフォルトでは、周波数はEISTとスロットリングテクノロジーの絡み合いを通じて制御されます。 | ||
+ | 前者はコア周波数と電圧の両方を制御し、後者はコア周波数のみを制御します。 | ||
+ | 両テクノロジーは確かな省電力効果を生みます。 | ||
+ | しかし、スロットリングの効果は小さく、またC2ステートを使うことで完全に隠れてしまいます。そんなわけで、スロットリング制御を無効化するために''/ | ||
+ | |||
+ | <code conf> | ||
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機能の制御のために、ACPIは公称クロック周波数より1MHz多い追加の性能レベルを報告するかもしれません。 |
+ | 例えば、Core i7-870では下記のようなレポートを見ることができるでしょう: | ||
+ | < | ||
dev.cpu.0.freq_levels: | dev.cpu.0.freq_levels: | ||
+ | </ | ||
- | , where value 2933 means 2.93GHz, but 2934, depending on situation, means 3.2-3.6GHz. | + | ここで2933は2.93GHzを意味しますが、2934はシチュエーションに依存し、3.2~3.6GHzを表します。 |
- | In my case frequency/voltage control saves about 5W of idle power. | + | 私のケースでは、周波数/電圧制御はアイドル電力を約5W節約します。 |
- | 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-チップセット-CPUの正確な協調動作が求められます。 | ||
+ | C2ステートの使用は'' | ||
+ | < | ||
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として知られる擬似ステートもあります。 |
+ | これはCステート対応のないOSで、モダンなCPUがより上手く動くための次善策です。 | ||
+ | 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 | + | == FreeBSD 8.x == |
- | Originally, before | + | 当初、SMP時代の前、FreeBSDはi8254(周波数用)とRTC(ステート用)チップセットタイマーを使いました。 |
+ | FreeBSD 8.2はそれらをSMPシステム用に蘇らせます。 | ||
+ | それらを使うために、'' | ||
+ | < | ||
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は時間を必要とします(私のシステムでは57us)。 |
+ | これはシステムがしばしば目覚める場合、C3ステートが効率的に利用されない事を意味します。 | ||
+ | 非アクティブ期間を増加させるには、' | ||
+ | < | ||
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回の追加割込みを回避することもできるでしょう。 | ||
+ | < | ||
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: | 行 116: | ||
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 == |
- | FreeBSD 9.x included new event timers subsystem -- eventtimers(4), that allows to support more types of the timer hardware, including HPET, present in most of modern chipsets and invariant to CPU power management. System automatically chooses timer it consider best, but you may check and dynamically change timer to use via sysctl. | + | FreeBSD 9.xは新しいイベントタイマーサブシステム'' |
+ | システムは最適と思われるタイマーを自動的に選択しますが、'' | ||
- | Also eventtimers(4) | + | また、'' |
+ | これにより'' | ||
+ | それでもなお'' | ||
- | 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, | + | 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. |
+ | それでもなお、ある種の作業負荷において性能低下の原因となるため、Cステートの使用は今も標準では有効になっておらず、手動で有効にしなければなりません。 | ||
+ | と同時に新しいCPUでは、より深いCステートの有効化はTurboBoostテクノロジーの利用を可能にし、これによりシングルスレッドアプリケーション性能が増加するでしょう。 | ||
- | On AMD CPUs FreeBSD 9.x blocks | + | AMD CPUでは、FreeBSD 9.xはローカルAPICタイマーが使われている時に限りC1Eをブロックします。 |
+ | もし起動時からずっとそのローカルAPICタイマーが使われていた場合、次の再起動までC1Eはブロックされます。 | ||
+ | C1E動作を許可するために、強制的にその他のタイマーを使うのがよいかもしれません。 | ||
- | 2. Screen | + | ==== 2. 画面 |
- | 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. | + | 画面のバックライトは多くの電力を消費する可能性があります。 |
- | Intel GPUs | + | 私のラップトップでは最低輝度の1.5Wから最大輝度の4Wでした。 |
+ | 従って、(ハードウェアやソフトウェアで)輝度を制御する方法を見つけ、状況に応じた最低輝度レベルの調整を行うべきです。 | ||
+ | 私の場合、ハードウェアのボタンで制御しました。 | ||
+ | '' | ||
+ | グラフィックチップはかなりの量の電力を消費する可能性があり、それは使用するドライバとその設定によって決まるかもしれません。 | ||
- | On laptops with SandyBridge/ | + | === Intel GPUs === |
+ | 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 | + | === NVIDIA Optimus |
If you have a Laptop with an NVIDIA Optimus GPU where you cannot switch off either GPU off in the Laptop' | If you have a Laptop with an NVIDIA Optimus GPU where you cannot switch off either GPU off in the Laptop' | ||
行 116: | 行 175: | ||
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 / | 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. Memory | + | ==== 3. メモリ ==== |
- | This laptop has two 1GB DDR2-667 SODIMM | + | このラップトップは2枚の1GB DDR2-667 SODIMMメモリモジュールが取り付けられています。 |
+ | そのうちの1枚を外すと約1Wの節電、2枚の1GBモジュールを1枚の2GBモジュールに置き換えると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 | + | ==== 5. 無線 ==== |
- | WiFi and Bluetooth | + | WiFiとBluetoothのアダプタは、使用時(当方の'' |
- | Some WiFi adapters (like my iwn(4)) support power-saving mode, disabling radio during inactivity periods. It can be enabled by adding | + | いくつかのWiFiアダプタ(当方の'' |
+ | これを有効にするには、以下のオプションを'' | ||
+ | < | ||
powersave | powersave | ||
+ | </ | ||
- | option to the ifconfig interface options. This may significantly reduce | + | この有意義なWiFi消費電力の削減は、リンク遅延の若干の増加と引き換えに行われる可能性があります。 |
- | 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 is cheap, fast and anyway with you. Also you may try to setup automatic idle drive spin-down, but if it is the only system drive you should be careful, as every spin-up reduces drive' | First common recommendation is use tmpfs for temporary files. RAM is cheap, fast and anyway with you. Also you may try to setup automatic idle drive spin-down, but if it is the only system drive you should be careful, as every spin-up reduces drive' | ||
- | 9. SATA | + | ==== 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. | 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. | ||
行 165: | 行 241: | ||
In my case PARTIAL mode saves 0.5W and SLUMBER - 0.8W of power. | In my case PARTIAL mode saves 0.5W and SLUMBER - 0.8W of power. | ||
- | 10. USB | + | ==== 10. USB ==== |
USB devices can individually be switched to and from power save mode by running the following commands: | USB devices can individually be switched to and from power save mode by running the following commands: | ||
行 177: | 行 254: | ||
The default for all devices except USB HUBs is power on. You should check the configuration descriptor of your device, that the " | The default for all devices except USB HUBs is power on. You should check the configuration descriptor of your device, that the " | ||
- | Results | + | ==== 結果==== |
So what have I got? To monitor real system power consumption I am using information provided by ACPI battery via acpiconf -i0 command: | So what have I got? To monitor real system power consumption I am using information provided by ACPI battery via acpiconf -i0 command: |