Skip to content

orca: decouple OOB report delivery from CSWRR weight manager#45953

Open
jukie wants to merge 1 commit into
envoyproxy:mainfrom
jukie:oob-decouple
Open

orca: decouple OOB report delivery from CSWRR weight manager#45953
jukie wants to merge 1 commit into
envoyproxy:mainfrom
jukie:oob-decouple

Conversation

@jukie

@jukie jukie commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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 generic HostLbPolicyData::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

@repokitteh-read-only

Copy link
Copy Markdown

As a reminder, PRs marked as draft will not be automatically assigned reviewers,
or be handled by maintainer-oncall triage.

Please mark your PR as ready when you want it to be reviewed!

🐱

Caused by: #45953 was opened by jukie.

see: more, trace.

Signed-off-by: jukie <10012479+jukie@users.noreply.github.com>
@jukie

jukie commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@jukie jukie marked this pull request as ready for review July 3, 2026 15:55
@jukie

jukie commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +359 to +373
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);
}
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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);
    }
  }
}

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