Skip to content

stream info: prefer reference rather than shared pointer for route()#43938

Merged
wbpcode merged 5 commits into
envoyproxy:mainfrom
wbpcode:dev-make-filter-stream-simple
Mar 26, 2026
Merged

stream info: prefer reference rather than shared pointer for route()#43938
wbpcode merged 5 commits into
envoyproxy:mainfrom
wbpcode:dev-make-filter-stream-simple

Conversation

@wbpcode
Copy link
Copy Markdown
Member

@wbpcode wbpcode commented Mar 13, 2026

Commit Message: stream info: return reference rather than copy of shared pointer
Additional Description:

See #44025

This pr update previous route() as routeSharedPtr() and add a new route() which will return OptRef<const Route>.

Risk Level: low.
Testing: n/a.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Mar 13, 2026

This bring minor change to interface of StreamInfo, so @ravenblackx @yanavlasov to avoid this affect your forks. (Although I think this won't bring any change to existing code, but in case)

@wbpcode wbpcode marked this pull request as draft March 13, 2026 03:10
@nezdolik
Copy link
Copy Markdown
Member

We also have a fork (cilium-proxy), but this change does not seem to affect us.

@wbpcode wbpcode marked this pull request as ready for review March 13, 2026 14:41
agrawroh
agrawroh previously approved these changes Mar 13, 2026
Copy link
Copy Markdown
Member

@agrawroh agrawroh left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks!

@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Mar 13, 2026

We also have a fork (cilium-proxy), but this change does not seem to affect us.

Yeah. It should won't affect any source code but may affect the test mock of route() method because now it will return a reference to Router::RouteConstSharedPtr. That's say the previous way to return a shared pointer of mock route will be affected.

ravenblackx
ravenblackx previously approved these changes Mar 13, 2026
Copy link
Copy Markdown
Contributor

@ravenblackx ravenblackx left a comment

Choose a reason for hiding this comment

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

Thanks for the heads-up. Looks fine to me.

@ravenblackx
Copy link
Copy Markdown
Contributor

/retest

nezdolik
nezdolik previously approved these changes Mar 13, 2026
Copy link
Copy Markdown
Member

@tyxia tyxia left a comment

Choose a reason for hiding this comment

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

Thanks!

Comment thread envoy/stream_info/stream_info.h Outdated
Copy link
Copy Markdown
Contributor

@yanavlasov yanavlasov left a comment

Choose a reason for hiding this comment

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

LGTM from me. If others feel like this is a serious issue, please comment.

/wait-any

tyxia
tyxia previously approved these changes Mar 17, 2026
Copy link
Copy Markdown
Member

@tyxia tyxia left a comment

Choose a reason for hiding this comment

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

Thanks!and benchmark

@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Mar 19, 2026

After offline discussion. We will migrate to two methods style. :)

@wbpcode wbpcode marked this pull request as draft March 19, 2026 10:03
@wbpcode wbpcode dismissed stale reviews from tyxia, nezdolik, and ravenblackx via 5667cfd March 20, 2026 07:53
@wbpcode wbpcode marked this pull request as ready for review March 20, 2026 07:56
@wbpcode wbpcode force-pushed the dev-make-filter-stream-simple branch 2 times, most recently from 5888f0a to a19b99b Compare March 20, 2026 12:44
@wbpcode wbpcode changed the title stream info: return reference rather than copy of shared pointer stream info: prefer reference rather than shared pointer for route() Mar 20, 2026
@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Mar 20, 2026

/retest

Copy link
Copy Markdown
Member

@nezdolik nezdolik left a comment

Choose a reason for hiding this comment

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

lgtm, thanks!

nezdolik
nezdolik previously approved these changes Mar 23, 2026
FilterManager& manager_;
absl::string_view filter_config_name_;
Router::RouteConstSharedPtr route_;
OptRef<const Router::Route> route_;
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.

I'm a bit concerned about this one - seems like a place where the shared ownership might be important. Do we know where else owns this route, that definitely has a lifetime exceeding that of a FilterManager?

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.

Even if it's okay, it's probably worth a comment here explaining who owns it and why we know their lifetime makes it okay to have just a ref here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's not easy to see why it's fine to use ref here on the github diff. But if you read the whole file, you will find the route_ here is a field of FilterChainFactoryCallbacksImpl which is only be used as temporarily object when creating new filter chain.

ravenblackx
ravenblackx previously approved these changes Mar 23, 2026
@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Mar 24, 2026

/retest

wbpcode added 5 commits March 25, 2026 12:34
Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Mar 25, 2026

This latest commit change nothing but merge main and resolve the conflicts.

@wbpcode
Copy link
Copy Markdown
Member Author

wbpcode commented Mar 25, 2026

/retest

@wbpcode wbpcode merged commit 5d8deb7 into envoyproxy:main Mar 26, 2026
29 checks passed
@wbpcode wbpcode deleted the dev-make-filter-stream-simple branch March 26, 2026 01:24
TAOXUY pushed a commit to TAOXUY/envoy that referenced this pull request Apr 1, 2026
…nvoyproxy#43938)

Commit Message: stream info: return reference rather than copy of shared
pointer
Additional Description:

See envoyproxy#44025

This pr update previous `route()` as `routeSharedPtr()` and add a new
`route()` which will return `OptRef<const Route>`.

Risk Level: low.
Testing: n/a.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

---------

Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Signed-off-by: Xuyang Tao <taoxuy@google.com>
citrus7 pushed a commit to citrus7/envoy that referenced this pull request Apr 1, 2026
…nvoyproxy#43938)

Commit Message: stream info: return reference rather than copy of shared
pointer
Additional Description:

See envoyproxy#44025

This pr update previous `route()` as `routeSharedPtr()` and add a new
`route()` which will return `OptRef<const Route>`.

Risk Level: low.
Testing: n/a.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

---------

Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Signed-off-by: Jonathan Wu <jtwu@google.com>
nshipilov pushed a commit to nshipilov/envoy that referenced this pull request Apr 13, 2026
…nvoyproxy#43938)

Commit Message: stream info: return reference rather than copy of shared
pointer
Additional Description:

See envoyproxy#44025

This pr update previous `route()` as `routeSharedPtr()` and add a new
`route()` which will return `OptRef<const Route>`.

Risk Level: low.
Testing: n/a.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

---------

Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
Signed-off-by: Nick Shipilov <nick.shipilov.n@gmail.com>
krinkinmu pushed a commit to grnmeira/envoy that referenced this pull request Apr 20, 2026
…nvoyproxy#43938)

Commit Message: stream info: return reference rather than copy of shared
pointer
Additional Description:

See envoyproxy#44025

This pr update previous `route()` as `routeSharedPtr()` and add a new
`route()` which will return `OptRef<const Route>`.

Risk Level: low.
Testing: n/a.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

---------

Signed-off-by: wbpcode/wangbaiping <wbphub@gmail.com>
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.

7 participants