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

Maintain pending io_uring ops count for early return on run_once #349

Merged
merged 2 commits into from
Sep 27, 2024

Conversation

arpit-saxena
Copy link
Contributor

Add a pending_ops field to InnerLinuxIO struct which is incremented for each operation submitted to the ring and decremented when they are taken off the completion queue. With this, we can exit from run_once if there are no pending operations. Otherwise, in that case, it would hang indefinitely due to call of ring.submit_and_wait(1)

@penberg
Copy link
Collaborator

penberg commented Sep 26, 2024

@pereman2 Can you please have a look at this?

penberg added a commit that referenced this pull request Sep 26, 2024
This is not related to any open issue (atleast from the ones I saw).
This is related to an issue I saw when running the simulator as it was
calling `io.run_once()` even before submitting any read/write job. This
would lead to it hanging since io_uring's submit_and_wait would keep
waiting for a completion event.
I've tried to improve the simulator's IO handling a bit:
We inject a fault before calling next_row() through which we'll get
pread faults. Also we call io's run_once on getting RowResult::IO. This
is run with a fault probability of 1%. This is less because a fault here
would result us in terminating the entire loop iterating on rows, and
also because realistically we'll expect less faults here.
PS: I think run_once() should not hang either when no operation is
pending in io_uring. Opened #349 for fixing that.

Closes #348
Copy link
Collaborator

@pereman2 pereman2 left a comment

Choose a reason for hiding this comment

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

looks good, thanks. Just left a minor nit

core/io/linux.rs Outdated Show resolved Hide resolved
Add a `pending_ops` field to `InnerLinuxIO` struct which is incremented
for each operation submitted to the ring and decremented when they are
taken off the completion queue. With this, we can exit from run_once if
there are no pending operations. Otherwise, in that case, it would hang
indefinitely due to call of `ring.submit_and_wait(1)`
Adds a struct WrappedIOUring which contains a IoUring and a pending_ops
field. Entry submission and popping from the queue is done through
functions operating on it, which also maintains pending_ops count

NOTE: This is a bit weird/hacky since in get_completion we create a
CompletionQueue and just call its next(). If it were a normal iterator
it would always return the same first item. However it is a queue posing
as an iterator which makes this work.
@penberg penberg merged commit b8dffbf into tursodatabase:main Sep 27, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants