orca: decouple OOB report delivery from CSWRR weight manager#45953
orca: decouple OOB report delivery from CSWRR weight manager#45953jukie wants to merge 1 commit into
Conversation
Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
|
/retest |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the delivery of Out-of-Band (OOB) ORCA load reports to make the OOB manager policy-agnostic. Instead of sharing an OrcaWeightManager's report handler, OrcaOobManager now delivers decoded reports directly to each host's HostLbPolicyData via the standard onOrcaLoadReport callback path, with the StreamInfo parameter made optional. A helper function, forEachOrcaLoadReportRecipient, was also introduced to iterate over interested load-balancing policy data entries. The review feedback suggests refactoring this helper function into a template function to avoid the performance overhead of std::function on critical paths.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| using OrcaLoadReportRecipientCb = std::function<void(HostLbPolicyData&)>; | ||
|
|
||
| /** | ||
| * Invokes `callback(HostLbPolicyData&)` for each load-balancing-policy data entry on `host` whose | ||
| * receivesOrcaLoadReport() is true. | ||
| */ | ||
| inline void forEachOrcaLoadReportRecipient(const HostDescription& host, | ||
| const OrcaLoadReportRecipientCb& callback) { | ||
| for (size_t i = 0; i < host.lbPolicyDataCount(); ++i) { | ||
| OptRef<HostLbPolicyData> data = host.lbPolicyDataAt(i); | ||
| if (data.has_value() && data->receivesOrcaLoadReport()) { | ||
| callback(*data); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Using std::function for the callback in forEachOrcaLoadReportRecipient introduces unnecessary overhead (such as potential dynamic memory allocation and virtual dispatch/preventing inlining) on what can be a performance-sensitive path (e.g., in-band ORCA report processing in the router filter).
We can avoid this overhead entirely by making forEachOrcaLoadReportRecipient a template function. This allows the compiler to inline the lambda directly. You can also remove the #include <functional> header on line 3 if it is no longer needed.
template <typename Callback>
inline void forEachOrcaLoadReportRecipient(const HostDescription& host, Callback callback) {
for (size_t i = 0; i < host.lbPolicyDataCount(); ++i) {
OptRef<HostLbPolicyData> data = host.lbPolicyDataAt(i);
if (data.has_value() && data->receivesOrcaLoadReport()) {
callback(*data);
}
}
}
Commit Message: orca: decouple OOB report delivery from CSWRR weight manager
Additional Description: Previously OOB report delivery was hardcoded to CSWRR's
OrcaLoadReportHandler. This reroutes it through the genericHostLbPolicyData::onOrcaLoadReport(which the in-band path already uses), so that any LB policy can consume OOB reports such as LoadAwareLocality LB policy which I'm starting to implement.Risk Level: Low
Testing: Added new ones and existing CSWRR tests continue to pass
Docs Changes: N/A
Release Notes: N/A - no user-visible behavior changes
Platform Specific Features: N/A
xRef: #44318