Skip to content

Add UringSystem for Native#4584

Draft
antoniojimeneznieto wants to merge 2 commits intotypelevel:series/3.xfrom
antoniojimeneznieto:feature/native-io_uring
Draft

Add UringSystem for Native#4584
antoniojimeneznieto wants to merge 2 commits intotypelevel:series/3.xfrom
antoniojimeneznieto:feature/native-io_uring

Conversation

@antoniojimeneznieto
Copy link
Copy Markdown
Member

It has been a while since I wanted to work on this one! I think there will be a lot of things to discuss :)

@djspiewak
Copy link
Copy Markdown
Member

Hype!

Adapts the Native UringSystem to the multi-poller runtime that Scala
Native 0.5+ enables. Mirrors the structure of the JVM prototype from
GSoC (armanbilge/fs2-io_uring#78)
@antoniojimeneznieto
Copy link
Copy Markdown
Member Author

Some updates! I've adapted the UringSystem to be multithreaded, following the ideas we used in the JVM prototype:

  • Pipe-based wakeup: When we create a Poller we also create a pipe. The read end is registered with IORING_OP_POLL_ADD on the first poll using a default callback (wakeupHandler) that processReadyEvents identifies. interrupt writes one byte to wake the poller. The wakeup CQE drains the pipe and clears the listening flag.

  • Cross-ring cancellation: Submission now yields (addr, originatingPoller). cancel takes the fast path when ctx.accessPoller hands back the same ring, otherwise the cancel is enqueued onto the originating poller's ConcurrentLinkedDeque and that ring is woken. We drain this queue at the top of each poll on the owning thread.

I'd like to implement the msg_ring wakeup mechanism as a follow-up.

@antoniojimeneznieto
Copy link
Copy Markdown
Member Author

I talked with @armanbilge about when to choose UringSystem over EpollSystem and I'd like to open the discussion here. I think UringSystem should initially be opt-in via a flag. Beyond that, I see two constraints:

io_uring is supported from Linux kernel 5.1 onward, but depending on which features we use the effective minimum kernel version may be higher. I think that listing the features we need together with their minimum kernel versions would be useful.

We also depend on a minimum liburing version and we have looked at this function io_uring_check_version(3), which could be useful as a runtime check to fallback to EpollSystem.

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.

2 participants