Comment by 0c3ca83

4 days ago

...I'm still confused why you wouldn't use memcpy?

How can one memcpy from a fd to a socket? I don’t touch the bytes in userspace, I just tell the kernel to send them out.

  • So why would you mmap?

    • to not let the bytes i forward enter userspace, i serve from the page cache for the asset path, directly from a zip file.

      i open the file, mmap it, close it and tell io_uring_prep_send which bytes from the mapping to send, this also saves me from a possible SIGBUS cause the access to the mmap happen inside the kernel, and when a SIGBUS would happen in userspace the kernel just reports a shorter send in cqe->res