Conversation
|
I have done some benchmarking of this on Linux. The result vary between runs as it's highly system dependent but I can see some useful result from that:
So this seems good in terms of Linux perf which probably matter most. We should look after some follow ups to improve FreeBSD, MacOS and other unix variant. The sendfile works a bit differently for partial writes (think it blocks there but I made some changes so it is only used for real socket so it should be fine). there so it needs more testing but I think it can be a follow up PR. I should also note that the pipe check is there for future use - that pipe flag is only supported on Win but if we supported pipes more on Linux, we could potentially make use of that and it would limit some overhead for splice. @devnexen Please could you review it. |
|
I ll do a deeper dive sometime next week but here some quick findings. |
| maxlen = 0; | ||
| } | ||
|
|
||
| if (php_stream_mmap_possible(src)) { |
There was a problem hiding this comment.
I m curious of the performance implications here.
There was a problem hiding this comment.
This impacted just file -> anything other than file and user case which for socket dest is handled by sendfile now so it might slightly regress for cases other than that on linux but sendfile is actually faster from my testing. For other UNIX platforms, we should probably consider sendfile as well. I initially got it so I should consider to put it back to limit impact there. Also file to file will regress there because they don't use copy_file_range (we could consider it again for freebsd maybe).
But I really want to get rid of the mmap because it's causing segfault if file is modified (which we got already report for) so we don't want anything that is causing segfault...
main/io/php_io_copy_windows.c
Outdated
| bytes_to_send = (DWORD) min(maxlen, MAXDWORD); | ||
| } | ||
|
|
||
| if (TransmitFile(dest_sock, file_handle, bytes_to_send, 0, NULL, NULL, 0)) { |
There was a problem hiding this comment.
so linux's splice does the work in chunks but seems to me TransmitfFile is its win32 equivalent, I do not know if we should proceed in a similar manner.
There was a problem hiding this comment.
This is sendfile equivalent. It should be in general safe because it should be only for socket dest but I need to test win more as I can see one test failed (not sure if it's related).
This introduces new API for fd copying and modifies
php_stream_copy_to_stream_exto use it. The implementation is separated for various platforms and the end result have couple of implications: