-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
Service config parser to core configuration #28883
Conversation
…a3a3 Automated fix for refs/heads/parserconfig
…669d Automated fix for refs/heads/parserconfig
…3e53 Automated fix for refs/heads/parserconfig
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.
Just wondering about the mutex. Everything else looks great!
#include <grpc/support/log.h> | ||
|
||
namespace grpc_core { | ||
|
||
std::atomic<Mutex*> CoreConfiguration::builder_mu_; |
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.
Why do we need this mutex now, when we didn't before?
If we are going to have a mutex here, do we still need atomics? Could we just use gpr_once_init()
to set a non-atomic global Mutex*
variable, and then just use that mutex for the remaining data?
Can we add lock annotations, so that it's clear to both readers and to compiler checks which variables are being guarded by this mutex?
Can I have a sentence in this comment that is not in the form of a question? :)
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.
We used to allow multiple builders to run concurrently and race to provide the finished configuration: since that happens relatively infrequently, and the configuration is relatively fast to construct, it seemed like a good trade-off.
What changes here is that the service config code stores some of its configuration in static variables (specifically the indices of the configured service config slots).
We could eliminate this mutex if we stored those indices as part of the configuration, which I considered... however that would mean some additional indirections I believe along the data path to load the core configuration and chase a pointer to get the relevant index. I guess if we had some scheme to locate those indices on the channel that might alleviate it and re-simplify this code.
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'm not sure I stated this strongly enough:
I would be strongly in favor of removing this mutex and finding some other way of storing those indices.
@@ -50,16 +50,12 @@ void grpc_resolver_sockaddr_shutdown(void); | |||
void grpc_message_size_filter_init(void); |
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 these two forward declarations are no longer needed.
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.
Fixed
…f0f9 Automated fix for refs/heads/parserconfig
@markdroth made the changes we'd talked about, ptal |
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 looks really good!
There are only two substantive comments: the one about detecting naming conflicts, and the one about not using the cached index value in the rbac filter. Everything else is cosmetic.
Thanks!
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 looks great!
Remaining comments are cosmetic.
@@ -1,5 +1,5 @@ | |||
// | |||
// Copyright 2015 gRPC authors. | |||
// Copyright 2022 gRPC authors. |
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 should probably retain its original 2015 copyright date.
|
||
namespace grpc_core { | ||
|
||
// TODO(roth): Consider stripping this down further to the completely minimal |
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've now addressed this TODO. :)
@@ -0,0 +1,127 @@ | |||
// | |||
// Copyright 2022 gRPC authors. |
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 should probably say 2015, since this code just moved around.
} | ||
// Save service config. | ||
saved_service_config_ = std::move(service_config); | ||
// Swap out the data used by GetChannelInfo(). | ||
UniquePtr<char> lb_policy_name_owned(gpr_strdup(lb_policy_name)); | ||
std::string lb_policy_name_owned = lb_policy_name; |
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.
How about just changing this method to take the lb_policy_name
parameter as a std::string
, so it doesn't need to convert internally?
@nicolasnoble