Mio – Cross-platform header-only C++11 library for memory-mapped file IO
1–10 of 79 posts
Re: Mio – Cross-platform header-only C++11 library for memory-mapped file IO
#2Re: Mio – Cross-platform header-only C++11 library for memory-mapped file IO
#3This just isn't really something that can be cleanly abstracted to do what you want it to do, even if you can make the code "look" the same.
But again, it looks like a nice, clean, modern C++ library. Just IMHO misapplied.
Re: Mio – Cross-platform header-only C++11 library for memory-mapped file IO
#4The code seems clean. I'm not sure this is a great idea in practice, though. Generally the only good reason for mapping stuff out of the filesystem is performance, and VM behavior with mmap() varies wildly across systems (and filesystem backends, and drivers if it's a hardware device, and hardware if it's a framebuffer, and...). Frankly on windows this is AFAIK a mostly-unheard-of technique. No one does mapping. This…
Just a data point, but we use memory mapping (both with and without names) in our product that runs on Windows.
Re: Mio – Cross-platform header-only C++11 library for memory-mapped file IO
#5Re: Mio – Cross-platform header-only C++11 library for memory-mapped file IO
#6I wonder: is there something like this written in rust?
Re: Mio – Cross-platform header-only C++11 library for memory-mapped file IO
#7Re: Mio – Cross-platform header-only C++11 library for memory-mapped file IO
#8Wow, I did not expect this. I'm really touched. I wrote this as a small utility for my own consumption because I was unsatisfied with the existing selection at the time, so I'm both surprised and delighted to learn that people are finding it useful. Although to be completely frank, I think this library is way too small and insignificant to deserve a spot on HN's front page, but it definitely made my day. So thank you kind stranger who posted it!
Re: Mio – Cross-platform header-only C++11 library for memory-mapped file IO
#9The name definitely made me think of Rust's mio. On the other hand, `namespace cplusplus` and `mod rust` maybe are disjoint.
Re: Mio – Cross-platform header-only C++11 library for memory-mapped file IO
#10Creating a new memory mapping can be pretty expensive! On both Windows and Linux, it involves taking a process-wide reader-writer lock in exclusive mode (meaning you get to sit and wait behind page faults), doing a bunch of VMA tree manipulation work, doing various kinds of bookkeeping (hello, rmap!) and then, after you return to userspace, entering the kernel again in response to VM faults just to fill in a few pages by doing, inside the kernel, what amounts to a read (2) anyway!
Sure, if you use mmap, you get to look at the page cache pages directly instead of copying from them into some application-provided buffer, but most of the time, it's not worth the cost.
There are exceptions of course, but you should always default to conventional reads.