php-src icon indicating copy to clipboard operation
php-src copied to clipboard

io_uring for stream_copy_to_stream

Open tsukasagenesis opened this issue 4 years ago • 4 comments

Description

Hello,

It would be really nice to implement io_uring like here https://lwn.net/Articles/879724/ (talked in hn on https://news.ycombinator.com/item?id=30144652) to get stream_copy_to_stream() really performant. example code here : https://lwn.net/ml/linux-kernel/[email protected]/ It would help a lot of stream proxy in php to be handled directly in the kernel, and increase drastically the performance.

From many test, stream_copy_to_stream() is sadly "slow" because it didn't use any trick, like sendfile() or 0copy, but instead is just a warper for a classic read/write loop, no gain in performance.

tsukasagenesis avatar Jan 31 '22 13:01 tsukasagenesis

Hello

A first step could be to make a PoC to demonstrate the speed boost.

stream_copy_to_stream is implemented here: https://github.com/php/php-src/blob/php-8.1.4/main/streams/streams.c#L1540

arnaud-lb avatar Apr 01 '22 10:04 arnaud-lb

Related benchmarks using io_uring over on ASP: https://ndportmann.com/io_uring-preview-release/

gnat avatar Dec 17 '22 18:12 gnat

If I understand correctly, this is benchmarking an ASP async framework with various I/O adapters, including an io_uring one?

There are a few async frameworks in PHP, like https://amphp.org/ or https://reactphp.org/. It would be worth trying to implement an io_uring event loop for these.

arnaud-lb avatar Dec 19 '22 09:12 arnaud-lb

I just learned that windows has an io_uring equivalent named IoRing - I will leave it here in case its useful

https://github.com/oven-sh/bun/issues/43#issuecomment-1605693525

staabm avatar Jun 25 '23 06:06 staabm