Skip to content

[feature][bug] Add tcp transport event dispatcher unsched flag & fix RDMA event dispatcher unsched flag#3238

Open
MalikHou wants to merge 2 commits intoapache:masterfrom
MalikHou:master
Open

[feature][bug] Add tcp transport event dispatcher unsched flag & fix RDMA event dispatcher unsched flag#3238
MalikHou wants to merge 2 commits intoapache:masterfrom
MalikHou:master

Conversation

@MalikHou
Copy link

@MalikHou MalikHou commented Mar 6, 2026

Event Dispatcher Unsched Flag

What problem does this PR solve?

Problem Summary:

  • Event-dispatch scheduling behavior was not unified across transports.
  • RDMA used a transport-specific flag (rdma_edisp_unsched), while TCP had no unified switch.
  • In RDMA path, bthread_start_urgent and bthread_start_background logic was reversed, causing behavior opposite to expected unsched semantics.
  • The scheduling decision logic was duplicated in transport code, making behavior harder to reason about and test.

What is changed and the side effects?

Changed:

  • Added a unified flag in dispatcher layer: event_dispatcher_edisp_unsched.
  • Added EventDispatcherUnsched() helper in event_dispatcher.{h,cpp} as single source of truth.
  • Updated TcpTransport::ProcessEvent and RdmaTransport::ProcessEvent to use EventDispatcherUnsched():
    • false -> bthread_start_urgent
    • true -> bthread_start_background
  • Fixed RDMA bug where bthread_start_urgent and bthread_start_background branches were previously swapped.
  • Deprecated rdma_edisp_unsched and kept compatibility through dispatcher-layer unified check.
  • Added/updated tests in test/brpc_event_dispatcher_unittest.cpp:
    • event_dispatcher_unsched_by_unified_flag
    • event_dispatcher_unsched_by_legacy_rdma_flag (when BRPC_WITH_RDMA)
    • tcp_unsched_true_returns_before_onedge_finish
    • tcp_unsched_false_blocks_caller_when_single_worker

Effects:

  • event_dispatcher_edisp_unsched=true may reduce immediate foreground switching of dispatcher path.
  • rdma_edisp_unsched is deprecated.
  • RDMA runtime behavior now matches intended unsched semantics after fixing the swapped urgent/background branches. Users depending on previous incorrect behavior should migrate and re-check tuning.

Check List:

MalikHou and others added 2 commits March 6, 2026 20:26
[feature][bugfix] Add tcp transport event dispatcher unsched flag & fix RDMA event dispatcher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant