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

common: introduce md_config_cacher_t #20320

Merged
merged 2 commits into from Feb 12, 2018

Conversation

rzarzynski
Copy link
Contributor

No description provided.

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
const static md_config_cacher_t<uint64_t> osd_max_object_size(
*g_conf, "osd_max_object_size");
const static md_config_cacher_t<bool> conf_data_digest(
*g_conf, "osd_skip_data_digest");
Copy link
Member

Choose a reason for hiding this comment

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

If these are static the lifecycle is not quite right. (For example, these will outlive the CephContext and md_config_t itself.) Instead, let's make these members of OSDService

Copy link
Contributor

@cbodley cbodley left a comment

Choose a reason for hiding this comment

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

i think this is a good strategy!

we'll want to keep an eye on the total number of these objects, since md_config_t::_apply_changes() is linear with respect the number of observers. but i think this makes the right tradeoff in terms of optimizing reads vs infrequent writes

const static md_config_cacher_t<uint64_t> osd_max_object_size(
*g_conf, "osd_max_object_size");
const static md_config_cacher_t<bool> conf_data_digest(
*g_conf, "osd_skip_data_digest");
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: cct->_conf instead of g_conf

}

~md_config_cacher_t() {
conf.remove_observer(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

object lifetimes are going to get tricky here, especially if we're declaring these as static

one option is to require md_config_cacher_t to hold a reference to CephContext. another is to skip this call to remove_observer() for static variables, as ~md_config_t() doesn't appear to care whether all observers were safely removed

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to be pedantic about lifecycle, because in many case we want ot ensure the cct gets destroy (e.g., library code) and using static would prevent that from ever happening. It shouldn't be hard to attach instances of this to a class that gets cleaned up before cct (i.e., something that owns a ref to the cct).

Copy link
Contributor

@mattbenjamin mattbenjamin left a comment

Choose a reason for hiding this comment

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

looks promising to me

class md_config_cacher_t : public md_config_obs_t {
md_config_t& conf;
const char* const option_name;
std::atomic<ValueT> value_cache;
Copy link
Contributor

Choose a reason for hiding this comment

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

a bit surprising, if nothing constrains the type of ValueT

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
@tchaikov tchaikov merged commit cc2fa37 into ceph:master Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants