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

bthread 怎么在启动时设置cpu亲和性 #2885

Open
tengallonhead-lv opened this issue Jan 23, 2025 · 4 comments
Open

bthread 怎么在启动时设置cpu亲和性 #2885

tengallonhead-lv opened this issue Jan 23, 2025 · 4 comments
Labels
feature new feature

Comments

@tengallonhead-lv
Copy link

Is your feature request related to a problem? (你需要的功能是否与某个问题有关?)
brpc在启动任务时,怎么将启动的worker调度到别的CPU上,而不是默认的当前pthread所在的CPU

Describe the solution you'd like (描述你期望的解决方法)
在brpc启动时,通过某个参数来设置CPU亲和性,可以选择打开或关闭

Additional context/screenshots (更多上下文/截图)

Image

@wwbmmm wwbmmm added the feature new feature label Feb 10, 2025
@wwbmmm
Copy link
Contributor

wwbmmm commented Feb 10, 2025

目前还不支持通过参数设置CPU亲和性

@tengallonhead-lv
Copy link
Author

目前还不支持通过参数设置CPU亲和性

那请问有什么推荐的设置CPU亲和性的方式吗?@wwbmmm

@yanglimingcn
Copy link
Contributor

// Add a startup function that each pthread worker will run at the beginning
// To run code at the end, use butil::thread_atexit()
// Returns 0 on success, error code otherwise.
extern int bthread_set_worker_startfn(void (*start_fn)());

// Add a startup function with tag
extern int bthread_set_tagged_worker_startfn(void (*start_fn)(bthread_tag_t));

用这两个函数,在启动worker线程的时候做设定是否能行呢?

@tengallonhead-lv
Copy link
Author

// Add a startup function that each pthread worker will run at the beginning // To run code at the end, use butil::thread_atexit() // Returns 0 on success, error code otherwise. extern int bthread_set_worker_startfn(void (*start_fn)());

// Add a startup function with tag extern int bthread_set_tagged_worker_startfn(void (*start_fn)(bthread_tag_t));

用这两个函数,在启动worker线程的时候做设定是否能行呢?

好的 谢谢 我试下

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

No branches or pull requests

3 participants