3 ms·
Things are so much better if you are not writing apps for general public (mine are trading-related). You can tell your few clients — make sure that the access t
by atemerev 8y ago
Things are so much better if you are not writing apps for general public (mine are trading-related). You can tell your few clients — make sure that the access to mmapped file is exclusive — and get away with it.
And yes, mmap is the awesomest thing out there.
- CoolGuySteve 8y agoI’ve moved away from mmap for trading in favor of a separate write thread. While mmap is fast, the combination of factors that can make it decide to stall your thread while it commits to disk is difficult to manage from an operational standpoint. A slight misconfiguration is all it takes to introduce a rare and hard to notice multi-millisecond delay. Whereas with a spinlocked sized-reserved vector, the fail state performance is however long it takes to allocate more space which is on the level of microseconds. You do pay 50-150ns for that spinlock though.
- jacobush 8y agoOr better yet, mmap in a read-write-thread?
- CoolGuySteve 8y agoYa sure, go nuts on the other thread. It’s not critical to trading. I normally fprintf all sorts of time stamps, log level info, and handle formatting over there. Just make sure you put it on another core to protect your cache. But if you want mmap, you do you.
- gpderetta 8y agoWritable mappings are problematic though, because of the unpredictable pauses caused by the TLB shutdowns required to maintain coherence of the dirty flag.