You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Phalcon\Autoloader is slow because the is_file() test is slow. With a lot of files, this can add a serious amount of time, especially if the whole PHP run is small.
stream => stream_resolve_include_path() (as it seems to be really faster than is_file(), but implies some issues if the file is removed from the filesystem)
none => no file check (you should always have a class file if you load one class, don't you? It's true only if you don't use multiple directories for the same namespace)
Details
Phalcon version: 3.3.2
PHP Version: 7.0.27
Operating System: Linux Debian stable
Installation type: installing via package manager
Zephir version (if any): (from package) 0.10.7
Server: Lighttpd
Other related info: none
The text was updated successfully, but these errors were encountered:
Expected and Actual Behavior
Phalcon\Autoloader is slow because the
is_file()
test is slow. With a lot of files, this can add a serious amount of time, especially if the whole PHP run is small.See #10472 for instance, and specifically comment: #10472 (comment)
Reproduce script:
=> for 120 files
=> first load: about 120ms
=> next loads: 4-8ms (opcache must play a part here)
=> takes less than a millisecond as expected
=> for 121 files
=> first load: 250ms
=> next loads: 100-150ms (about 1ms per loaded class)
The culprit is the
is_file()
test before including the class: https://github.com/phalcon/cphalcon/blob/v3.3.2/phalcon/loader.zep#L368Proposed fix
Add a parameter, either as a new function (
setFileChecking
) or as a third parameter inregisterNamespaces()
(see https://github.com/phalcon/cphalcon/blob/v3.3.2/phalcon/loader.zep#L109), for example$this->fileChecking
:is_file()
stream_resolve_include_path()
(as it seems to be really faster thanis_file()
, but implies some issues if the file is removed from the filesystem)Details
The text was updated successfully, but these errors were encountered: