A worker writes each large result into a file in a node-local directory
(/dev/shm on Linux, $TMPDIR on macOS, or DISTA_STORE_DIR). A reader
that can see that file maps it, through memory-region's SharedMapping,
read-only and reads the bytes where they lie: no socket, no copy through
the kernel's network stack. A reader that can't fetches the result over a
socket from the worker, as before.
"Can see the file" is the test, not a matching host name: file names carry a
random token per worker, so a file with the right name is the right file.
That covers one machine, and Kubernetes pods that share a volume. (Host
names turned out to be unreliable: on GitHub's macOS runners, processes on
one machine reported different ones.)
DISTA_SHM=0 turns the store off; large results then stay in the worker's
memory and are always fetched over sockets.
Spilling: a worker keeps at most DISTA_STORE_BYTES of results in the store
(no limit when unset), and a result past that, or one the store can't take,
goes to DISTA_SPILL_DIR on disk instead (default $TMPDIR, or /tmp).
A spilled result is read the same way, mapped or fetched, only from disk.
On Kubernetes /dev/shm is an in-memory volume whose size limit evicts the
pod rather than failing a write, so the limit is what keeps it in bounds.
A location says where a result is: the worker's object server address, its
host name, the file's path ("" when it's only in memory) and the exact size,
since mapped files are padded.