2 ms·
> If you need parallelism, and can afford its complexity, separate processes sharing only what must be shared can eliminate your TLB exposure. Then you need to
by adwn 6y ago
> If you need parallelism, and can afford its complexity, separate processes sharing only what must be shared can eliminate your TLB exposure.
Then you need to ensure that all shared data structures are exclusively allocated from a dedicated memory pool which is mapped to all processes. Oh, and you must make sure that you either don't use any pointers within those datastructures, or that the shared memory pool is mapped to the same address in all processes. And no pointers must point from within to outside that memory pool.
In theory, it is possible. In practice, this would preclude any kind of non-trivial parallelism.
- ncmncm 6y agoI see that you just haven't done it yet. "Allocation" in this context just means open(), mmap(). A "shared memory pool" is a thing I would have no use for. But I can assure you that you can have excellent, non-trivial parallelism with separate processes and chosen shared memory pages -- much moreso than with threads that must battle one another for access to locks, queues, and "pools". I routinely get order-of-magnitude performance improvement by reorganizing this way. The single-writer ring buffer is the component that makes it all work. The environment might seem stark, but in exchange you can have exactly 0% concurrency overhead. Not wasting 90% on pool management and thread contention means other optimizations become meaningful. And, you can start and stop the processes independently.