An answer to this question:
Can I do a copy-on-write memcpy in Linux?
suggests one can achieve copy-on-write of a bunch of memory by:
- opening a file
mmap()
'ing the source to a filemmap()
'ing the destination to the same file (withMAP_PRIVATE
)
But this seems rather fishy w.r.t. speed. I'm sure the I/O costs you something; and maybe there's more unforeseen overhead other than page table work.
So, what can be said with certainty about the speed of this procedure (perhaps as a function of the Linux kernel version)?