News for hackers. Stuff that matters.
Re:Mio – Cross-platform header-only C++11 library for memory... by gok on Saturday October 20, 2018 @01:57PM (#18264503)
The cost of the second kernel trip (on the first page fault) is often mitigated by speculative read-ahead, or the fact that a given page is often in the UBC already. And file-backed memory doesn't contribute to dirty memory. And mmap() makes it easy to use read-only memory, which catches memory corruption bugs. Plus it's easier to use huge pages, which reduces TLB pressure.

I <3 mmap

Re:Mio – Cross-platform header-only C++11 library for memory... by nemo1618 on Saturday October 20, 2018 @11:24PM (#18266592)
>mmap() makes it easy to use read-only memory, which catches memory corruption bugs

You might appreciate this toy Go package I hacked together: https://github.com/lukechampine/freeze

It uses mmap and mprotect to "freeze" Go objects; if you try to modify a frozen object, the program crashes.

Re:Mio – Cross-platform header-only C++11 library for memory... by gok on Sunday October 21, 2018 @12:16AM (#18266706)
Nice!
Re:Mio – Cross-platform header-only C++11 library for memory... by jzwinck on Saturday October 20, 2018 @08:25PM (#18266202)
Memory mapped I/O actually prevents the use of huge pages if the backing storage is an actual disk. See https://lwn.net/Articles/718102/

Do you know of a way around that, aside from building your own patched kernel?

Re:Mio – Cross-platform header-only C++11 library for memory... by gok on Sunday October 21, 2018 @12:28AM (#18266733)
Yeah you need to move your files to tmpfs, but I still consider that easier than dealing with making it happen with malloc+read