Ngx_cpuinfo / kvm & qemu / ngx_cacheline_size

Hi,

I have virtual machine running on qemu / kvm.

cat /proc/cpuinfo give :
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 2
model name : QEMU Virtual CPU version 1.1.2
stepping : 3
microcode : 0x1
cpu MHz : 1999.999
cache size : 4096 KB
fpu : yes
fpu_exception : yes
cpuid level : 4
wp : yes
flags : fpu de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pse36
clflush mmx fxsr sse sse2 syscall nx lm up rep_good nopl pni cx16 popcnt
hypervisor lahf_lm
bogomips : 3999.99
clflush size : 64
cache_alignment : 64
address sizes : 40 bits physical, 48 bits virtual
power management:

the code in ngx_cpuinfo use the model value (2), and set
the ngx_cacheline_size to 32, instead of 64 given by cache_alignment in
/proc/cpuinfo.

On same host using vmware virtualization, /proc/cpuinfo give a model of
45,
ngx_cacheline_size is set to 64.

I think I can have low performances problems due to the
ngx_cacheline_size
of 32 under qemu virtualization. Do you confirm ?

Do you think we have to change ngx_cpuinfo code to give
ngx_cacheline_size
64 on qemu env ?

Regards,

Bertrand

Hello!

On Sun, Dec 02, 2012 at 12:15:03PM +0100, Bertrand P. wrote:

stepping : 3
bogomips : 3999.99
ngx_cacheline_size is set to 64.

I think I can have low performances problems due to the ngx_cacheline_size
of 32 under qemu virtualization. Do you confirm ?

Do you think we have to change ngx_cpuinfo code to give ngx_cacheline_size
64 on qemu env ?

Incorrectly detected cache line size may result in slightly
non-optimal performance in some situations (I wouldn’t suppose 32
vs 64 to result in more than a few percent difference in real word
nginx operation though, even on real hardware). On the other
hand, using virtualization ensures non-optimal performance in all
situations, so one using virtualization probably don’t care
anyway.

(In any case there are no plans to change Intel CPUs cache line
size detection code to support fake emulated qemu CPUs. In
particular because it’s not possible to tell which cache line size
is more effective for a given emulated CPU. It’s up to you to
configure qemu to emulate a CPU with a cache line size most
effective on your hardware if you think you care.)


Maxim D.

Ok, thx you for answering.

Regards,

Bertrand