3 ms·
I have known for some time to open /proc/self/mem or use hugetblfs, then send the fd to another process to mmap() so I can share pages; I've made a similar API
by geocar 4y ago
I have known for some time to open /proc/self/mem or use hugetblfs, then send the fd to another process to mmap() so I can share pages; I've made a similar API to the proposed by combining memfd and /proc/self/fd/X. It seems like this API more-directly implements these patterns, but is that it? Or is it something else? Like, is this API going to be faster than that? Or is it just nice to give our pages cute names?
- eklitzke 4y agoThe use case apparently is for sharing some memory region between thousands of processes, which has a lot of overhead because each process would normally need its own PTEs which add up. I agree this is really weird though, if you want thousands of things sharing the same memory region it would make more sense to me to just use threads.
- touisteur 4y agoWell, threads come with their own myriad problems. Aside from isolation, with separate process one can start/stop/kill from outside in a more sysadmin-friendly way, but also upgrade gradually. I often use these kinds of mechanisms for control-planes or one writer / thousands of readers schemes (to share huge parameters or look up tables...). It's somehow far more efficient and easier to design than pub/sub or database requests and wasting loads of memory on N copies of the same data. Start the process, map the structures and go.