NVIDIA/stdexec

example.io_uring isn't getting compiled

lukester1975 opened this issue · 3 comments

Since c9df036 (stdexect_examples typo). Presumably as a result, it seems to have bitrotted a bit :)

In https://github.com/lukester1975/stdexec/tree/fix-uring-example I've put a cmake fix and a few other hacks to try to get the example working. Happy to separate out the cmake fix in to a PR. I'm sure the rest is largely nonsense...

Presumably context.run() should be context.run_until_stopped() after 5bb9746?

The example still seems a bit racy. Sometimes it works:

Hello, 1!
Hello, 2, stopped.
Hello, 2!
Hello, 1, stopped.
Hello, 0!
Hello, 1!
Hello, 2!
Stop it!
Requesting context stop
Requesting context2 stop
Hello, stopped.
Hello, stopped.
Joining io_thread
Joining io_thread2
Threads finished
The context is stopped!
The context is stopped!
Restarting context
Hello, 2!
Hello, schedule_at!
Finished

Other times:

Hello, 1!
Hello, 2, stopped.
Hello, 2!
Hello, 1, stopped.
Hello, 0!
Hello, 1!
Hello, 2!
Stop it!
Requesting context2 stop
Hello, stopped.
Hello, stopped.
Joining io_thread

I've not looked at that in any depth as it made my brain melt. It did seem context.reset() was required to ever get it to work, though.

Maybe I should open separate issue for this, but should run_until_stopped() restart IORING_ENTER_GETEVENTS if it gets EINTR? Otherwise run_until_stopped() needs wrapping in a loop and try/catch, presumably? Gets interrupted a lot when debugging.

Kernel is 6.5.6-200.fsync.fc38.x86_64 from nobara. Perhaps I should double check with something more vanilla...

Thanks!

maikel commented

Thank you for this!

I will look into it and fix it. Regarding EINTR you are correct. In fact I have a fix (and some improvements) in the pipeline here

https://github.com/maikel/senders-io/blob/static_io_pool/source/sio/io_uring/io_uring_context.cpp#L351

I haven't managed yet to merge it yet but I will try do so today.

maikel commented

I've fixed the trivial stuff. For the other error: I have yet to debug the cause. Currently I'm suspecting some misuse of the io_uring interface. For example, I am ignoring the dropped counter for the submission queue. I will try to allocate time soonish.

maikel commented

I currently assume that the implementation is correct but the example is wrong.

exec::schedule_after(scheduler2, 4s) | stdexec::then([&] { context.request_stop(); }), is NOT wrapped in a exec::finally which means it is not executed when context2 is stopped before the timed schedule can complete.

I don't know anymore what my intention have been, either I forgot to wrap this in a finally sender or I mixed scheduler and scheduler2