apache / brpc

brpc is an Industrial-grade RPC framework using C++ Language, which is often used in high performance system such as Search, Storage, Machine learning, Advertisement, Recommendation etc. "brpc" means "better RPC".

Home Page:https://brpc.apache.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bthread_setconcurrency相关的使用优化

yanglimingcn opened this issue · comments

Describe the bug (描述bug)

bthread_min_concurrency/bthread_concurrency/bthread_current_tag/bthread_concurrency_by_tag现在使用起来很不友好,感觉可以优化一下。
这些值的实际生效都是在bthread的worker都启动完成后再去执行,感觉就会比较符合预期,比较可控。所以可以将这些函数中的
TaskControl* c = get_task_control(); 代码改成 TaskControl* c = get_or_new_task_control(); 再去调用相关的修改逻辑。这样整体代码会简洁很多,这几个参数的依赖性也就没那么强了。尤其是bthread_current_tag/bthread_concurrency_by_tag,在没有启动好worker前调用其实是不能生效的,这就很别扭。

这么做的弊端是这些worker的启动会提前一些,但是,既然是用户设置的感觉提前启动也没啥问题。

To Reproduce (复现方法)

Expected behavior (期望行为)

Versions (各种版本)
OS:
Compiler:
brpc:
protobuf:

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

@wwbmmm 这块你有啥建议吗?