# Ngx\_cpuinfo / kvm & qemu / ngx\_cacheline\_size

**URL:** <https://www.ruby-forum.com/t/ngx-cpuinfo-kvm-qemu-ngx-cacheline-size/224918>\
**Category:** NGINX\
**Created:** [December 2, 2012, 12:15pm UTC](https://www.ruby-forum.com/t/ngx-cpuinfo-kvm-qemu-ngx-cacheline-size/224918 "2012-12-02T12:15:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [December 2, 2012, 12:15pm UTC](https://www.ruby-forum.com/t/ngx-cpuinfo-kvm-qemu-ngx-cacheline-size/224918/1 "2012-12-02T12:15:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Bertrand\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e19b73/32.png) [@Bertrand\_P](https://www.ruby-forum.com/u/Bertrand_P)\
**Post date:** [December 3, 2012, 2:55pm UTC](https://www.ruby-forum.com/t/ngx-cpuinfo-kvm-qemu-ngx-cacheline-size/224918/2 "2012-12-03T14:55:56Z")

</div>

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.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.

---

<div class="post-metadata">

**Author:** ![Bertrand\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e19b73/32.png) [@Bertrand\_P](https://www.ruby-forum.com/u/Bertrand_P)\
**Post date:** [December 3, 2012, 4:06pm UTC](https://www.ruby-forum.com/t/ngx-cpuinfo-kvm-qemu-ngx-cacheline-size/224918/3 "2012-12-03T16:06:39Z")

</div>

Ok, thx you for answering.

Regards,

Bertrand
