alibaba / PhotonLibOS

Probably the fastest coroutine lib in the world!

Home Page:https://PhotonLibOS.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pinning Photon vcpu to specific cpu cores

aley1 opened this issue · comments

Hi all,

Is it possible to setup multiple Photon threads and pin them to specific cpu cores for the lifetime of the application?

photon thread will not automatically migrate to other vCPU. So you can bind the vCPU (OS thread) to specific core, for instance, using taskset or cpu affinity

thank you and noted. as a follow up question on photon workpool. If I have a workpool of 4 vcpus, and migrate tthreads to the workpool by specifying the vcpu_num/idx to migrate to for each thread, e.g thread 1 to vcpu 1, thread 2 to vcpu 2, can i achieve the same thing? Meaning vcpu1 is always running on the same core for the duration of the workpool?

workpool creates std::thread internally, so there is no way you can add some control into it. But you can still set cpu core affinity afterward. You can traverse each vcpu and get their pthread id, and bind to cores before your workload ever started

Got it, thanks!

You also have the option to create std:threads as vCPUs by yourself, pin them to physical CPU cores, and then put them into the pool.