go_away

Author Topic: php problem: include() function slow by 2+ seconds  (Read 3769 times)

0 Members and 1 Guest are viewing this topic.

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,657
  • Helpful? 169
    • Society of Robots
php problem: include() function slow by 2+ seconds
« on: May 25, 2009, 10:47:55 AM »
I've determined that the php include() function is somehow slowing chatbot down by 2 seconds. All chatbot software is in this include file.

If I don't use an include, and keep all code outside the include, it runs super fast. If I put the same exact code into the include file, the delay comes to closer to 2+ seconds.

I tried prefixing it with a file_exists() but no luck.

I have output_buffering set to 1 and using php v4.3.9-3.18.1.

Anyone with ideas?

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 108
Re: php problem: include() function slow by 2+ seconds
« Reply #1 on: May 30, 2009, 11:27:55 AM »
Am a php idiot -  but ....

How are you specifying the include files?  eg  'http://www.blahblah.com.file.php',  or relative urls etc. Am sure you've already found this http://forums.site5.com/showthread.php?t=12129

Do you have lots of files that includes lots of other files that include lots of other files...etc. Are some files getting loading multiple times? Maybe 'include_once' could be an answer.

But mainly ----- I found this:
Quote
To avoid painfully SLOW INCLUDES under IIS be sure to set "output_buffering = on" in php.ini. File includes dropped from about 2 seconds to 0 seconds when this was set.


Note the use of 'on' rather than '1'
« Last Edit: May 30, 2009, 11:51:53 AM by Webbot »
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,657
  • Helpful? 169
    • Society of Robots
Re: php problem: include() function slow by 2+ seconds
« Reply #2 on: May 30, 2009, 12:33:07 PM »
Yea thats the exact post I saw that made me think to change the buffering.

The host changed it to '1' when I asked them to change it to 'on'. I figured they knew what they were doing so didn't complain . . .

Anyway, I told them to change it to 'on' again, so lets wait and see . . .

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,657
  • Helpful? 169
    • Society of Robots
Re: php problem: include() function slow by 2+ seconds
« Reply #3 on: May 30, 2009, 01:00:34 PM »
My host still refused to set it to 'on,' and this time changed it to:
output_buffering=4096

Webbot, see this:
http://www.php.net/manual/en/outcontrol.configuration.php

right . . . should I insist for a 3rd time to set it to 'on'?

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 108
Re: php problem: include() function slow by 2+ seconds
« Reply #4 on: May 30, 2009, 01:12:50 PM »
Ok so that link still suggests that it can be set to either a boolean or an integer.

The definition of boolean says:-

 
Quote
When converting to boolean, the following values are considered FALSE:

    * the boolean FALSE itself
    * the integer 0 (zero)
    * the float 0.0 (zero)
    * the empty string, and the string "0"
    * an array with zero elements
    * an object with zero member variables (PHP 4 only)
    * the special type NULL (including unset variables)
    * SimpleXML objects created from empty tags

Every other value is considered TRUE (including any resource).

Since the current value is '1' then it is treated as an Integer whereas 'on' is not an integer and doesn't satisfy any off the above so it will be treated as boolean true.

I guess your host is worried because 'on' implies 'unlimited' and they may be worried if the files are very large as it may grab all the server memory.

So the current value of '1' is bad - as this probably means '1 byte'.  Hence their suggestion of a limited value such as 4096. I 'think' this value is 'bytes' - so check the size of your included file and if it is > 4096 then ask for a bigger value.

So go with the 4096 but it may be worth asking if they will allow 'on' for a trial period. If 'on' works but '4096' doesn't then you may need to increase the '4096' value. ie 'on' means 'infinite'.
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,657
  • Helpful? 169
    • Society of Robots
Re: php problem: include() function slow by 2+ seconds
« Reply #5 on: May 30, 2009, 01:44:42 PM »
The host sent this email:

Quote
Hello, Dear customer, If we set output_buffering = on php-nfo will show you value "1" I have set it to 20480

Either way, problem still exists . . .

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 108
Re: php problem: include() function slow by 2+ seconds
« Reply #6 on: May 30, 2009, 01:48:25 PM »
I think they are just being awkward. Ok if they don't like 'on' then lets go for '102400'
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,657
  • Helpful? 169
    • Society of Robots
Re: php problem: include() function slow by 2+ seconds
« Reply #7 on: May 30, 2009, 02:49:08 PM »
I put up a post for ajax chat on sourceforge, maybe someone will know . . .

https://sourceforge.net/forum/message.php?msg_id=7418412

and phpfreaks.com:
http://www.phpfreaks.com/forums/index.php/topic,254560.0.html

(posted here as a cross reference)
« Last Edit: May 30, 2009, 03:13:42 PM by Admin »

 


Get Your Ad Here