tuned: tuning daemon

tuned について

tunedは、cpu,disk,kernelなどに関する複数のパラメーターを一括して一つのプロファイルとして保存し、
コマンド一発で設定・切り替えを行うことができるツールです。

CentOS7の場合は、tuned のパッケージにはあらかじめいくつかのプロファイルが用意されていて
その中で変更するだけでも性能の違いを実感できますし、その他にカスタムのプロファイルも作成することができます。

デフォルトで用意されているプロファイル

  • デフォルトで用意されているプロファイルには以下の9つがあります。
    また、tuned-profile-xxx といったパッケージ名で用意されたものをインストールすると
    RHELのAtomic Host、Laptop、Oracleといった環境向けの他、spindown-diskといったディスクの省電力向けの
    プロファイルも追加されます。
# tuned-adm list
Available profiles:
- balanced                    - General non-specialized tuned profile
- desktop                     - Optmize for the desktop use-case
- 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.  This is the default profile for RHEL7.
- virtual-guest               - Optimize for running inside a virtual guest.
- virtual-host                - Optimize for running KVM guests

設定方法

manページを見ると、throughput-performanceがRHEL7のデフォルトである旨のことが書かれていますが
実際にはbalancedとなっているケースが多いです。

$ tuned-adm active :  現在有効となっているプロファイルが表示されます。

$ tuned-adm profile balanced : 左のケースでは"balanced"というプロファイルに設定されます。
このコマンドを実行するだけで、OSやサービスの再起動の必要なく、すぐに設定が適用されます。

実際に変更されているパラメーター

パッケージに含まれているプロファイルについては、/usr/lib/tuned/[プロファイル名]/tuned.conf に
実際に変更されているパラメーターとその設定値が記載されています。

下記はthroughput-performanceのtuned.confで
cpupower, x86_energy_perf_policyで設定されるようなCPUの電力管理系のプロファイル、
ディスクのread_ahead_kbのサイズ、kernelのパラメーターに関して記載されていることがわかります。

----
[main]
summary=Broadly applicable tuning that provides excellent performance across a variety of common server workloads.  This is the default profile for RHEL7.

[cpu]
governor=performance
energy_perf_bias=performance
min_perf_pct=100

[disk]
readahead=>4096

[sysctl]
kernel.sched_min_granularity_ns = 10000000
kernel.sched_wakeup_granularity_ns = 15000000
vm.dirty_ratio = 40
vm.dirty_background_ratio = 10
vm.swappiness=10
----

性能の比較

結論から言えば、”throughput-performance” がたいていのケースではおすすめです。

ネットワーク、ファイルコピーの速度比較

  • InfiniBand : QDR
  • OS : CentOS7.2
  • Mode : Connected Mode
balanced network-throughput throughput-performance
Netperfでの速度比較 21,656 Mbps 23,909 Mbps 25,528 Mbps
ddで作成した10GBのファイルのコピー時間(NFS越し) 0m12.873s 0m8.616s 0m8.624s

fioでのIOPS測定

  • Device /dev/md0(NVMe x4)
  • Filesystem:XFS
  • Queue Depth : 32
  • numjobs: 1
Random Read(4K) Random Write(4K)
balanced 200569 IOPS 227951 IOPS
latency-performance 268315 IOPS 289342 IOPS

bowtie2 の実行時間比較

  • bowtie2 : 2.3.1
  • index : hg19
  • fastq : SRR067579_1.fastq, SRR067579_2.fastq,
threads throughput-performance
(intel_pstate)
balanced
(intel_pstate)
throughput-performance
(acpi_cpufreq)
8 2479s 2477s 2507s
16 1276s 1290s 1279s
32 679s 690s 676s
56 545s 649s 616s

NAMDの性能比較

  • NAMD : Nightly Build(2017-06-30)
  • data : stmv.namd
  • OS : CentOS 7.3
threads throughput-performance(ns/day) balanced(ns/day)
4 0.0578 0.0555
8 0.1083 0.1077
16 0.2094 0.2086
32 0.4028 0.3931
上の例では、ベンチマークツールで1-4割、アプリケーションレベルで数%から2割程度の性能差が出ています。

もちろん、常時"throughput-performance"に設定しておいても良いのですが、
コマンド一発でプロファイルの切り替えができるという特性を考えると
ジョブ実行前に"throughput-performance"に切り替え、ジョブ完了後に省電力モードに戻す
といった使い方(ジョブスケジューラーへのジョブ投入スクリプト内に追記)はシンプルで
効果もあるかもしれません。(省電力の効果のほどはいずれ確認したいと思いますが)

また、仮にアプリケーションやデータの種類などそれぞれに最適のプロファイルを用意できたとすれば
ジョブスケジューラー側の機能を使ってジョブの名前やその他の値から自動的にプロファイルを選択、
設定して実行させるいった使い方もできるのではないかと思います。