Position independent data structures support shared memory (i.e. differing virtual address ranges) by using offsets from a known base rather than full virtul addresses.
So far I’ve only supported s single shared memory segment, so all data used has to be in that one segment. The offset is from the data structure state.
This is obviously a problem with NUMA.
With NUMA, you might well want to have a shared memory segment in every NUMA node.
This means in general multiple shared memory segments, which means mutiple offsets, which means when you are manipulating elements in the data structure and so working with offsets, knowing which shared memory segment a given offset is from, so you can know its base.
Central to almost all data structures is the atomic compare-and-swap (CAS).
If we have one segment only, we can compare the offsets across all the different virtual memory ranges and we will know we’re comparing the same data structure element.
If we have multiple segments, we can have the same offset but in different segements. Somehow we have to know, in the CAS, which segment an offset belongs to.
The only way I can see to do this is to borrow some most significant bits.
On 64-bit platforms this should be fine.
If we borrow say 8 bits, we can have 256 shared memory segments, and we have 56 bits remaining for the offset.
On 32-bit platforms it barely works.
If we borrow just 4 bits, and so can have 16 shared memory segments, we have 28 bits left over for the offset – which is 512mb.
It also means we have at times to do a lookup, in the data structure; we have an array, and here we store the base addresses of the different segements, and we look them up when we need to convert the offset to a full virtual address (which we do when we pass elements back to the user, i.e. after a dequeue() or pop()).
Position independence without NUMA is basically a fail, so I think this has to happen.