Details
-
Type: Improvement
-
Status: Open
-
Priority: Minor
-
Resolution: Unresolved
-
Affects Version/s: 4.6, 4.7
-
Fix Version/s: None
-
Component/s: None
-
Labels:
-
Versioning Impact:Patch (backwards-compatible bug fixes)
-
Documentation Required?:None
-
Funding Source:Contributed Code
Description
I did some performance testing for Drupal / CiviCRM using Blackfire.io this week. In that process, I discovered that one Smarty call used a disproportionate amount of CPU time: smarty_core_get_include_path().
This method accounted for 15 to 20 % of the page generation time on a large Drupal 7 + CiviCRM 4.6 installation with a lot of extensions. The screenshot attached shows this could take up to 700 ms if the server was busy. I also tried it on a smaller Drupal 7 + CiviCRM 4.7 installation, that answered much quicker but also reported that about 15% of resources were used by this function.
What this Smarty function does, is running explode on the system include path, then manually checking if there is a file with a certain name in each of those directories. In my case that meant that is_readable() was called tens of thousands of times for each request.
The built-in PHP function stream_resolve_include_path() has been around since PHP 5.3.3, and does the exact same thing as this function tries to do, but in a few microseconds.
This is a Smarty internal issue (and I hope we'll get rid of Smarty 2 soon anyway) - but since this code hasn't changed in twelve years upstream, I think it'd be a good idea to patch this in the version packaged with CiviCRM.
--> Added a PR for both 4.6 and 4.7.
Attachments
Issue Links
- links to