mstar.worker.rid_table#

Worker-local integer handles for request ids.

Messages carry the request id string; everything inside a worker keys on a small int instead. The only translations are at the process boundary: a handle is minted on NEW_REQUEST and looked up on every other inbound message, and the string goes back on the wire at each send site.

Handles are RECYCLED once a request is removed, so anything keyed by one must be purged on the same REMOVE_REQUEST that releases it. A leaked string key was harmless – the string never recurred – but a leaked handle silently attaches to whichever request gets that handle next. Known handle-keyed state: MicroScheduler.{failed_rids, admit_errors, held_until, backlog} (purged by clear_rid), Worker.{_last_active, _pending_removes, _pending_loop_stops, streaming_buffers}, the engine’s and tensor manager’s per-request state, and WorkerProfileInfo.

MicroScheduler.pending_tp_follow_count is the one deliberate exception: a ScheduleTPNode can arrive before the NEW_REQUEST that mints the handle, so it stays keyed by the wire string and is purged by clear_wire_rid.

Classes

class mstar.worker.rid_table.RidTable[source]#

Bases: object

handle(request_id)[source]#

Handle for an inbound message’s request id, or None if this worker does not know it (never admitted, or already removed – a benign race, not an error).

Parameters:

request_id (str)

Return type:

int | None

intern(request_id)[source]#

Handle for request_id, minting one if it has none.

A request spanning several partitions on this worker gets one NEW_REQUEST per partition; they all share the first one’s handle.

Parameters:

request_id (str)

Return type:

int

name(handle)[source]#

The wire identity, for a message about to leave this process.

Parameters:

handle (int)

Return type:

str

release(handle)[source]#

Free handle for reuse. Must run after every handle-keyed map has been purged of it.

Parameters:

handle (int)

Return type:

None