
cpuのモードを切り替えてサーバを早く動かす方法のメモ(非クラウド限定)
cpuのモードを切り替えてサーバを早く動かす方法のメモ
まとめ
- cpu governorの設定を変更する
- Ubuntuの場合 cpufrequtilsを使う
- RedHatの場合 tuned-admを使う
cpuのモードを切り替えて処理を高速化する
OS毎にcpuのモードが存在して、大体のところ、省電力 or エコモードみたいなものに設定されている そのモードを電力無視&cpuパフォーマンス最優先モードにすると、パフォーマンスが改善する(思いの外変わった)
クラウドではないオンプレやレンサバ、個人のローカルPCでのみ有効なので注意。
Ubuntuではcpuのgovernor設定をperformanceに、 RedHatでは同設定をlatency-performanceにすることで変更できる
設定方法 Ubuntu
sudo apt install cpufrequtils
cat /etc/default/cpufrequtils
GOVERNOR="ondemand" <-- ここをperformanceに変更する
ENABLE="true"
MIN_SPEED="1000000"
MAX_SPEED="3000000"
LATENCY_THRESHOLD="10"
設定ファイルの変更後に systemctl でcpufrequtilsを再起動すれば終わり
設定方法 redhat
tunedのパッケージが入っていれば、tuned-admのコマンドが利用できる
sudo tuned-adm profile latency-performance
sudo tuned-adm active
ちなみに設定できる値はlistオプションで確認できる
$ tuned-adm list
Available profiles:
- balanced - General non-specialized tuned profile
- desktop - Optimize for the desktop use-case
- hpc-compute - Optimize for HPC compute workloads
- latency-performance - Optimize for deterministic performance at the cost of increased power consumption
- network-latency - Optimize for deterministic performance at the cost of increased power consumption, focused on low latency network performance
- network-throughput - Optimize for streaming network throughput, generally only necessary on older CPUs or 40G+ networks
- powersave - Optimize for low power consumption
- throughput-performance - Broadly applicable tuning that provides excellent performance across a variety of common server workloads
- virtual-guest - Optimize for running inside a virtual guest
- virtual-host - Optimize for running KVM guests
Current active profile: latency-performance
まとめ
- cpu governorの設定を変更する
- Ubuntuの場合 cpufrequtilsを使う
- RedHatの場合 tuned-admを使う