-
Notifications
You must be signed in to change notification settings - Fork 995
Avoid uniqid() for performance sake #9905
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
base: master
Are you sure you want to change the base?
Conversation
uniqid() provides time-based unique idenfitiers. In order to avoid collisions, it waits for time to elapse. Depending on PHP version, this is done by sleeping or by polling the gettimeofday() system call, both approach being rather inefficient. uniqid() may take a few dozen of milliseconds to return, and it is called very often to build a page. AVideo implements _uniqid() which provides random-based unique identifiers. This change replace uniqid() calls by _uniqid() to improve performances.
Sorry but I do not like this find and replace without test also I am not sure if it will make any difference in the performance. Currently you are the only one complaining that slow down on last update also does it already makes any difference for you? how much performance did you gain? |
On Thu, Feb 27, 2025 at 07:19:12PM -0800, Daniel Neto wrote:
Sorry but I do not like this find and replace without test
I agree the change is intrusive. What about adding a global
option to decide what implementation to use?
Currently you are the only one complaining that slow down on last update
I updated from 8.9.1
also does it already makes any difference for you? how much performance did you gain?
Before the change, the home page takes 16s to load.
After the change, it loads in 0.7s.
|
(that means: PHP native uniqid() is used unless the setting is toggled) _uniqid() also gets an optional parameter to force the local implementation instead of native PHP uniqid(), whatever the global setting is.
as we may have been included from a plugin.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi,
This is an update to keep the issue open. There was not comment on the
latest patch, was there?
…--
Emmanuel Dreyfus
***@***.***
|
uniqid() provides time-based unique idenfitiers. In order to avoid collisions, it waits for time to elapse. Depending on PHP version, this is done by sleeping or by polling the gettimeofday() system call, both approach being rather inefficient. uniqid() may take a few dozen of milliseconds to return, and it is called very often to build a page.
AVideo implements _uniqid() which provides random-based unique identifiers. This change replace uniqid() calls by _uniqid() to improve performances.