wwbmmm commented on code in PR #2819: URL: https://github.com/apache/brpc/pull/2819#discussion_r2030365543
########## src/bthread/task_control.h: ########## @@ -153,6 +157,7 @@ friend bthread_t init_for_pthread_stack_trace(); std::vector<bvar::PassiveStatus<double>*> _tagged_cumulated_worker_time; std::vector<bvar::PerSecond<bvar::PassiveStatus<double>>*> _tagged_worker_usage_second; std::vector<bvar::Adder<int64_t>*> _tagged_nbthreads; + std::vector<WorkStealingQueue<bthread_t>> _priority_qs; Review Comment: _priority_queues ########## src/bthread/task_control.h: ########## @@ -97,6 +97,10 @@ friend bthread_t init_for_pthread_stack_trace(); std::string stack_trace(bthread_t tid); #endif // BRPC_BTHREAD_TRACER + void push_priority_q(bthread_tag_t tag, bthread_t tid) { Review Comment: push_priority_queue ########## src/bthread/task_control.cpp: ########## @@ -430,6 +435,11 @@ int TaskControl::_destroy_group(TaskGroup* g) { bool TaskControl::steal_task(bthread_t* tid, size_t* seed, size_t offset) { auto tag = tls_task_group->tag(); + + if (_priority_qs[tag].steal(tid)) { Review Comment: 所有线程都访问这个是否会造成全局竞争? ########## src/brpc/event_dispatcher_epoll.cpp: ########## @@ -70,7 +70,8 @@ int EventDispatcher::Start(const bthread_attr_t* consumer_thread_attr) { // Set _thread_attr before creating epoll thread to make sure // everyting seems sane to the thread. _thread_attr = consumer_thread_attr ? - *consumer_thread_attr : BTHREAD_ATTR_NORMAL; + *consumer_thread_attr : _thread_attr; Review Comment: 默认的attr就是EPOLL,这里是不是可以改成这样更直观一些: ``` if (consumer_thread_attr) { _thread_attr = *consumer_thread_attr | BTHREAD_GLOBAL_PRIORITY } ``` ########## src/bthread/task_group.h: ########## @@ -200,6 +200,8 @@ class TaskGroup { return total_ns; } + const bthread_attr_t& get_current_attr() { return _cur_meta->attr; } Review Comment: 这个方法好像没有必要,目前只有task_group.cpp里面用到,那里可以直接访问到_cur_meta->attr -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org