Welcome Guest, Not a member yet? Register   Sign In
Under PHP 5.3, Error Logging - Incrementally & significantly slower each pageload (not so under PHP 5.2)
#1

[eluser]haydenp[/eluser]
I have the same CI web app running on two different development servers. Both web aps are set with a Error Logging Threshold = 4 (All Messages)

SERVER A
PHP Version 5.2.5
CI 1.7.2

SERVER B
PHP Version 5.3.1
CI 1.7.2

I've noticed that the Total Execution Time on SERVER B gets incrementally and significantly higher each pageload, whilst on the server running PHP 5.2.5 there is no real significant increase.

For Example:

SERVER A (PHP 5.2.5, CI 1.7.2)

If I refresh the same page on SERVER A 10 times, the total execution times are as follows:

0.2252, 0.2115, 0.2053, 0.2050, 0.2057, 0.2093, 0.2023, 0.2081, 0.2038, 0.2015

The total logs filesize after 10 page refreshes = 30KB

SERVER B (PHP 5.3.1, CI 1.7.2)

If I refresh the same page on SERVER B 10 times, the total execution times are as follows:

0.3971, 0.5386, 0.7088, 0.8374, 0.9149, 1.0824, 1.2196, 1.2908, 1.3546, 1.5692

The total logs filesize after 10 page refreshes = 32KB

From the above, Error Logging on SERVER A does not have as significant an impact on the Total Execution Time of a page as it does on SERVER B.

It all eminates from the write_log() function in Log.php and I am wondering if it has to do with the use of the date() call throwing warnings in PHP 5.3 and having to use date_default_timezone_set() to avoid them?

On a busy site, even if the Error Logging Threshold was set to 1, the impact this would have could be a cause for concern.

Any ideas or has anyone come across this under CI 1.7.2 / PHP 5.3?
#2

[eluser]haydenp[/eluser]
This morning I took a clean copy of CI 1.7.2 and installed it on SERVER B (PHP Version 5.3.1)

I set the "Error Logging Threshold" to 4 (All Messages)

Code:
$config['log_threshold'] = 4;

I added the enable_profiler() in the welcome.php controller

Code:
$this->output->enable_profiler(TRUE);

Then refreshed the "Welcome to CodeIgniter!" page a number of times ... again the "Total Execution Time" of the page gets incrementally and significantly higher each pageload.

As mentioned in my previous post, this does not seem to be the case in PHP 5.2.

Could it possibly be related to my PHP 5.3.1 install (the read/writing of files)? Could it possibly be a bug in CI 1.7.2 running on PHP 5.3.1. Could it possibly have an impact elsewhere in the CI codebase?

In this instance I have isolated the problem to the fwrite($fp, $message); call in the write_log() method in Log.php.

Is fwrite() slower under PHP 5.3.1 ??? ... right now I think it may be more a server setup issue?
#3

[eluser]haydenp[/eluser]
Still not sure why logging is slower in PHP 5.3.1 when compared to PHP 5.2.5 ...

BUT for anyone interested, I dug up this old post and I implemented the solution provided by esbium. I can confirm that it does provide a remarkable improvement on CI's Error Logging performance.




Theme © iAndrew 2016 - Forum software by © MyBB