7.3. Controlling data transfer

When a Morloc value crosses a pool boundary, the runtime picks one of three routes for data transfer:

  • Inline — for serialized payloads that are less than 64 KiB (by default), the bytes ride inside the packet over the Unix socket.

  • Shared memory — for larger payloads, the data sits in /dev/shm and the packet carries only an 8-byte pointer. This allows zero-copy data transfer between pools on the same host.

  • Temp file — only used when shared memory has been disabled (see --no-shm below). The data is written to a .mpk file and the packet carries the path.

Three morloc make flags let you override the default policy when it is wrong for your workload — restricted containers, tight /dev/shm quotas, debugging the wire-level traffic, or simply tuning the threshold to a value that matches your data shape:

Flag Effect

--inline-size BYTES

Move the inline/large threshold. Accepts a bare number or k/m/g suffix (binary, 1024-based). 0 means never inline. Default: 64k.

--no-shm

Disable shared memory. Payloads above the inline threshold are written to a temp file and passed by path.

--tmpdir PATH

Directory for the temp files produced under --no-shm. When set, the files are NOT auto-deleted at end of eval — useful for testing and debugging. Default (unset): $TMPDIR or /tmp, with auto-cleanup at end of every eval.

7.3.1. Combinations

Build flags Behavior

(none)

Inline ⇐ 64k, shared memory above.

--inline-size 0

Never inline; all cross-pool transfers go through shared memory.

--no-shm

Inline ⇐ 64k, temp files above. No /dev/shm traffic.

--inline-size 0 --no-shm

Every cross-pool transfer is a temp file. Slowest mode, but works on systems with no shared memory at all.

7.3.2. Examples

Build for a container with no usable /dev/shm:

$ morloc make --no-shm -o nexus main.loc

Run a workload where 64 KiB is too small (large records, every call exceeds the default):

$ morloc make --inline-size 1m -o nexus main.loc

Inspect the wire-level packets for debugging or testing:

$ morloc make --no-shm --inline-size 0 --tmpdir ./wire-dump -o nexus main.loc
$ ./nexus pipeline arg1 arg2
$ ls wire-dump/
morloc-pkt-12345-0.mpk  morloc-pkt-12345-1.mpk  ...

Each file is a self-contained MessagePack payload — one per pool return. Because --tmpdir was supplied, they persist after the program exits and can be inspected with any MessagePack reader.