Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pinning Photon vcpu to specific cpu cores #367

Closed
aley1 opened this issue Feb 20, 2024 · 5 comments
Closed

Pinning Photon vcpu to specific cpu cores #367

aley1 opened this issue Feb 20, 2024 · 5 comments

Comments

@aley1
Copy link

aley1 commented Feb 20, 2024

Hi all,

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

@beef9999
Copy link
Collaborator

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

@aley1
Copy link
Author

aley1 commented Feb 20, 2024

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?

@beef9999
Copy link
Collaborator

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

@aley1
Copy link
Author

aley1 commented Feb 21, 2024

Got it, thanks!

@aley1 aley1 closed this as completed Feb 21, 2024
@lihuiba
Copy link
Collaborator

lihuiba commented Feb 21, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants