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 使用的线程设置线程名 #1923

Closed
feng-y opened this issue Sep 9, 2022 · 3 comments
Closed

bthread 使用的线程设置线程名 #1923

feng-y opened this issue Sep 9, 2022 · 3 comments
Labels
feature new feature good first issue Good for newcomers

Comments

@feng-y
Copy link

feng-y commented Sep 9, 2022

Is your feature request related to a problem? (你需要的功能是否与某个问题有关?)
方便gdb && pstack 的时候找到bthread 使用线程

Describe the solution you'd like (描述你期望的解决方法)
pthread_setname_np

Describe alternatives you've considered (描述你想到的折衷方案)
在TaskControl::init, TaskControl::add_works
TimeThread::Start 创建线程时使用 pthread_setname_np 设置线程名

Additional context/screenshots (更多上下文/截图)
最近在查一个线程问题,bthread 因为使用了 pthread mutex 导致所有的bthread 都锁住了,pstack 也无法完整打出栈数据处理,无法快速识别出bthread 具体卡到哪了,如果为bthread 使用的线程命名,就比较方便的找出线程并用 gdb thread apply id bt 查看,线上进程有几个线程,最终花了较长时间才找到bthread 的线程并定位

@feng-y feng-y closed this as completed Sep 9, 2022
@feng-y feng-y reopened this Sep 9, 2022
@feng-y feng-y changed the title bthread bthread 使用的线程设置线程名 Sep 9, 2022
@TousakaRin TousakaRin added the good first issue Good for newcomers label Sep 19, 2022
@fansehep
Copy link
Contributor

fansehep commented Oct 5, 2022

We must specify rules for the naming of threads. In my thinking, a thread' name can be "create_function + number".
a example like: TaskContol::init_1 if TaskControl::init create a thread firstly. then other name just incremently. Any other greater design?


我们必须要为创建的线程指定命名规则, 我的想法是, 一个线程的别名是 创建的他的函数 + 第几个创建的, 一个例子如 TaskControl::init_1 是 TaskControl::init 创建的第一个线程. 此后依次递增. 请问这样是否是合适的或者有更好的想法吗?

@Divyansh200102
Copy link
Contributor

Divyansh200102 commented Dec 4, 2023

I want to work on this issue @feng-y @fansehep and I understood the feature that is required since I am a beginner can you tell me how should I start working on this issue and which files do I need to make changes in?

@chenBright
Copy link
Contributor

chenBright commented Dec 4, 2023

Worker threads and other threads has been named by #2136 .

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

No branches or pull requests

6 participants