Is this even possible?
Hey @marsupialtail , would you mind elaborating a bit more on the context? Specifically, when you say pinning, what do you mean here?
E.g.
- always runs an actor to a cpu by id?
- always run an actor to one of cpus across programs?
- always runs
ActorA
to the same core, andActorB
class to another?
I think there is no direct top level API in ray that pins actor to a core with some identifiers. e.g. ActorClass.remote(pin_cpu=<some_cpu_id>)
But there might be ways to make an actor to be scheduled on a worker(core) with placement groups or detached actors.
Yes I want to always run an actor on a particular CPU. In particular the actor has some state, so I want the state to stay in L2.
This is probably less important to the Python API but when using the C++ API I am thinking about this.
I’ve gotten this to work in Python before by simply running os.sched_setaffinity
within the actor. Perhaps there’s an equivalent of that in CPP?
Yes, you can totally do that on your own in c++ by using sched_setaffinity
system call (sched_setaffinity(2) - Linux man page)