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

Set of functionality additions and small adjustments. #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ivancich
Copy link
Member

This commit contains a bunch of minor changes.

First it allows a ClientProfile to be updated with new reservation,
weight, and limit values by adding an update function.

Second it adds an ability to invoke callbacks when a ClientInfo object
is removed due to the idle timeout. Testing this functionality has
been added to the unit tests.

Third we add the ability to clear a heap to help with a more
controlled tear-down.

Finally, dmclock-servers "cleaning" has been renamed "idle erase" to
better indicate the role. Types and variable names have been adjusted
accordingly.

Signed-off-by: J. Eric Ivancich [email protected]

@ivancich
Copy link
Member Author

This PR primarily has functionality addtions for the librados integration plus a few other related changes.

@ivancich ivancich requested review from tchaikov and cbodley May 10, 2018 20:23
@ivancich ivancich force-pushed the wip-librados-adjustments branch 2 times, most recently from abacfd0 to c2a1e93 Compare May 11, 2018 13:07
}


~PriorityQueueBase() {
finishing = true;

DataGuard g(data_mtx);
Copy link
Contributor

Choose a reason for hiding this comment

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

locking in a destructor is generally unnecessary, unless it's to synchronize with the shutdown of an internal thread. you don't need to provide mutual exclusion between the destructor and public functions, because it would already be undefined behavior for one thread to call functions on an object that's being destructed in another thread

for (auto c = client_map.begin(); client_map.end() != c; /* empty */) {
auto current = c++;
for (auto l : idle_erase_listeners) {
(*l)(current->second->client);
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the motivation for notifying these listeners on destruction?

Copy link
Member Author

Choose a reason for hiding this comment

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

The key motivation was that if they were maintaining data to support those clients (i.e., they were the target of a ClientInfoFunc) they could dispose of the data. This was specifically for the OSD. However in the case of the OSD it's unlikely the dmclock server code (i.e., PullPriorityQueue) would be destructed if the rest of the OSD weren't also destructed. But in a more general case it seems necessary to prevent irreversible memory growth.

Copy link
Member Author

Choose a reason for hiding this comment

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

As I think about this further, not allowing the listener to be dynamic constrains the owner but likely makes more sense overall.


// NB: All threads declared at end, so they're destructed first!
using IdleEraseListener = std::function<void(const C&)>;
std::set<const IdleEraseListener*> idle_erase_listeners;
Copy link
Contributor

Choose a reason for hiding this comment

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

it doesn't seem safe to store these functions by pointer - especially when they're passed to add_idle_erase_listener() as a const reference. that means it's perfectly valid to call with a lambda, which we'd store as a pointer to a temporary object:

  q.add_idle_erase_listener([] (const C& c) {});

it looks like it was done this way so you could implement remove_idle_erase_listener() - but is this kind of dynamic registration really necessary? consider treating this similar to ClientInfoFunc, and take a single optional callback as a constructor argument. if the caller really needs dynamic registration, they could implement it themselves inside their callback. does that make sense?

@ivancich ivancich force-pushed the wip-librados-adjustments branch 2 times, most recently from c27cdbf to 6ce61d0 Compare May 11, 2018 17:41
@ivancich
Copy link
Member Author

@cbodley Thanks for all your input. I reworked it and I think the code is much better now.

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.

lgtm

@ivancich ivancich force-pushed the wip-librados-adjustments branch from 6ce61d0 to ddd6b56 Compare May 11, 2018 22:03
First it allows a ClientProfile to be updated with new reservation,
weight, and limit values by adding an update function.

Second it adds an ability to invoke callbacks when a ClientInfo object
is removed due to the idle timeout. Testing this functionality has
been added to the unit tests.

Third we add the ability to clear a heap to help with a more
controlled tear-down.

Finally, dmclock-servers "cleaning" has been renamed "idle erase" to
better indicate the role. Types and variable names have been adjusted
accordingly.

Signed-off-by: J. Eric Ivancich <[email protected]>
@ivancich ivancich force-pushed the wip-librados-adjustments branch from ddd6b56 to d76b9af Compare September 13, 2018 16:36
@tchaikov
Copy link
Collaborator

tchaikov commented May 10, 2021

@ivancich i will review this change later this week. but do you mind splitting this change into smaller commits? i can help on this with your permission if you don't have enough bandwidth on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants