Skip to content

upstream: change pool APIs#16544

Merged
alyssawilk merged 7 commits intoenvoyproxy:mainfrom
alyssawilk:newStream
Jun 2, 2021
Merged

upstream: change pool APIs#16544
alyssawilk merged 7 commits intoenvoyproxy:mainfrom
alyssawilk:newStream

Conversation

@alyssawilk
Copy link
Copy Markdown
Contributor

@alyssawilk alyssawilk commented May 18, 2021

Changing pool APIs to prefetch connections only on stream establishment

Risk Level: medium (theoretically only changes things for folks who prefetch, and have no-op routing)
Testing: many many tests updated
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Copy Markdown
Contributor Author

(again, CI failures expected :-) )

@ggreenway
Copy link
Copy Markdown
Member

It might be more flexible to have an interface, instead of a struct containing std::function. But I don't see any clear use-case, so I'd be fine with that as-is.

I worry that it's harder to reason about the required lifetime of the LbContext. It used to only need to have lifetime of the call to getting the pool. Now it needs to live until after the returned callback is called. I think that works fine for current uses, it just makes it a little bit harder to reason about going forward. But OTOH, making it a shared_ptr or something seems needlessly complicated.

I think changing in this direction makes sense though.

@alyssawilk
Copy link
Copy Markdown
Contributor Author

It occurs to me that @RyanTheOptimist may have some API preferences as well.

Functionally for prefetch, we need to tie in the connection manager impl, and the pool and this is one way to do it.
I think you'll be poking in this area further when we're not even sure which host we're going to end up with, so if there's tweaks now that will make pooling/coalescing easier, it'd be nice to not have to rewrite those 5000 unit tests twice in one year, so if you have API thoughts, throw them my way? Otherwise I'll start cleaning up the unit tests next week.

Copy link
Copy Markdown
Contributor

@RyanTheOptimist RyanTheOptimist left a comment

Choose a reason for hiding this comment

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

This seems reasonable, but I don't think I'm quite close enough to the problem yet to have a terribly useful opinion.


// HttpPoolData returns information about a given pool as well as a function
// to create streams on that pool.
struct HttpPoolData {
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.

nit: It seems like this isn't so much "pool data" as it is "stream data" in that it contains a host and a function for creating a stream, but does not provide any direct access to a poo per se. Perhaps HttpStreamData?

I think this extends down to httpConnPool() which no longer returns a pool but instead returns stream data, if I'm reading this right.

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk alyssawilk marked this pull request as ready for review May 26, 2021 19:21
@alyssawilk alyssawilk requested review from lizan and zuercher as code owners May 26, 2021 19:21
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@@ -11,26 +11,47 @@ namespace Upstream {
// HttpPoolData returns information about a given pool as well as a function
// to create streams on that pool.
struct HttpPoolData {
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.

nit: I think tis is probably a class now that it has methods and private members.


// Tcp pool returns information about a given pool, as well as a function to
// create connections on that pool.
struct TcpPoolData {
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.

Ditto

@alyssawilk
Copy link
Copy Markdown
Contributor Author

clang tidy is objecting to a preexisting error which I'll clean up, and coverage is sad because I removed a line of tested code.
Given it's an include fix and a unit test, I think the code is fine to look at :-)

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk alyssawilk changed the title WIP: change pool APIs upstream: change pool APIs May 27, 2021
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

Looks good overall. Just one nit.

@alyssawilk alyssawilk merged commit ff2c0e5 into envoyproxy:main Jun 2, 2021
alyssawilk pushed a commit that referenced this pull request Jun 8, 2021
A recent change (#16544) moved the Http::ConnectionPool::Instance* returned from ThreadLocalCluster::httpConnPool() behind a new class HttpPoolData which no longer exposes the pool instance.

This PR adds two new methods on HttpPoolData to allow the removal of said workaround - hasActiveConnections and addDrainedCallback. Both just forward the call to the underlying pool.

Risk Level: low, existing functionality isn't affected.
Testing: n/a, only accessor method added.
Docs Changes: n/a.
Release Notes: n/a.

Signed-off-by: Jakub Sobon <mumak@google.com>
leyao-daily pushed a commit to leyao-daily/envoy that referenced this pull request Sep 30, 2021
Changing pool APIs to prefetch connections only on stream establishment

Risk Level: medium (theoretically only changes things for folks who prefetch, and have no-op routing)
Testing: many many tests updated
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
leyao-daily pushed a commit to leyao-daily/envoy that referenced this pull request Sep 30, 2021
A recent change (envoyproxy#16544) moved the Http::ConnectionPool::Instance* returned from ThreadLocalCluster::httpConnPool() behind a new class HttpPoolData which no longer exposes the pool instance.

This PR adds two new methods on HttpPoolData to allow the removal of said workaround - hasActiveConnections and addDrainedCallback. Both just forward the call to the underlying pool.

Risk Level: low, existing functionality isn't affected.
Testing: n/a, only accessor method added.
Docs Changes: n/a.
Release Notes: n/a.

Signed-off-by: Jakub Sobon <mumak@google.com>
@alyssawilk alyssawilk deleted the newStream branch August 4, 2022 00:57
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.

3 participants