Welcome to the Linux Foundation Forum!

Sendfile and memory cache

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.

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

  • Posts: 501
    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.
  • 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:
    1. ~ > free
    2. total used free shared buffers cached
    3. Mem: 16633136 3370264 13262872 0 520812 2391332
    4. -/+ buffers/cache: 458120 16175016
    5. 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.
  • I got confirmation that the reason of above issue is memory allocation limit in 32-bit kernel (as expected).

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training