-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[GraphBolt][io_uring] Use RAII to ensure queues are returned. #7680
Conversation
To trigger regression tests:
|
available_queues_.pop_back(); | ||
} | ||
auto &io_uring_queue = io_uring_queue_[thread_id]; | ||
auto [acquired_queue_handle, my_read_buffer2] = queue_source.get(); |
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.
never my :)
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 I used my in another PR. Will fix it today.
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.
See #7713
@@ -147,6 +146,68 @@ class OnDiskNpyArray : public torch::CustomClassHolder { | |||
static inline std::mutex available_queues_mtx_; // available_queues_ mutex. | |||
static inline std::vector<int> available_queues_; | |||
|
|||
struct QueueAndBufferAcquirer { |
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.
Better to explain how the Acquirer works at the top of the class.
Use class for struct with methods, struct is reserved only for data structure.
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.
See #7713
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.
Which guideline says that struct is reserved only for C style data structures? If you can point it out, I can read it and learn why this is preferred. I normally like using struct when the first things I am writing are supposed to be public.
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.
https://google.github.io/styleguide/cppguide.html#Structs_vs._Classes
We are trying to follow Google style guide for C++: https://docs.dgl.ai/contribute.html#coding-styles
Description
Make use of RAII to ensure the queues are returned back in a guaranteed way due to the object destructors.
This should make the code more error prone (I mean safer). Even if the worker threads or the main thread face an error or an exception, the destructors will be called, releasing the acquired shared resources.
Checklist
Please feel free to remove inapplicable items for your PR.
Changes