espoal / awesome-iouring

Delightful io_uring packages and resources
MIT License
340 stars 16 forks source link

why using syscalls instead of implementing unsafe liburing ? #8

Closed weinberggithub closed 1 year ago

weinberggithub commented 1 year ago

Can you explain 'If you're doing Go/Rust, consider using syscalls instead of implementing unsafe liburing' in best.md please?

espoal commented 1 year ago

Here's the thing:

For time sensitive operations, like a read or a write, uring commands are for sure the way to go. Instead for one off operations, like setting up the ring or tearing down buffers, then a syscall becomes an interesting option.

Let me know if this answer your question @weinberggithub :)

weinberggithub commented 1 year ago

Here's the thing:

  • Uring commands are very fast, because they don't require trepassing the kernel/userspace barrier which would cause a context switch. On the other hand, as you can see here, they are very complex to get right and static tools like the rust borrow checker can't help you to find hidden bugs.
  • Syscalls are very slow (2-3 order of magnitude slower), but it just requires a function call which hides for you the nasty details, allowing static analysis tools to help you

For time sensitive operations, like a read or a write, uring commands are for sure the way to go. Instead for one off operations, like setting up the ring or tearing down buffers, then a syscall becomes an interesting option.

Let me know if this answer your question @weinberggithub :)

thanks, It was very helpful!