-
Notifications
You must be signed in to change notification settings - Fork 4.1k
[feature][bug] Add tcp transport event dispatcher unsched flag & fix RDMA event dispatcher unsched flag #3238
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -47,6 +47,23 @@ The application can manage memory by itself and send data with IOBuf::append_use | |||||||||||||
|
|
||||||||||||||
| RDMA is hardware-related. It has some different concepts such as device, port, GID, LID, MaxSge and so on. These parameters can be read from NICs at initialization, and brpc will make the default choice (see src/brpc/rdma/rdma_helper.cpp). Sometimes the default choice is not the expectation, then it can be changed in the flag way. | ||||||||||||||
|
|
||||||||||||||
| `event_dispatcher_edisp_unsched` is a global flag and affects EventDispatcher scheduling in both normal mode (TCP) and RDMA mode. For backward compatibility, `rdma_edisp_unsched` is still kept, but it is deprecated and will be removed in a future release. | ||||||||||||||
|
|
||||||||||||||
| The effective unsched condition is unified as: | ||||||||||||||
| `event_dispatcher_edisp_unsched || rdma_edisp_unsched` | ||||||||||||||
|
|
||||||||||||||
| No startup synchronization rewrites user flags. Runtime behavior is determined directly from user-provided values. | ||||||||||||||
|
|
||||||||||||||
| Recommended usage: | ||||||||||||||
| 1. New deployment: set only `event_dispatcher_edisp_unsched`. | ||||||||||||||
| 2. Existing deployment: keep `rdma_edisp_unsched` temporarily, but migrate to `event_dispatcher_edisp_unsched`. | ||||||||||||||
| 3. Avoid conflicting values in scripts; with unified OR semantics, either flag being `true` makes EventDispatcher unschedulable. | ||||||||||||||
|
|
||||||||||||||
| Examples: | ||||||||||||||
| 1. Only `-rdma_edisp_unsched=true`: `rdma_edisp_unsched=true`, `event_dispatcher_edisp_unsched=false`; both TCP and RDMA are unschedulable. | ||||||||||||||
| 2. Only `-event_dispatcher_edisp_unsched=true`: both flags are `true`; both TCP and RDMA are unschedulable. | ||||||||||||||
| 3. Both `-rdma_edisp_unsched=true -event_dispatcher_edisp_unsched=false`: `rdma_edisp_unsched=true`, `event_dispatcher_edisp_unsched=false`; both TCP and RDMA are unschedulable. | ||||||||||||||
|
Comment on lines
+63
to
+65
|
||||||||||||||
| 1. Only `-rdma_edisp_unsched=true`: `rdma_edisp_unsched=true`, `event_dispatcher_edisp_unsched=false`; both TCP and RDMA are unschedulable. | |
| 2. Only `-event_dispatcher_edisp_unsched=true`: both flags are `true`; both TCP and RDMA are unschedulable. | |
| 3. Both `-rdma_edisp_unsched=true -event_dispatcher_edisp_unsched=false`: `rdma_edisp_unsched=true`, `event_dispatcher_edisp_unsched=false`; both TCP and RDMA are unschedulable. | |
| 1. Only `-rdma_edisp_unsched=true`: `rdma_edisp_unsched=true`, `event_dispatcher_edisp_unsched=false`; effective condition is true, so both TCP and RDMA are unschedulable. | |
| 2. Only `-event_dispatcher_edisp_unsched=true`: `rdma_edisp_unsched=false` (default), `event_dispatcher_edisp_unsched=true`; effective condition is true, so both TCP and RDMA are unschedulable. | |
| 3. Both `-rdma_edisp_unsched=true -event_dispatcher_edisp_unsched=false`: `rdma_edisp_unsched=true`, `event_dispatcher_edisp_unsched=false`; effective condition is true, so both TCP and RDMA are unschedulable. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,16 @@ DECLARE_int32(task_group_ntags); | |
| namespace brpc { | ||
|
|
||
| DEFINE_int32(event_dispatcher_num, 1, "Number of event dispatcher"); | ||
| DEFINE_bool(event_dispatcher_edisp_unsched, false, | ||
| "Disable event dispatcher schedule"); | ||
|
|
||
| #if BRPC_WITH_RDMA | ||
| namespace rdma { | ||
| DEFINE_bool(rdma_edisp_unsched, false, | ||
| "Deprecated and will be removed in a future release, " | ||
| "use event_dispatcher_edisp_unsched instead"); | ||
| } // namespace rdma | ||
| #endif | ||
|
|
||
| DEFINE_bool(usercode_in_pthread, false, | ||
| "Call user's callback in pthreads, use bthreads otherwise"); | ||
|
|
@@ -41,6 +51,15 @@ static bvar::LatencyRecorder* g_edisp_read_lantency = NULL; | |
| static bvar::LatencyRecorder* g_edisp_write_lantency = NULL; | ||
| static pthread_once_t g_edisp_once = PTHREAD_ONCE_INIT; | ||
|
|
||
| bool EventDispatcherUnsched() { | ||
| #if BRPC_WITH_RDMA | ||
| return FLAGS_event_dispatcher_edisp_unsched || | ||
| rdma::FLAGS_rdma_edisp_unsched; | ||
| #else | ||
| return FLAGS_event_dispatcher_edisp_unsched; | ||
| #endif | ||
| } | ||
|
Comment on lines
32
to
+61
|
||
|
|
||
| static void StopAndJoinGlobalDispatchers() { | ||
| for (int i = 0; i < FLAGS_task_group_ntags; ++i) { | ||
| for (int j = 0; j < FLAGS_event_dispatcher_num; ++j) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,13 +19,16 @@ | |||||||||
| #ifndef BRPC_EVENT_DISPATCHER_H | ||||||||||
| #define BRPC_EVENT_DISPATCHER_H | ||||||||||
|
|
||||||||||
| #include <gflags/gflags_declare.h> // DECLARE_bool | ||||||||||
| #include "butil/macros.h" // DISALLOW_COPY_AND_ASSIGN | ||||||||||
| #include "bthread/types.h" // bthread_t, bthread_attr_t | ||||||||||
| #include "brpc/versioned_ref_with_id.h" | ||||||||||
|
|
||||||||||
|
|
||||||||||
| namespace brpc { | ||||||||||
|
|
||||||||||
| DECLARE_bool(event_dispatcher_edisp_unsched); | ||||||||||
|
|
||||||||||
| // Unique identifier of a IOEventData. | ||||||||||
| // Users shall store EventDataId instead of EventData and call EventData::Address() | ||||||||||
| // to convert the identifier to an unique_ptr at each access. Whenever a | ||||||||||
|
|
@@ -188,6 +191,11 @@ template <typename T> friend class IOEvent; | |||||||||
|
|
||||||||||
| EventDispatcher& GetGlobalEventDispatcher(int fd, bthread_tag_t tag); | ||||||||||
|
|
||||||||||
| // Unified unsched switch for transport layer. | ||||||||||
| // false -> background start (allowing schedule away), | ||||||||||
| // true -> urgent start (foreground scheduling before caller continues). | ||||||||||
|
Comment on lines
+195
to
+196
|
||||||||||
| // false -> background start (allowing schedule away), | |
| // true -> urgent start (foreground scheduling before caller continues). | |
| // false -> urgent start (foreground scheduling before caller continues), | |
| // true -> background start (allowing schedule away). |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -38,7 +38,6 @@ namespace rdma { | |||||||
|
|
||||||||
| DECLARE_bool(rdma_use_polling); | ||||||||
| DECLARE_int32(rdma_poller_num); | ||||||||
| DECLARE_bool(rdma_edisp_unsched); | ||||||||
| DECLARE_bool(rdma_disable_bthread); | ||||||||
|
||||||||
| DECLARE_bool(rdma_disable_bthread); | |
| DECLARE_bool(rdma_disable_bthread); | |
| DECLARE_bool(rdma_edisp_unsched); // Deprecated: kept for source compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
行为示例第2条表述不准确:仅设置
-event_dispatcher_edisp_unsched=true并不会使rdma_edisp_unsched也变为true(除非用户显式设置)。建议修改示例文案,区分“最终生效条件(OR)为 true”和“各 flag 实际取值”。