shm-tensor-ring

command
v0.6.21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 4, 2026 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

shm-tensor-ring

Demonstrates cross-process tensor descriptor streaming and wake-latency benchmarking over a shared mmapped file backed by x/ossync (OS_SYNC_WAIT_ON_ADDRESS_SHARED / OS_SYNC_WAKE_BY_ADDRESS_SHARED), compared against a POSIX pipe baseline.

The parent process initializes two lock-free ossync.Rings (request and ack) inside a temporary MAP_SHARED file, spawns a helper subprocess via os.Args[0] -role=consumer, and runs four checks:

  1. Streams 10,000 64-byte TensorDesc descriptors with FNV-1a checksums and verifies 0 drops and strict sequence ordering.
  2. Benchmarks cross-process 1-way wake latency (ping-pong RTT / 2) over the shared mmap rings.
  3. Verifies that Ring.PopTimeout on an empty shared ring classifies Darwin's errno as ossync.ErrTimeout / syscall.ETIMEDOUT.
  4. Benchmarks an equivalent cross-process POSIX pipe ping-pong baseline.

Running

CGO_ENABLED=0 go run ./examples/os/shm-tensor-ring

Flags:

  • -count: number of tensor descriptors to stream (default 10000)
  • -warmup: warmup ping-pong iterations (default 100)
  • -bench-samples: measured ping-pong iterations (default 1000)
  • -timeout: duration for the ETIMEDOUT verification check (default 20ms)

Measured Results

Measured on an Apple M4 Max (16 cores, macOS 26.6.2) with CGO_ENABLED=0 go run ./examples/os/shm-tensor-ring:

shm-tensor-ring: count=10000 slot=64B cap=256 warmup=100 samples=1000
stream: sent=10000 received=10000 drops=0 elapsed=19.949ms throughput=501282.5 desc/s
timeout: requested=20ms elapsed=23.829ms err="ossync: wait timed out: operation timed out" (ETIMEDOUT=true)

TRANSPORT (1-WAY WAKE)            P50        P95        P99
x/ossync Shared mmap          9.604µs  115.292µs  569.792µs
POSIX pipe baseline           9.791µs  122.542µs  684.187µs

ossync vs pipe p50 ratio: 1.02x

Documentation

Rendered for darwin/amd64

Overview

Command shm-tensor-ring demonstrates cross-process tensor descriptor streaming and wake-latency benchmarking over a shared mmap region using Darwin's os_sync_wait_on_address (OS_SYNC_WAIT_ON_ADDRESS_SHARED) via x/ossync, compared against a POSIX pipe baseline.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL