本文共 760 字,大约阅读时间需要 2 分钟。
使用KVM虚拟化,当虚拟机的vcpu不是很多时,可以通过绑定物理cpu的方式提到虚拟机的性能。实验证明Host整体性能大约能提高5%,单台虚拟机性能最高提高10%。
实验数据(数据来自同事,Thanks Jack):
纵坐标表示虚拟机编译2.6.32内核花费的时间,可以看到绑定cpu后性能有一定提高。
PS:前提是虚拟cpu总个数不多于物理cpu总个数。
虚拟机的虚拟cpu有1个,实体机物理cpu有8个,可以通过以下方式绑定cpu,绑定的动作不一定要在虚机启动时,可以在任何时候:
[root@ci13sjcmp03 ~]# virsh vcpuinfo 1
CPU Affinity: yyyyyyyy <-------虚拟cpu与物理cpu对应关系位图, 'y'表示虚拟cpu0能绑定到物理cpu1, '-'表示虚拟cpu0不能绑定到其他cpu
[root@ci13sjcmp03 ~]# virsh vcpupin 1 0 1 <-------将domain 1的cpu0绑定到物理cpu1
[root@ci13sjcmp03 ~]# virsh vcpuinfo 1
CPU Affinity: -y------ <-------虚拟cpu与物理cpu对应关系位图, 'y'表示虚拟cpu0能绑定到物理cpu1, '-'表示虚拟cpu0不能绑定到其他cpu