Skip to content
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

Merged
merged 28 commits into from
Feb 24, 2022
Merged

Conversation

ctiller
Copy link
Member

@ctiller ctiller commented Feb 15, 2022

@ctiller ctiller added the release notes: no Indicates if PR should not be in release notes label Feb 15, 2022
@ctiller ctiller marked this pull request as ready for review February 15, 2022 16:59
@ctiller ctiller requested a review from markdroth as a code owner February 15, 2022 16:59
…3e53

Automated fix for refs/heads/parserconfig
Copy link
Member

@markdroth markdroth left a 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_;
Copy link
Member

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? :)

Copy link
Member Author

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.

Copy link
Member Author

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);
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed

@ctiller
Copy link
Member Author

ctiller commented Feb 23, 2022

@markdroth made the changes we'd talked about, ptal

Copy link
Member

@markdroth markdroth left a 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!

src/core/lib/service_config/service_config_parser.cc Outdated Show resolved Hide resolved
src/core/ext/filters/client_channel/retry_service_config.h Outdated Show resolved Hide resolved
src/core/ext/filters/rbac/rbac_filter.cc Show resolved Hide resolved
src/core/lib/config/core_configuration.h Outdated Show resolved Hide resolved
src/core/lib/config/core_configuration.h Outdated Show resolved Hide resolved
Copy link
Member

@markdroth markdroth left a 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.
Copy link
Member

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
Copy link
Member

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.
Copy link
Member

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;
Copy link
Member

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?

@ctiller ctiller merged commit 16a3ce5 into grpc:master Feb 24, 2022
@copybara-service copybara-service bot added the imported Specifies if the PR has been imported to the internal repository label Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bloat/low imported Specifies if the PR has been imported to the internal repository lang/core perf-change/high release notes: no Indicates if PR should not be in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants