Home Linux Community Forums Hardware Storage Sendfile and memory cache

Sendfile and memory cache

Link to this post 05 Nov 09

Could you please confirm or denied that system call sendfile(), opposite to read()+write() operations, does not use memory cache at all.

What means that i.e. in an Apache serving many times the same static content turning EnableSendfile Off might bust the performance, because files would be read from memory rather then from disk.

Link to this post 06 Nov 09

The sendfile() function uses kernel instead of user-space memory. That means that your application heap will not be increased appreciably. However, the OS will still cache the data as that is not a matter of the application calling sendfile() as it is a matter of how the OS caches data read from disc. So, yes, it will use system memory to cache the data.

Link to this post 06 Nov 09

Thanks for great response. As each good response it lead to further question.

Do data cached by kernel have to fit into 1GB of kernel memory?

Is there different in handling this memory between 32bit and 64bit version of x86 arch?

I'm asking because on a busy 32-bit server (apache serving static content - from 2 or 3 week non-stop) I see:

~ > free
total used free shared buffers cached
Mem: 16633136 3370264 13262872 0 520812 2391332
-/+ buffers/cache: 458120 16175016
Swap: 1052248 88 1052160

My estimation is that if the system kept all served files in the cache the memory would filled in few hours. So there are some software limit of the memory usage.

Link to this post 07 Nov 09

I got confirmation that the reason of above issue is memory allocation limit in 32-bit kernel (as expected).

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Linux Training / Board