Bug #10299 Updated: CPU and Memory Spike

From: Date: Sun, 20 May 2001 12:39:37 +0000
Subject: Bug #10299 Updated: CPU and Memory Spike
Groups: php.dev 
Request: Send a blank email to php-dev+get-55948@lists.php.net to get a copy of this message
ID: 10299 Updated by: jmoore Reported By: goten@mylaptop.com Old-Status: Critical Status: Analyzed Bug Type: Performance problem Operating system: PHP Version: 4.0.4pl1 Assigned To: Comments: We cant reproduce this so not really critical, reutnring to analysed. - James Previous Comments: --------------------------------------------------------------------------- [2001-05-17 09:05:32] zeev@php.net I'm unable to reproduce a fd leak using require_once() or include_once(). Do you have any script that reproduces this problem? We can't really replicate your problem in general, but if somehow there's a resource leak in your setup, lots of different weird things could end up happening. --------------------------------------------------------------------------- [2001-05-09 01:08:11] goten@mylaptop.com What I found out is that using a lot of include_once, require_once + session will trigger the CPU and memory spike. Add database access to the script can speed up the frequency of the spike. And I also found out require_once DO leak memory. pstat -T show that file in use will always increase. Somehow require_once forgot to close the file after use. lsof can give you a clear picture when you use require_once() I changed my code using cookie and require() statement now. And I delete all sess_files in /tmp seems to correct the problem. This is the only change I made to eliminate the problem. I can't reproduce the error now because the code that have problems have been changed and I don't have the backup. But the combination of A lot of include_once, require_once, and session will trigger the spike, I am pretty sure because after I changed all that, the problem disappear. Old session file in /tmp also contribute to the problem as well. BTW, the last time I checked, CVS version 4.06 in late April still have the problem. --------------------------------------------------------------------------- [2001-05-08 19:26:01] zeev@php.net Is this fairly reproducible? If it is, any chance you could build Apache with debug information (--enable-debug in configure), attach to an offending process (gdb /path/to/httpd <PID>), and run a backtrace ('bt')? --------------------------------------------------------------------------- [2001-05-07 12:44:51] derick@php.net marking critical for php 4.0.6 --------------------------------------------------------------------------- [2001-04-14 09:00:57] goten@mylaptop.com I found the problem. since the script I use have a lot of include and require statement. just a script include a bunch of files and keep reloading the page will kill the server in no time. I attach a sample config file I usually include, just make a test.php and include this file like 10 times to simulate a lot of include files. And then, just keep reloading test.php. You should see the script take a lot of CPU time and eventually the httpd eat all the CPU time and the process hang. From command "top", one of the httpd process keep eating up CPU time. The following is the sample config file <? /*Root directory */ $config[root_path] = "/usr2/home/business/test/www"; $config[w3b_path] = "/usr2/home/business/test/www/wwwthreads"; $config[data_path] = "/usr2/home/business/test/data"; $config[rdf_path] = "/usr2/home/business/test/www/rdf"; /* database */ include $config[root_path]."/db.php"; /* global */ $config[sitename] = "www.test.net"; $config[root_url] = "http://www.test.net/"; // Cookie Setting $config[cookie_path] = "/"; # web root directory $config[CookieURL] = ".test.net"; $config[cookieTTL] = 7200; // in seconds $config[minpass] = 3; # Minimum user password length in characters /* language and locale */ $config[language] = "english"; # [english] english, [big5] BIG5 code $config[locale] = "english"; # Used for translation of date-related stuff /* story control */ $config[commentmax] = 4096; $config[abstractlen] = 4996; #length of abstract show on first page $config[icon_width] = 100; # Topic icons width $config[timezone] = "HKT"; #Time zone $config[limitnews] = 10; # default number of stories per page $config[older_story_num] = 10; # number of older stories to display $config[anon_users] = 0; # 1 to allow anonymous postings # 0 to disable /* theme control */ $config[def_theme] = "Main"; # name of default theme (see themes/ directory for list) /* mail settings */ $config[use_fake_email] = 1; # Displays fake email addresses for users instead of the real ones $config[notifyEmail] = "webmaster@test.net"; #address where you want to receive notice //$config[CensorList] = array('fuck','cunt','fucker','fucking','pussy','cock','c0ck','cum','bitch','shit'); $config[CensorList] = array("/fuck/s","/fuck/s","/fuck/s", "/[a-z]*fuck[a-z]*/is", "/[a-z]*cunt[a-z]*/is", "/[a-z]*pussy[a-z]*/is", "/[a-z]*cock[a-z]*/is", "/[a-z]*c0ck[a-z]*/is", "/[a-z]*shit[a-z]*/is", "/[a-z]*bitch[a-z]*/is", "/[a-z]*diu[a-z]*/is" ); # See also specific LOCALE definitions $config[CensorMode] = 3; # 0: no filtering # 1: exact match # 2: match word beginnings # 3: match string anywhere in words $config[CensorReplace] = "[CENSORED]" ; /* allowable HTML tags. Used by check_html() Happily lifted (with mods) from phpslash */ $config[AllowableHTML] = array("p"=>1, # 2 means accept all qualifiers: <foo bar> "b"=>1, # 1 means accept the tag only: <foo> "i"=>1, "a"=>2, "em"=>1, "br"=>1, "strong"=>1, "blockquote"=>1, "img"=>2, "tt"=>1, "hr"=>1, "li"=>1, "ol"=>1, "div"=>1, "ul"=>1); $config[AllowableHTMLtag] = "<b>,<i>,<a>,<em>,<br>,<strong>,<blockquote>,<tt>,<hr>,<li>,<ol>,<div>,<ul>"; /* poll settings */ $config[maxOptions] = 12; # maximal number of options allowed $config[BarScale] = 1; # scale of result bar (in multiples of 100 pixels) $config[warnCheaters] = 1; # 1 - a notice issued on vote second try # 0 - silently ignores the vote $config[maxOptions] = 10; /* story stuff */ $reasons = array('As is', # "Normal" 'Offtopic', # Bad Responses 'Flamebait', 'Troll', 'Redundant', 'Insightful', # Good Responses 'Interesting', 'Informative', 'Funny', 'Overrated', # Last two are "special" 'Underrated'); if ($config[dateString] == "") { switch ($config[locale]) { // specifier specs can be found on http://www.php.net/manual/function.strftime.php /menthos case "english": $config[dateString] = "%a, %b %d,%Y @ %I:%M %p"; break; case "french": $config[dateString] = "%a %d %B %Y &agrave; %H:%M"; break; case "german": $config[dateString] = "%a, %d. %b %Y %H:%M"; break; case "italian": $config[dateString] = "%a %d %b %Y %H:%M"; break; case "swedish": $config[dateString] = "%a %d %b %Y, %H:%M"; break; case "dutch": $config[dateString] = "%a, %d. %b %Y %H:%M"; break; case "spanish": $config[dateString] = "%a %d %b %Y %H:%M"; break; default: $config[dateString] = "%a %b %d @ %H:%M"; break; } } ?> --------------------------------------------------------------------------- The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online. ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=10299&edit=2

« previous php.dev (#55948) next »