4 ms·
"Assumption 1. Using write() instead of implicitly writing to a memory map would lead to better performance." I've seen this mentioned in the context of RocksD
by fiatmoney 12y ago
"Assumption 1. Using write() instead of implicitly writing to a memory map would lead to better performance."
I've seen this mentioned in the context of RocksDB; but contradicted by e.g. SQLite. The case for mmap has always been that one avoids the overhead of a system call & some double-copying, and in either case it just dirties the page cache and is only "really" written in periodic flushes (assuming it's not writing via direct IO). Can someone explain what the bottleneck is on the mmap side and why write() might be faster?
- deleted 12y ago[deleted]
- cbsmith 12y agoBecause most POSIX systems, including Linux, provide even almost nothing to help with hinting about page management, but write() (and the implicit copy) provides better ways to be explicit about that.
- fiatmoney 12y agoCould you go into more detail? mmap lets you specify some flags about access patterns; write() doesn't give you any such hints.
- woadwarrior01 12y agoCorrect me if I'm wrong. I think he's talking about posix_fadvise() [1], which lets you pre declare access patterns for an fd. And you're talking about madvise() [2]. [1]: http://linux.die.net/man/2/posix_fadvise http://linux.die.net/man/2/posix_fadvise [2]: http://linux.die.net/man/2/madvise http://linux.die.net/man/2/madvise
- cbsmith 12y ago...and madvise hardly does anything.
- cbsmith 12y agoYou ever tried doing an append only mmap? ;-)
- perbu 12y agoWe (Varnish Software) still use mmap, just not for writing. The problem with mmap is that you can't use it to wrote whole pages at a time as the CPU will trap and ask the OS to merge the page you're writing to. mmaps are still great as the page cache still manages the split cache between disk and memory.