Search code examples
solarismmapzfs

Memory usage of zfs for mapped files


I read the following on https://blogs.oracle.com/roch/entry/does_zfs_really_use_more

There is one peculiar workload that does lead ZFS to consume more memory: writing (using syscalls) to pages that are also mmaped. ZFS does not use the regular paging system to manage data that passes through reads and writes syscalls. However mmaped I/O which is closely tied to the Virtual Memory subsystem still goes through the regular paging code . So syscall writting to mmaped pages, means we will keep 2 copies of the associated data at least until we manage to get the data to disk. We don't expect that type of load to commonly use large amount of ram

What does this mean exactly? does this mean that zfs will "uselessly" double cache any memory region that is backed by a memory mapped file? or does "using syscalls" mean writing using some other method of writing that I am not familiar with. If so, am I better off keeping the working directories of files written this way on a ufs partition?


Solution

  • Does this mean that zfs will "uselessly" double cache any memory region that is backed by a memory mapped file?

    Hopefully, no.

    or does "using syscalls" mean writing using some other method of writing that I am not familiar with.

    That method is just regular low level write(fd, buf, nbytes) system calls and similars and not what memory mapped files are designed to support: accessing file content just with reading / writing memory by using pointers, using the file data as a byte array or whatever.

    If so, am I better off keeping the working directories of files written this way on a ufs partition?

    No, unless memory mapped files that are also written to using system calls sum to a significant part of your RAM workload, which is quite unlikely to happen.

    PS: Note that this blog is almost ten years old. There might have been changes in the implementation since that time.