-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
grid: cleaning up pools #34802
grid: cleaning up pools #34802
Conversation
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks for doing this.
source/common/http/conn_pool_grid.h
Outdated
ConnectionPool::Callbacks& callbacks, const Instance::StreamOptions& options); | ||
|
||
// This holds state for a single connection attempt to a specific pool. | ||
class ConnectionAttemptCallbacks : public ConnectionPool::Callbacks, | ||
public LinkedObject<ConnectionAttemptCallbacks> { | ||
public: | ||
ConnectionAttemptCallbacks(WrapperCallbacks& parent, PoolIterator it); | ||
ConnectionAttemptCallbacks(WrapperCallbacks& parent, ConnectionPool::Instance* pool); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be an Instance&
if it is non-null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
source/common/http/conn_pool_grid.h
Outdated
ConnectionPool::InstancePtr http3_pool_; | ||
ConnectionPool::InstancePtr http2_pool_; | ||
// A convenience list to allow taking actions on all pools. | ||
std::list<ConnectionPool::Instance*> pools_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A list involves heap allocations and pointer chasing. What would you think of absl::InlinedVector instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
source/common/http/conn_pool_grid.h
Outdated
// Attempt to create a new stream for pool(). | ||
StreamCreationResult newStream(); | ||
// Attempt to create a new stream for pool. | ||
StreamCreationResult newStream(ConnectionPool::Instance* pool); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
source/common/http/conn_pool_grid.cc
Outdated
|
||
return --pools_.end(); | ||
setupPool(*pools_.back()); | ||
return (pools_.back()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: no need for the extra ()s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
source/common/http/conn_pool_grid.cc
Outdated
@@ -325,13 +325,13 @@ ConnectionPool::Cancellable* ConnectivityGrid::newStream(Http::ResponseDecoder& | |||
} else { | |||
// Before skipping to the next pool, make sure it has been created. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we might want to tweak this comment since "skipping to the next pool" is a tag less clear than "using the h2 pool"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry failed to reply to the comment but this is done.
Make sure the HTTP/2 pool is created.
} | ||
auto wrapped_callback = | ||
std::make_unique<WrapperCallbacks>(*this, decoder, pool, callbacks, overriding_options); | ||
std::make_unique<WrapperCallbacks>(*this, decoder, callbacks, overriding_options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OOC, why move pool
from the constructor to newStream
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a property of an attempt not of a wrapper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, heh. Sure, good point. Thanks!
source/common/http/conn_pool_grid.cc
Outdated
ConnectionPool::Cancellable* ret = wrapped_callback.get(); | ||
LinkedList::moveIntoList(std::move(wrapped_callback), wrapped_callbacks_); | ||
if (wrapped_callbacks_.front()->newStream() == StreamCreationResult::ImmediateResult) { | ||
if (wrapped_callbacks_.front()->newStream(pool) == StreamCreationResult::ImmediateResult) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This predates you, but might as well use ret
instead of wrapped_callbacks_.front()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
return nullptr; | ||
} | ||
return static_cast<ConnectionPool::MockInstance*>(&*pools_.front()); | ||
return static_cast<ConnectionPool::MockInstance*>(http3_pool_.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this method is no longer returning the first element from a list, I think the name first
isn't correct any longer. Shall we rename it http3Pool()
or some such?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
ASSERT_TRUE(optional_it1.has_value()); | ||
EXPECT_EQ("HTTP/3", (**optional_it1)->protocolDescription()); | ||
auto pool1 = ConnectivityGridForTest::forceCreateNextPool(grid); | ||
ASSERT_TRUE(pool1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think we typically use explicit nullptr checks. ASSERT_TRUE(pool1 != nullptr)
. (Here and on line 990)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// Always start with the HTTP/3 pool if it exists. | ||
ConnectionPool::Instance* pool = http3_pool_ ? http3_pool_.get() : http2_pool_.get(); | ||
if (!pool) { | ||
pool = createNextPool(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having read through the rest of this PR, I think that we should eliminate createNextPool()
. In this method, we have an explict if()
down on line 320 which controls if we're doing h2 or h3. Can we simply inline the initialization of http2_pool_
and http3_pool_
there and eliminate createNextPool()
since the next is a list operation which we really don't seem to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SG. Would it be Ok to do this in a follow-up? I have another clean up PR Pending plus the actual underlying fix I want to do. added a TODO in the .h file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, modulo the unresolved comment
// Always start with the HTTP/3 pool if it exists. | ||
ConnectionPool::Instance* pool = http3_pool_ ? http3_pool_.get() : http2_pool_.get(); | ||
if (!pool) { | ||
pool = createNextPool(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM!
source/common/http/conn_pool_grid.cc
Outdated
@@ -325,13 +325,13 @@ ConnectionPool::Cancellable* ConnectivityGrid::newStream(Http::ResponseDecoder& | |||
} else { | |||
// Before skipping to the next pool, make sure it has been created. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping
} | ||
auto wrapped_callback = | ||
std::make_unique<WrapperCallbacks>(*this, decoder, pool, callbacks, overriding_options); | ||
std::make_unique<WrapperCallbacks>(*this, decoder, callbacks, overriding_options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, heh. Sure, good point. Thanks!
Changing the grid to make the HTTP/2 and HTTP/3 pools explicit Risk Level: medium Testing: n/a Docs Changes: n/a Release Notes: n/a Signed-off-by: Alyssa Wilk <alyssar@chromium.org> Signed-off-by: antoniovleonti <leonti@google.com>
Changing the grid to make the HTTP/2 and HTTP/3 pools explicit
Risk Level: medium
Testing: n/a
Docs Changes: n/a
Release Notes: n/a