-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stream wrapper slower than the direct API #81
Comments
A tcpdump of the SMB connection shows that the "fast" code sends many more packets between each response of the server. This suggests that the stream wrapper waits for a response from the server before sending more data. |
We also noticed that |
copy
much slower than the API
Sorry, cannot reproduce (on linux, using a Samba server) Output with progress info:
|
I can indeed see slower process using stream, but only with PHP 7, same speed with PHP 8
|
After digging, stream API with PHP 7 split write in 8K bloc, so run much more calls IMHO, nothing we can do in this extension side. |
For memory (chunk_size usage dropped in 8) PHP 7: https://github.com/php/php-src/blob/PHP-7.4/main/streams/streams.c#L1122 |
This can be workaround in userland with
@eduardok can also be managed in extension using
But I don't know if this is really a good idea to differ from the default value, especially as I don't see any extension using such change, so probably better to keep this for userland (perhaps some words in docs) |
Thank you for the excellent research and explanation. The commit that removed the chunking is php/php-src@5cbe5a5. There's even a PHP bug for the slow writes: https://bugs.php.net/bug.php?id=73262 Setting the chunk size also fixes the slow read speed. Here's my test script:
Regarding the proposed changes:
I saw that the HTTP wrapper changes the chunk size temporarily, so this might be ok to do in code: https://github.com/php/php-src/blob/3e01f5afb1b52fe26a956190296de0192eedeec1/ext/standard/http_fopen_wrapper.c#L351
|
I just tested PHP 8 now. PHP 8 fixes the write performance of the stream wrappers. The read performance is still bad though and requires the workaround with |
hello! i am using this module with nextclod-21 server for connection my external dfs-mountpoint (smb). (servers are located on neighboring virtual machines in the same 10-gigabit LAN). my stable config is a also had reinstalled nextcloud from scratch on various pure test systems - and i have same bad result. I noticed that performance was degraded since january 2021.. when i downloading files - i have very slow download speed. about 1-3Mb per sec, although earlier it was maximum, since I am on the same local network. maybe i should downgrade to old version of nextcloud (that supports php7.2) and install it on 18.04 ubuntu server that includes old stable version of this php-module (0.8.0).. sorry for my bad english, i am a little jaded of researching and debugging this problem. best regards. |
Overview
The stream wrappers are really useful. However, we noticed that copy operations are much slower. The client runs on Linux and the server on Windows.
For a 65 MB file we took the following measurements:
Code
stream copy
stream fwrite
smbclient_write
The text was updated successfully, but these errors were encountered: