Skip to main content

Module sharded

Module sharded 

Source
Expand description

atomr-cluster-sharding adapter for super::PlacementActor.

Bridges the GPU-fleet placement layer to atomr’s typed sharding primitives. Callers wrap their crate::device::DeviceMsg with a [RoutedDeviceMsg { entity_id, msg }] envelope, and the adapter exposes an [EntityRef<DeviceExtractor>] whose tell routes the message to the device owning that entity id.

This enables:

  • Cluster-wide shard handoff if/when a remote forwarder is wired in via [ShardRegion::set_remote_forwarder].
  • Consistent placement: identical entity_ids always land on the same device, even across restarts of the calling code.

The current implementation uses a simple FxHash-mod-N consistent routing policy (no live-load awareness). A follow-up can install a custom [ShardCoordinator]-driven allocation strategy that polls the underlying super::PlacementActor’s load snapshot.

Structs§

DeviceExtractor
MessageExtractor impl for RoutedDeviceMsg. Hashes entity_id into one of shard_count shards.
PlacementShardingAdapter
Adapter that publishes a [ShardRegion<DeviceExtractor>] backed by a fixed pool of pre-spawned DeviceActor refs. Each shard maps to one device via shard_index % devices.len(), so identical entity_ids always reach the same device.
RoutedDeviceMsg
Envelope used by the sharding adapter. Wraps an underlying DeviceMsg with the entity id the caller wants the message to be routed by. The adapter’s MessageExtractor reads entity_id to pick the destination shard / device.