MalikHou opened a new pull request, #3238:
URL: https://github.com/apache/brpc/pull/3238
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:
- [x] Please make sure your changes are compilable.
- [x] When providing us with a new feature, it is best to add related tests.
- [x] Please follow [Contributor Covenant Code of
Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]