Skip to content

Commit

Permalink
Some performance improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisgraham committed Dec 12, 2017
1 parent 44b0299 commit f723e60
Show file tree
Hide file tree
Showing 19 changed files with 115 additions and 56 deletions.
2 changes: 1 addition & 1 deletion install.php
Expand Up @@ -2526,7 +2526,7 @@ function object_factory($class)
*/
function safe_ini_set($var, $value)
{
if (@preg_match('#(\s|,|^)' . str_replace('#', '\#', preg_quote('ini_set')) . '(\s|$|,)#', strtolower(@ini_get('disable_functions') . ',' . ini_get('suhosin.executor.func.blacklist') . ',' . ini_get('suhosin.executor.include.blacklist') . ',' . ini_get('suhosin.executor.eval.blacklist'))) != 0) {

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

Unnecessary str_replace, preg_quote can handle the extra escaping.

if (@preg_match('#(\s|,|^)' . preg_quote('ini_set', '#') . '(\s|$|,)#', strtolower(@ini_get('disable_functions') . ',' . ini_get('suhosin.executor.func.blacklist') . ',' . ini_get('suhosin.executor.include.blacklist') . ',' . ini_get('suhosin.executor.eval.blacklist'))) != 0) {
return false;
}

Expand Down
2 changes: 2 additions & 0 deletions lang/EN/config.ini
Expand Up @@ -515,3 +515,5 @@ DESCRIPTION_TIMEZONE_SITE=The time zone the site should report in. Note also tha
DOC_BASE_CONFIGURATION=To change an option set during installation, you generally use the external "Installation Options editor".\n\nThe Installation Options editor is completely separated from the main software, so that if your site ever breaks due to a misconfiguration in the <kbd>_config.php</kbd> configuration file (perhaps if you moved servers, and your database settings are no longer valid), you can fix it without having to hand-edit the file. As a result of the separation, the Configuration editor cannot empty caches automatically when you change an option, so after using it you should use the cleanup tools to empty the caches.
BASE_CONFIGURATION=Installation Options

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

This was meant to be on my previous commit, ignore.

DEEPER_CONFIGURATION=Deeper configuration
12 changes: 12 additions & 0 deletions sources/caches.php
Expand Up @@ -140,6 +140,7 @@ class Self_learning_cache
private $pending_save = false;
public $paused = false;
public $empty = true;
private $already_invalidated = false;

/**
* Constructor. Initialise our cache.
Expand Down Expand Up @@ -338,6 +339,11 @@ public function invalidate()
return;
}

if ($this->already_invalidated) {

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

No need to allow this decache function to be run more than once.

return;
}
$this->already_invalidated = true;

if (!is_null($this->path)) {
@unlink($this->path);
} else {
Expand All @@ -356,6 +362,12 @@ public static function erase_smart_cache()
return;
}

static $done_once = false;

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

No need to allow this decache function to be run more than once.

if ($done_once) {
return;
}
$done_once = true;

$dh = @opendir(get_custom_file_base() . '/caches/self_learning');
if ($dh !== false) {
while (($f = readdir($dh)) !== false) {
Expand Down
18 changes: 17 additions & 1 deletion sources/caches3.php
Expand Up @@ -216,6 +216,12 @@ function erase_thumb_cache()
*/
function erase_cached_language()
{
static $done_once = false;
if ($done_once) {
return;
}
$done_once = true;

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

No need to allow this decache function to be run more than once.

cms_profile_start_for('erase_cached_language');

$langs = find_all_langs(true);
Expand Down Expand Up @@ -284,6 +290,16 @@ function erase_cached_templates($preserve_some = false, $only_templates = null,
return; // Optimisation
}

if ((!$rebuild_some_deleted_files) && ($preserve_some)) {
static $done_sweeping_decache_already = false;
if ($done_sweeping_decache_already) {
return;
}
if (($only_templates === null) && ($raw_file_regexp === null)) {
$done_sweeping_decache_already = true;
}
}

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

No need to allow this decache function to be run more than once (this case is a bit more complex, as the function takes various parameters to target the decache).

cms_profile_start_for('erase_cached_templates');

global $ERASED_TEMPLATES_ONCE;
Expand Down Expand Up @@ -344,7 +360,7 @@ function erase_cached_templates($preserve_some = false, $only_templates = null,
foreach ($themes as $theme) {
$using_less =
(addon_installed('less')) || /*LESS-regeneration is too intensive and assumed cache-safe anyway*/
is_file(get_custom_file_base() . '/themes/' . $theme . '/css/global.less') ||
is_file(get_custom_file_base() . '/themes/' . $theme . '/css/global.less') ||
is_file(get_custom_file_base() . '/themes/' . $theme . '/css_custom/global.less');

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

Ignore, my editor strips trailing whitespace on save.

foreach (array_keys($langs) as $lang) {
Expand Down
2 changes: 1 addition & 1 deletion sources/files.php
Expand Up @@ -150,7 +150,7 @@ function cms_file_put_contents_safe($path, $contents, $flags = 4, $retry_depth =
}

// Find file size
clearstatcache();
clearstatcache(true, $path);

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

Can target clearstatcache with more accuracy, avoiding flushing of stats cache for remain of page run-time.

$size = @filesize($path);

// Special condition: File already deleted
Expand Down
6 changes: 5 additions & 1 deletion sources/global.php
Expand Up @@ -414,7 +414,11 @@ function php_function_allowed($function)
return false;
}
}
$cache[$function] = (@preg_match('#(\s|,|^)' . str_replace('#', '\#', preg_quote($function)) . '(\s|$|,)#', strtolower(@ini_get('disable_functions') . ',' . ini_get('suhosin.executor.func.blacklist') . ',' . ini_get('suhosin.executor.include.blacklist') . ',' . ini_get('suhosin.executor.eval.blacklist'))) == 0);

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

Unnecessary str_replace, preg_quote can handle the extra escaping.

static $disabled_functions = null;
if ($disabled_functions === null) {
$disabled_functions = strtolower(@ini_get('disable_functions') . ',' . ini_get('suhosin.executor.func.blacklist') . ',' . ini_get('suhosin.executor.include.blacklist') . ',' . ini_get('suhosin.executor.eval.blacklist'));
}
$cache[$function] = (@preg_match('#(\s|,|^)' . preg_quote($function, '#') . '(\s|$|,)#', $disabled_functions) == 0);
return $cache[$function];
}

Expand Down
10 changes: 7 additions & 3 deletions sources/global2.php
Expand Up @@ -35,7 +35,7 @@ function init__global2()
}
$error_log_path = get_custom_file_base() . '/data_custom/errorlog.php';
safe_ini_set('error_log', $error_log_path);
if (is_file($error_log_path) && filesize($error_log_path) < 17) {
if ((is_file($error_log_path)) && (filesize($error_log_path) < 17)) {

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

Ignore, small formatting cleanup.

@file_put_contents($error_log_path, "<" . "?php return; ?" . ">\n", LOCK_EX);
}

Expand Down Expand Up @@ -350,7 +350,7 @@ function init__global2()
setlocale(LC_ALL, explode(',', do_lang('locale')));
if (substr(@strftime('%M'), 0, 2) == '??') { // Windows may do this because it can't output a utf-8 character set, so gets mangled to question marks by PHP
setlocale(LC_ALL, explode(',', 'en-GB.UTF-8,en_GB.UTF-8,en-US.UTF-8,en_US.UTF-8,en.UTF-8,en-GB,en_GB,en-US,en_US,en')); // The user will have to define locale_subst correctly
}
}

// Check RBLs
$spam_check_level = get_option('spam_check_level');
Expand Down Expand Up @@ -874,6 +874,7 @@ function is_browser_decaching()
}

if (GOOGLE_APPENGINE) {
$BROWSER_DECACHEING_CACHE = false;
return false; // Decaching by mistake is real-bad when Google Cloud Storage is involved

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

Bug, we were not setting $BROWSER_DECACHEING_CACHE, so this function ran many times, and _config.php would be rewritten many times to remove the "need to decache" flag.

}

Expand All @@ -883,15 +884,18 @@ function is_browser_decaching()
$config_file = rtrim(str_replace(array('if (!defined(\'DO_PLANNED_DECACHE\')) ', 'define(\'DO_PLANNED_DECACHE\', true);'), array('', ''), $config_file)) . "\n\n";
require_code('files');
cms_file_put_contents_safe(get_file_base() . '/_config.php', $config_file, FILE_WRITE_FIX_PERMISSIONS);
$BROWSER_DECACHEING_CACHE = true;
return true;
}

