librespeed / speedtest

Self-hosted Speed Test for HTML5 and more. Easy setup, examples, configurable, mobile friendly. Supports PHP, Node, Multiple servers, and more
https://librespeed.org
GNU Lesser General Public License v3.0
12.29k stars 2.21k forks source link

fix: download speed is 0 on certain platform #617

Closed zypA13510 closed 6 months ago

zypA13510 commented 6 months ago

Reverting this commit fixed #613 for me. Tested with my own build ghcr.io/zypa13510/librespeed. I'm not exactly sure why, not a PHP expert, but my guess is that the random_byte() call could be using CSPRNG which is slower. If that is the case, I believe it is perfectly fine to not use CSPRNG, as this is just a speed test not a password generator.

Revert: fa0ac8cd2336052286cd3556889449660e4d9c83, #487 Close: #613

zypA13510 commented 6 months ago

Just proved my guess: I added %^FB (delay in microseconds between when the request arrived and the first byte of the response headers are written) and %D (the time taken to serve the request, in microseconds) to the apache log format inside the container. As it turns out, the TTFB for the version without random_byte() is 1~5 ms, and using random_byte() increased that to more than 15 seconds. While I'm still not sure why random_byte() is so slow especially on Synology, like I said, not a PHP expert, but it is pretty clear to me now the random_byte() call is the root cause of #613.