Re: Bug #10299 Updated: CPU and Memory Spike

From: Date: Wed, 09 May 2001 01:26:46 +0000
Subject: Re: Bug #10299 Updated: CPU and Memory Spike
Groups: php.dev 
Request: Send a blank email to php-dev+get-54456@lists.php.net to get a copy of this message
Just a note, I'm not reporting the same but I have seen something that sounds kinda similar. While developing an external module that used resources, I found that I could get PHP into an infinite loop in the memory cleanup routine by improperly releasing a resource (by just freeing the resource structure, and not doing a zend_list_remove) and then letting the resource be removed again on script exit. I was able to duplicate it quite easily and traced it in a debugger and found a linked list pointed to itself causing an infinite loop. To cause this required both an extension programming bug, and a certain script to activate it. It might be releated... Brian On 8 May 2001 23:26:01 -0000, zeev@php.net wrote: >ID: 10299 >Updated by: zeev >Reported By: goten@mylaptop.com >Status: Critical >Bug Type: Performance problem >Operating system: >PHP Version: 4.0.4pl1 >Assigned To: >Comments: > >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')? > > >Previous Comments: >--------------------------------------------------------------------------- > >[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; > } >} > >?> > >--------------------------------------------------------------------------- > >[2001-04-14 07:59:05] goten@mylaptop.com >This is vmstat show if I keep reloading the script > >procs memory page disks faults cpu > r b w avm fre flt re pi po fr sr da0 da1 in sy cs us sy id > 1 4 0 73860 13432 4 0 0 0 0 0 2 0 382 3804 258 16 1 83 > 0 4 0 73860 13424 4 0 0 0 0 0 0 0 357 3789 245 15 4 81 > 1 4 0 73860 13424 4 0 0 0 0 0 0 0 373 3763 263 14 3 83 > 2 4 0 73860 13416 142 0 0 0 139 0 0 0 402 6155 285 26 4 70 > 0 4 0 73860 13408 4 0 0 0 4 0 11 0 366 3179 220 11 2 87 > 1 4 0 73860 13400 4 0 0 0 0 0 0 0 358 3943 257 15 3 82 > 2 4 0 73860 13400 4 0 0 0 0 0 0 0 340 4201 240 12 42 45 > 2 4 0 73860 13400 4 0 0 0 0 0 0 0 240 1842 90 0 100 0 > 2 4 0 73116 13400 4 0 0 0 0 0 19 0 265 1802 98 0 100 0 > 2 4 0 73116 13400 4 0 0 0 0 0 0 0 241 1753 93 0 100 0 > 2 4 0 73116 13400 4 0 0 0 0 0 0 0 239 1729 96 0 100 0 > 2 4 0 73116 13400 4 0 0 0 0 0 0 0 241 1612 94 0 100 0 > 2 4 0 73116 13400 4 0 0 0 0 0 0 0 243 1576 97 0 100 0 > 2 4 0 73116 13400 4 0 0 0 0 0 0 0 243 1541 98 0 100 0 > 2 4 0 73116 13400 4 0 0 0 0 0 0 0 239 1487 102 0 100 0 > 2 4 0 73116 13400 4 0 0 0 0 0 0 0 241 1401 93 0 100 0 > 2 4 0 73116 13400 4 0 0 0 0 0 0 0 251 1405 100 0 100 0 > 2 4 0 73116 13400 4 0 0 0 0 0 0 0 246 1338 101 0 100 0 > 2 4 0 73116 13400 4 0 0 0 0 0 0 0 238 1297 94 0 100 0 > 2 4 0 73860 13400 4 0 0 0 0 0 0 2 243 1282 100 0 100 0 > 2 4 0 73860 13400 4 0 0 0 0 0 0 0 239 1223 89 0 100 0 > 2 4 0 73860 13400 4 0 0 0 2 0 9 16 300 1180 92 0 100 0 > procs memory page disks faults cpu > r b w avm fre flt re pi po fr sr da0 da1 in sy cs us sy id > 3 4 0 73860 13400 4 0 0 0 0 0 0 0 251 1156 90 0 100 0 > 3 4 0 50296 13400 4 0 0 0 0 0 6 0 258 1116 93 0 100 0 > 2 4 0 50296 13400 4 0 0 0 0 0 0 0 240 1108 83 0 100 0 > 3 4 0 50296 13400 4 0 0 0 0 0 0 0 245 1064 92 0 100 0 > 3 4 0 46988 13400 4 0 0 0 0 0 0 0 242 1031 83 0 100 0 > 3 4 0 46988 13400 4 0 0 0 0 0 0 0 242 989 82 0 100 0 > 2 4 0 46988 13400 4 0 0 0 0 0 0 0 243 1010 85 0 100 0 > 2 4 0 46988 13400 4 0 0 0 0 0 1 0 241 985 81 0 100 0 > 2 4 0 46988 13400 4 0 0 0 0 0 0 0 241 971 89 1 99 0 > 2 4 0 46988 13400 4 0 0 0 0 0 0 0 243 940 74 0 100 0 > 3 4 0 46988 13400 4 0 0 0 2 0 8 0 250 926 80 0 100 0 > 2 4 0 46988 13400 4 0 0 0 0 0 1 0 245 930 88 0 100 0 > 3 4 0 46988 13400 4 0 0 0 0 0 0 0 240 905 80 0 100 0 > 2 4 0 46988 13400 4 0 0 0 0 0 7 0 253 920 100 0 98 2 > 3 4 0 47332 13056 90 0 0 0 0 0 0 0 239 2113 116 3 97 0 > 2 4 0 46588 13048 4 0 0 0 0 0 1 0 243 2334 103 1 99 0 > 1 4 0 46244 13392 4 0 0 0 86 0 8 0 276 4383 140 7 19 74 > 1 4 0 47896 13184 59 0 0 0 0 0 2 0 275 621 56 7 1 92 > 0 4 0 47896 13152 20 0 0 0 0 0 1 0 253 471 46 6 1 93 > 1 4 0 47492 13372 18 0 0 0 64 0 0 0 251 478 43 0 1 99 > 0 4 0 47492 13372 4 0 0 0 0 0 0 0 235 440 40 0 0 100 > 0 4 0 47492 13372 4 0 0 0 0 0 0 0 238 442 40 0 2 98 > >The CPU time drop from 80 all the way to zero and make the Apache hang for like 30 seconds and >the resume back again. It happens VERY often if I only have like 30 users surf the website at the same time. It pretty much bring the web server down if I have around 50 users surft the site > >--------------------------------------------------------------------------- > >[2001-04-11 18:03:59] goten@mylaptop.com >I am running on FreeBSD 4.2 Stable, Apache 1.3.19 + PHP 4.0.4pl1 + Modssl on a Dual P2 400mhz >with 256mb ram. From time to time, one of the httpd process will eat up all the CPU time and memory, and after around 5 to 10 seconds, it goes back to normal Even a Very simple script like > ><? >echo "test"; >?> > >can make it happen. 1 out of 25 reload of the above script can make the spike happen. But the >web server do not crash though. If I run on a script with heavy database access, it happen 1 out of 10 if I press reload button continously. > >BTW, is that normal for Apache to take up 30% of the CPU time to excute one single >PHP-database-driven page? > >I search the bugs database and I found another user have the exact problem like what I am having >right now. His bug id is #9154. > >This is how I configure PHP >./configure --with-mysql=/usr/local/mysql --with-apxs=/usr/local/apache/bin/apxs >--with-config-file- path=/usr/local/etc --enable-track-vars --enable-ftp --with-gd=/usr/local --with-pcre-regex=/usr/local/ >--with-jpeg-dir=/usr/local --with-xpm-dir=/usr/X11R6 > >With or Without modssl enable does not make a difference. Both can cause the spike. > >--------------------------------------------------------------------------- > >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 > > >-- >PHP Development Mailing List <http://www.php.net/> >To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net >For additional commands, e-mail: php-dev-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.dev (#54456) next »