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

[GraphBolt][io_uring] Use RAII to ensure queues are returned. #7680

Merged
merged 1 commit into from
Aug 10, 2024

Conversation

mfbalin
Copy link
Collaborator

@mfbalin mfbalin commented Aug 10, 2024

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.

  • The PR title starts with [$CATEGORY] (such as [NN], [Model], [Doc], [Feature]])
  • I've leverage the tools to beautify the python and c++ code.
  • The PR is complete and small, read the Google eng practice (CL equals to PR) to understand more about small PR. In DGL, we consider PRs with less than 200 lines of core code change are small (example, test and documentation could be exempted).
  • All changes have test coverage
  • Code is well-documented
  • To the best of my knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change
  • Related issue is referred in this PR
  • If the PR is for a new model/paper, I've updated the example index here.

Changes

@dgl-bot
Copy link
Collaborator

dgl-bot commented Aug 10, 2024

To trigger regression tests:

  • @dgl-bot run [instance-type] [which tests] [compare-with-branch];
    For example: @dgl-bot run g4dn.4xlarge all dmlc/master or @dgl-bot run c5.9xlarge kernel,api dmlc/master

@dgl-bot
Copy link
Collaborator

dgl-bot commented Aug 10, 2024

Commit ID: abc4b27

Build ID: 1

Status: ✅ CI test succeeded.

Report path: link

Full logs path: link

@mfbalin mfbalin added the expedited if it doesn't affect the main path approve first to unblock related projects, and review later label Aug 10, 2024
@mfbalin mfbalin merged commit c86776d into dmlc:master Aug 10, 2024
2 checks passed
@mfbalin mfbalin deleted the gb_RAII_io_uring_queue branch August 10, 2024 17:43
available_queues_.pop_back();
}
auto &io_uring_queue = io_uring_queue_[thread_id];
auto [acquired_queue_handle, my_read_buffer2] = queue_source.get();
Copy link
Collaborator

Choose a reason for hiding this comment

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

never my :)

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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 {
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See #7713

Copy link
Collaborator Author

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.

Copy link
Collaborator

@frozenbugs frozenbugs Aug 20, 2024

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expedited if it doesn't affect the main path approve first to unblock related projects, and review later
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants