-
Notifications
You must be signed in to change notification settings - Fork 1.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
scheduling_group: improve scheduling group creation exception safety #2617
base: master
Are you sure you want to change the base?
Conversation
cb8d016
to
88c4e8a
Compare
The CI fails in Seastar.unit.rpc with timeout |
@@ -37,17 +37,66 @@ namespace seastar { | |||
namespace internal { | |||
|
|||
struct scheduling_group_specific_thread_local_data { | |||
using val_ptr = std::unique_ptr<void, void (*)(void*) noexcept>; | |||
using cfg_ptr = std::shared_ptr<scheduling_group_key_config>; |
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.
Can it be seastar::lw_shared_ptr<scheduling_group_key_config>
?
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
@@ -37,17 +37,66 @@ namespace seastar { | |||
namespace internal { | |||
|
|||
struct scheduling_group_specific_thread_local_data { | |||
using val_ptr = std::unique_ptr<void, void (*)(void*) noexcept>; |
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.
What's the point in making it smart-pointer if you track construction/destruction by hand anyway?
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.
The point is to manage the dynamic memory allocation and free it automatically
inline auto& get_sg_data(unsigned sg_id) { | ||
return _scheduling_group_specific_data.per_scheduling_group_data[sg_id]; | ||
} | ||
|
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.
There's no need in those helpers, AFAICS, the existing get_scheduling_group_specific_thread_local_data()
(and Co) already provide access to the array of per_scheduling_group_data-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.
I added it because in several places we access the sg data and we do
auto& sg_data = _scheduling_group_specific_data;
auto& this_sg = sg_data.per_scheduling_group_data[sg._id];
which I thought is a little cumbersome and I didn't find another method for this
@@ -393,7 +401,6 @@ private: | |||
task_queue* pop_active_task_queue(sched_clock::time_point now); | |||
void insert_activating_task_queues(); | |||
void account_runtime(task_queue& tq, sched_clock::duration runtime); | |||
void allocate_scheduling_group_specific_data(scheduling_group sg, unsigned long key_id); |
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'd appreciate if the change "Move allocate_scheduling_group_specific_data() from reactor class to internal namespace" was made as separate preparational patch (in the same PR)
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
Move the function allocate_scheduling_group_specific_data from reactor class to an internal static function. Change it to handle only the allocation and construction of the data object, while the caller handles the assignment of it.
Improve handling of exceptions during scheduling group and scheduling group key creation, where a user-provided constructor for the keys may fail, for example. We use a new struct `specific_val` and smart pointers to manage memory allocation, construction and destruction of scheduling group data in a safe manner. We also reorder the initialization order to make it safer. For example, when creating a scheduling group, first allocate all data and then swap it into the scheduling group's data structure. Fixes scylladb#2222
88c4e8a
to
cd957c2
Compare
|
Improve handling of exceptions during scheduling group and scheduling group key creation, where a user-provided constructor for the keys may fail, for example.
We use a new struct
specific_val
and smart pointers to manage memory allocation, construction and destruction of scheduling group data in a safe manner.We also reorder the initialization order to make it safer. For example, when creating a scheduling group, first allocate all data and then swap it into the scheduling group's data structure.
Fixes #2222