APC - tuning apc.mmap_file_mask
Solution 1:
/tmp/apc.XXXXXX -> This mmap file mask is a normal filesystem based mmap and uses mkstemp to create a unique temporary file which is mmap'd. The 6 'X's are replaced by the unique string to make the filename unique. This is just writing data to a file in filesystem.
/tmp/apc.shm.XXXXXX -> Note that it_must_ be only /apc.shm.XXXXXX on linux systems. The difference from straight file-backed mmap is this mechanism creates a temporary file via mktemp() call and makes a call to shm_open() which creates and opens a new, or opens an existing, POSIX shared memory object. A POSIX shared memory object is in effect a handle which can be used by unrelated processes to mmap the same region of shared memory. I've not tried this before but I think it can have as minimum as 3 'X's (so apc.shml.XXX also should work).
/dev/zero -> mmap'ing /dev/zero
is an anonymous memory mapping which means its the memory object having no associated file and all the contents initialized to zero. If you don't specify mmap_file_mask, the APC would use the anonymous map (with flags MAP_SHARED and MAP_ANON). Thus, specifying /dev/zero
and not specifying mmap_file_mask are equivalent in the sense that both of them are anonymous map. Historically, MAP_SHARED and MAP_ANON together in linux had no support before kernel version 2.4.
Performance-wise, 3 will do the best since file-backed mmap'ing has considerably more disk I/O. So, 3 must be the fastest as it has no backed file and is part of actual memory itself, then 2 and 1 finally. However, this is only theory and practical benchmarks across various configuration can prove the reality. However, the disadvantage of anonymous mapping (& shared memory mapping) is that mmap'd memory is not persistent between the application executions thus loosing cache on restart.