if (get_value('ran_once') === null) { // Track whether Composr has run at least once
set_value('ran_once', '1');
$BROWSER_DECACHEING_CACHE = true;
return true;
}

return false; // This technique stopped working well, Chrome sends cache-control too freely
$BROWSER_DECACHEING_CACHE = false;
return false; // This technique stopped working well, Chrome sends cache-control too freely

/*
$header_method = (array_key_exists('HTTP_CACHE_CONTROL', $_SERVER)) && ($_SERVER['HTTP_CACHE_CONTROL'] == 'no-cache') && (cms_srv('REQUEST_METHOD') != 'POST') && ((!function_exists('browser_matches')));
Expand Down
2 changes: 1 addition & 1 deletion sources/global3.php
Expand Up @@ -2582,7 +2582,7 @@ function is_mobile($user_agent = null, $truth = false)
return false;
}
} else {
if (preg_match('#(^|,)\s*' . str_replace('#', '\#', preg_quote(get_page_name())) . '\s*(,|$)#', $details['mobile_pages']) == 0 && preg_match('#(^|,)\s*' . str_replace('#', '\#', preg_quote(get_zone_name() . ':' . get_page_name())) . '\s*(,|$)#', $details['mobile_pages']) == 0) {

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

Unnecessary str_replace, preg_quote can handle the extra escaping.

if (preg_match('#(^|,)\s*' . preg_quote(get_page_name(), '#') . '\s*(,|$)#', $details['mobile_pages']) == 0 && preg_match('#(^|,)\s*' . preg_quote(get_zone_name() . ':' . get_page_name(), '#') . '\s*(,|$)#', $details['mobile_pages']) == 0) {
$IS_MOBILE_CACHE = false;
return false;
}
Expand Down
7 changes: 7 additions & 0 deletions sources/lang3.php
Expand Up @@ -87,13 +87,19 @@ function _find_all_langs($even_empty_langs = false)
{
require_code('files');

static $cached = array();
if (isset($cached[$even_empty_langs])) {
return $cached[$even_empty_langs];
}

// NB: This code is heavily optimised

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

We can cache the output of this function, which may be called many times.


$_langs = array(fallback_lang() => 'lang');

if (!in_safe_mode()) {
$test = persistent_cache_get('LANGS_LIST');
if ($test !== null) {
$cached[$even_empty_langs] = $test;
return $test;
}

Expand Down Expand Up @@ -160,6 +166,7 @@ function _find_all_langs($even_empty_langs = false)
persistent_cache_set('LANGS_LIST', $_langs);
}

$cached[$even_empty_langs] = $_langs;
return $_langs;
}

Expand Down
16 changes: 8 additions & 8 deletions sources/lang_compile.php
Expand Up @@ -79,19 +79,19 @@ function require_lang_compile($codename, $lang, $type, $cache_path, $ignore_erro

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

is_file is faster than file_exists. We can use it if we know for sure it's a file and not a directory.

// Load originals
$lang_file = get_file_base() . '/lang/' . $lang . '/' . filter_naughty($codename) . '.ini';
if (file_exists($lang_file)) { // Non-custom, Proper language
if (is_file($lang_file)) { // Non-custom, Proper language
_get_lang_file_map($lang_file, $load_target, 'strings', false, true, $lang);
$bad = false;
}

// Load overrides now if they are there
if ($type !== 'lang') {
$lang_file = get_custom_file_base() . '/lang_custom/' . $lang . '/' . $codename . '.ini';
if ((!file_exists($lang_file)) && (get_file_base() !== get_custom_file_base())) {
if ((!is_file($lang_file)) && (get_file_base() !== get_custom_file_base())) {
$lang_file = get_file_base() . '/lang_custom/' . $lang . '/' . $codename . '.ini';
}
}
if (($type !== 'lang') && (file_exists($lang_file))) {
if (($type !== 'lang') && (is_file($lang_file))) {
_get_lang_file_map($lang_file, $load_target, 'strings', false, true, $lang);
$bad = false;
$dirty = true; // Tainted from the official pack, so can't store server wide
Expand All @@ -103,7 +103,7 @@ function require_lang_compile($codename, $lang, $type, $cache_path, $ignore_erro
require_lang($codename, fallback_lang(), $type, $ignore_errors);
$REQUIRE_LANG_LOOP--;
$fallback_cache_path = get_custom_file_base() . '/caches/lang/' . fallback_lang() . '/' . $codename . '.lcd';
if (file_exists($fallback_cache_path)) {
if (is_file($fallback_cache_path)) {
require_code('files');
@copy($fallback_cache_path, $cache_path);
fix_permissions($cache_path);
Expand Down Expand Up @@ -203,14 +203,14 @@ function get_lang_file_section($lang, $file = null, $section = 'descriptions')
function get_lang_file_map($lang, $file, $non_custom = false, $apply_filter = true)
{
$a = get_custom_file_base() . '/lang_custom/' . $lang . '/' . $file . '.ini';
if ((get_custom_file_base() !== get_file_base()) && (!file_exists($a))) {
if ((get_custom_file_base() !== get_file_base()) && (!is_file($a))) {
$a = get_file_base() . '/lang_custom/' . $lang . '/' . $file . '.ini';
}

if ((!file_exists($a)) || ($non_custom)) {
if ((!is_file($a)) || ($non_custom)) {
$b = get_custom_file_base() . '/lang/' . $lang . '/' . $file . '.ini';

if (file_exists($b)) {
if (is_file($b)) {
$a = $b;
} else {
if ($non_custom) {
Expand Down Expand Up @@ -239,7 +239,7 @@ function get_lang_file_map($lang, $file, $non_custom = false, $apply_filter = tr
function _get_lang_file_map($b, &$entries, $section = 'strings', $given_whole_file = false, $apply_filter = true, $lang = null)
{
if (!$given_whole_file) {
if (!file_exists($b)) {
if (!is_file($b)) {
return;
}

Expand Down
42 changes: 25 additions & 17 deletions sources/lang_filter_EN.php
Expand Up @@ -220,9 +220,10 @@ public function compile_time($key, $value, $lang = null)

// Put in correct brand name
if (!is_null($key)) {
$remapping['the software'] = preg_quote(brand_name(), '#');
$remapping['the website software'] = preg_quote(brand_name(), '#');
$remapping['other webmasters'] = 'other ' . preg_quote(brand_name(), '#') . ' users';
$brand_name = brand_name();

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

No need to call brand_name 3 times.

$remapping['the software'] = preg_quote($brand_name, '#');
$remapping['the website software'] = preg_quote($brand_name, '#');
$remapping['other webmasters'] = 'other ' . preg_quote($brand_name, '#') . ' users';
}

// Fix bad contextualisation
Expand All @@ -247,29 +248,36 @@ public function compile_time($key, $value, $lang = null)
if ($is_american) {
// NB: Below you will see there are exceptions, typically when the base word already naturally ends with "se" on the end, it uses "s" not "z"

$value = str_replace('sation', 'zation', $value);
$value = str_replace('converzation', 'conversation', $value); // Exception, put this back
$value = str_replace('Converzation', 'Conversation', $value); // Exception, put this back
if (strpos($value, 'sation') !== false) {

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

No need to run all the str_replace's to correct the exceptions of the first str_replace, if the string being considered isn't even present.

$value = str_replace('sation', 'zation', $value);
$value = str_replace('converzation', 'conversation', $value); // Exception, put this back
$value = str_replace('Converzation', 'Conversation', $value); // Exception, put this back
}

$value = str_replace('sable', 'zable', $value);
$value = str_replace('dizable', 'disable', $value); // Exception, put this back
$value = str_replace('Dizable', 'Disable', $value); // Exception, put this back
$value = str_replace('advizable', 'advisable', $value); // Exception, put this back
$value = str_replace('Advizable', 'Advisable', $value); // Exception, put this back
$value = str_replace('purchazable', 'purchasable', $value); // Exception, put this back
$value = str_replace('Purchazable', 'Purchasable', $value); // Exception, put this back
$value = str_replace('uzable', 'usable', $value); // Exception, put this back
if (strpos($value, 'sable') !== false) {
$value = str_replace('sable', 'zable', $value);
$value = str_replace('dizable', 'disable', $value); // Exception, put this back
$value = str_replace('Dizable', 'Disable', $value); // Exception, put this back
$value = str_replace('advizable', 'advisable', $value); // Exception, put this back
$value = str_replace('Advizable', 'Advisable', $value); // Exception, put this back
$value = str_replace('purchazable', 'purchasable', $value); // Exception, put this back
$value = str_replace('Purchazable', 'Purchasable', $value); // Exception, put this back
$value = str_replace('uzable', 'usable', $value); // Exception, put this back
}

$value = str_replace('sational', 'zational', $value);
$value = str_replace('senzational', 'sensational', $value); // Exception, put this back
if (strpos($value, 'sational') !== false) {
$value = str_replace('sational', 'zational', $value);
$value = str_replace('senzational', 'sensational', $value); // Exception, put this back
}

$remapping = $this->make_uncle_sam_happy;
} else {
$remapping = $this->the_sun_never_sets_on_the_british_empire;
}

$lc_value = strtolower($value);
foreach ($remapping as $authentic => $perverted) {
if (stripos($value, $authentic) !== false) {
if (strpos($lc_value, $authentic) !== false) {
$value = preg_replace(
'#(^|\s)' . preg_quote($authentic, '#') . '#',
'$1' . $perverted,
Expand Down
2 changes: 1 addition & 1 deletion sources/minikernel.php
Expand Up @@ -177,7 +177,7 @@ function php_function_allowed($function)
return false;
}
}
return (@preg_match('#(\s|,|^)' . str_replace('#', '\#', preg_quote($function)) . '(\s|$|,)#', strtolower(@ini_get('disable_functions') . ',' . ini_get('suhosin.executor.func.blacklist') . ',' . ini_get('suhosin.executor.include.blacklist') . ',' . ini_get('suhosin.executor.eval.blacklist'))) == 0);
return (@preg_match('#(\s|,|^)' . preg_quote($function, '#') . '(\s|$|,)#', strtolower(@ini_get('disable_functions') . ',' . ini_get('suhosin.executor.func.blacklist') . ',' . ini_get('suhosin.executor.include.blacklist') . ',' . ini_get('suhosin.executor.eval.blacklist'))) == 0);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion sources/news2.php
Expand Up @@ -876,7 +876,7 @@ function _news_import_grab_images_and_fix_links($download_images, &$data, $impor
// Go through other items, in case this news article/page is linking to them and needs a fixed link
foreach ($imported_news as $item) {
if (array_key_exists('full_url', $item)) {
$num_matches = preg_match_all('#<a\s*([^<>]*)href="' . str_replace('#', '\#', preg_quote(escape_html($item['full_url']))) . '"([^<>]*)>(.*)</a>#isU', $data, $matches);
$num_matches = preg_match_all('#<a\s*([^<>]*)href="' . preg_quote(escape_html($item['full_url']), '#') . '"([^<>]*)>(.*)</a>#isU', $data, $matches);
for ($i = 0; $i < $num_matches; $i++) {
if (($matches[1][$i] == '') && ($matches[2][$i] == '') && (strpos($data, '[html]') === false)) {
$data = str_replace($matches[0][$i], '[page="_SEARCH:news:view:' . strval($item['import_id']) . '"]' . $matches[3][$i] . '[/page]', $data);
Expand Down
6 changes: 6 additions & 0 deletions sources/sitemap.php
Expand Up @@ -1154,6 +1154,11 @@ function get_root_comcode_pages($zone, $include_zone = false)

// This uses more memory than the above, but is needed as pages may not have got into the database yet...

static $cache = array();

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

Can cache the output of this function.

if (isset($cache[$zone][$include_zone])) {
return $cache[$zone][$include_zone];
}

disable_php_memory_limit();

static $rows = array();
Expand Down Expand Up @@ -1191,6 +1196,7 @@ function get_root_comcode_pages($zone, $include_zone = false)

$page_links[$key] = isset($root[$page]) ? $root[$page] : 1;
}
$cache[$zone][$include_zone] = $page_links;
return $page_links;
}

Expand Down
17 changes: 6 additions & 11 deletions sources/textfiles.php
Expand Up @@ -47,15 +47,15 @@ function _find_text_file_path($codename, $lang)
do {
$lang = $langs[$i];
$path = get_custom_file_base() . '/text_custom/' . $lang . '/' . $codename . '.txt';
if (!file_exists($path)) {
if (!is_file($path)) {

This comment has been minimized.

Copy link
@chrisgraham

chrisgraham Dec 12, 2017

Author Contributor

is_file faster than file_exists

$path = get_file_base() . '/text_custom/' . $lang . '/' . $codename . '.txt';
}
if (!file_exists($path)) {
if (!is_file($path)) {
$path = get_file_base() . '/text/' . $lang . '/' . $codename . '.txt';
}
$i++;
} while ((!file_exists($path)) && (array_key_exists($i, $langs)));
if (!file_exists($path)) {
} while ((!is_file($path)) && (array_key_exists($i, $langs)));
if (!is_file($path)) {
$path = '';
}

Expand All @@ -74,8 +74,7 @@ function read_text_file($codename, $lang = null, $missing_blank = false)
{
$path = _find_text_file_path($codename, $lang);

$tmp = @fopen($path, 'rb');
if ($tmp === false) {
if (!is_file($path)) {
if ($lang !== fallback_lang()) {
return read_text_file($codename, fallback_lang(), $missing_blank);
}
Expand All @@ -85,11 +84,7 @@ function read_text_file($codename, $lang = null, $missing_blank = false)
}
warn_exit(do_lang_tempcode('MISSING_TEXT_FILE', escape_html($codename), escape_html('text/' . (is_null($lang) ? '' : ($lang . '/')) . $codename . '.txt')));
}
flock($tmp, LOCK_SH);
$in = @file_get_contents($path);
flock($tmp, LOCK_UN);
fclose($tmp);
$in = unixify_line_format($in);
$in = unixify_line_format(cms_file_get_contents_safe($path));

if (strpos($path, '_custom/') === false) {
global $LANG_FILTER_OB;
Expand Down

1 comment on commit f723e60

@chrisgraham
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my last live chat my Composr install was running slow on some page requests.
I have since found that this was due to my Mac's Time Machine backup running in the background (Apple's iterative backup service). As I use an SSD, it's silent - but it will saturate my I/O quite badly if that happens.

Additionally doing cam streaming can use up CPU as it has to compress the MPEG stream on the fly.

Never-the-less, it's always good to do some performance optimisation, and I've done some profiling on an "empty" cache scenario.

Here are the main issues found and fixed...

  • re-reading/re-writing _config in support_smart_decaching function many times immediately after decache.sh script run (i.e. lots of unnecessary disk IO)
  • slow running with comcode_whitelists addons (read_file was recalled on comcode_whitelist.txt for every bit of Comcode parsed)
  • sub-optimal US English compilation (when the US English is option on language string compilation has extra overhead, and I've optimised it now)
  • unneeded non-parallelised JS compile (one particular JS cache file was regenerating on the first screen after a decache, which was not necessary)
  • double decaching (some unnecessary double decaching was happening after decache.sh was run; decaching has some overhead)
  • clearstatcache call when writing files (this flushes out the stats cache on files, slowing the rest of the page load; only happened after decache as it rewrote the cache files - now it's changed to only clear stat caching on the file being written, for PHP5.3+)
  • get_root_comcode_pages multiple calls (this method called more than once when generating site-map, now cached)

All these issues are related either to decaching, or subsequent recaching. On a normal machine it would likely be less than a second of overhead, happening at an exceptional situation. However when debugging on a machine with saturated I/O it's much more noticeable.

Please sign in to comment.