-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Updated the article about performance tuning tips #6937
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dd057dd
Updated the article about performance tuning tips
javiereguiluz 6409fc5
Fixes and improvements
javiereguiluz fab7a0a
Minor reword
javiereguiluz c1b64cc
Further rewordings and improvements
javiereguiluz b9d94b8
Added a mention to opcache.max_accelerated_files
javiereguiluz e2abd22
Added a note about the different caches for CLI and the server
javiereguiluz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,15 +12,15 @@ application even faster. | |
.. index:: | ||
single: Performance; Byte code cache | ||
|
||
Use a Byte Code Cache (e.g. APC) | ||
-------------------------------- | ||
Use a Byte Code Cache (e.g. OPcache) | ||
------------------------------------ | ||
|
||
One of the best (and easiest) things that you should do to improve your performance | ||
is to use a "byte code cache". The idea of a byte code cache is to remove | ||
the need to constantly recompile the PHP source code. There are a number of | ||
`byte code caches`_ available, some of which are open source. As of PHP 5.5, | ||
PHP comes with `OPcache`_ built-in. For older versions, the most widely used | ||
byte code cache is probably `APC`_ | ||
byte code cache is `APC`_. | ||
|
||
Using a byte code cache really has no downside, and Symfony has been architected | ||
to perform really well in this type of environment. | ||
|
@@ -43,6 +43,25 @@ your ``php.ini`` configuration. | |
.. index:: | ||
single: Performance; Autoloader | ||
|
||
Configure the PHP realpath cache | ||
-------------------------------- | ||
|
||
PHP uses an internal cache to store the result of mapping file paths to their | ||
real and absolute file system paths. This increases the performance for | ||
applications like Symfony that open many PHP files, specially on Windows | ||
systems. | ||
|
||
By default PHP sets a default ``realpath_cache_size`` of ``16K`` which is too | ||
low for Symfony. Consider updating this value at least to ``4096K``. In | ||
addition, cached paths are only stored for ``120`` seconds. Consider updating | ||
this value too using the ``realpath_cache_ttl`` option: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "[...] option in your |
||
|
||
.. code-block:: ini | ||
|
||
; php.ini | ||
realpath_cache_size=4096K | ||
realpath_cache_ttl=600 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to indent with 4 spaces |
||
|
||
Use Composer's Class Map Functionality | ||
-------------------------------------- | ||
|
||
|
@@ -52,18 +71,25 @@ automatically find any new classes that you've placed in the registered | |
directories. | ||
|
||
Unfortunately, this comes at a cost, as the loader iterates over all configured | ||
namespaces to find a particular file, making ``file_exists`` calls until it | ||
namespaces to find a particular file, making ``file_exists()`` calls until it | ||
finally finds the file it's looking for. | ||
|
||
The simplest solution is to tell Composer to build a "class map" (i.e. a | ||
big array of the locations of all the classes). This can be done from the | ||
command line, and might become part of your deploy process: | ||
The simplest solution is to tell Composer to build an optimized "class map", | ||
which is a big array of the locations of all the classes and it's stored | ||
in ``vendor/composer/autoload_classmap.php``. | ||
|
||
The class map can be generated from the command line, and might become part of | ||
your deploy process: | ||
|
||
.. code-block:: bash | ||
|
||
$ composer dump-autoload --optimize | ||
$ composer dump-autoload --optimize --no-dev --classmap-authoritative | ||
|
||
Internally, this builds the big class map array in ``vendor/composer/autoload_classmap.php``. | ||
The ``--optimize`` option dumps every PSR-0 and PSR-4 compatible class used in | ||
your application. The ``--no-dev`` option excludes the classes that are only | ||
needed in the development environment (e.g. tests). The ``--classmap-authoritative`` | ||
option prevents Composer from scanning the file system for classes that are not | ||
found in the class map. | ||
|
||
Caching the Autoloader with APC | ||
------------------------------- | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cache