Re: Can anyone explain PHP slowing down please ?



In article <xPxig.3721$sC.2396@xxxxxxxxxxxxxxxxxxxxx>,
david.haynes2@xxxxxxxxxxxx says...

A slow down of this magnitude typically points to some system-related
bottleneck rather than an algorithmic one. Have you checked the
processes' virtual memory use? I would suspect that you are starting to
swap around the 6,000th record.

If not, I would start to place finer-grained time information around the
major I/O points (fgetcsv, fwrite) to see if they are causing the slow down.

On a stylistic note, why do you use $x++ in some places and $x += 1 in
others? Also, the checkit function could use the trinary compare operator:

function checkit($star) {
exec('declination.exe '.$star, $aout, $returnval);
return ($aout[0][0] === 'Y');
}

and 'if( $checkit($star) == false ) {' could become
'if( ! $checkit($star) ) {'

However, I don't think any of these would contribute to your slow down
issue.

-david-


Thanks for the comments david - I've run this on both windows and linux
now and the linux system I ran through apache - I get the same results on
that too (very similar but not identical) (The linux box is entirely
different hardware) - I'll post timing differences later - they're
outrageous !!!

I've also run the windows version with apache too now and still get the
slowdown.

I've tried removing my call to the executable replacing it with a simple
return and it still slows down.

Looking at what you suggest - could it be that the fgetcsv command is
searching from the top of the file on every itteration?
I dont cause it to - but if thats how it works ?

I have discovered a windows loss of 2Mb of system memory for every run -
thats either a windows or PHP problem I dont know which - probably
windows and I dont think its connected to the slowdown.

If this isnt obvious to anyone I guess the only thingI can do is start
taking things out one by one starting with your suggestions.

On the memory side - no it all(suprisingly) seems to happen in ram - even
the test database file of 1 million records seems to go straight to ram.
There's no thrashing or anything (The win-98 system has 1Gb ram - the
linux system just 128Mb)

On the style front - Dave you wouldn't believe my working methods!
In my time I've used maybe 7 languages in anger and currently I use 3 or
4 so I'm in and out of them all the time - things get mixed up in my
head.
I always do a "comment" sweep when I'm done and tidy things up for this
very reason but sometimes I do use ++x and += 1 because it helps me
remember whats going on and what I need to keep an eye on. (I have a bad
short term memory problem) My "if" statements and other stuff follow the
same routine for the same reasons - there is method in my madness - you
just have to be mad too to see it...
This particular code has been messed about with quite badly too as I try
to find the problem.

I care more about function not fancy - most PHP style I've seen is
abysmal anyway - the standard style reccomended is appaling. I'm not a
fan of the way most people code - nor of the way many languages work for
that matter. Anything other than Forth is bad form in my book ;-)

As for the trinary operator - its a terrible construct for anyone who
doesn't use it regularly or anyone looking at someone elses code so I
avoid it.

tony



.



Relevant Pages

  • RE: service pack 2 and time errors
    ... > Windows firewall, that could explain your other issues as ... send the report i am informed that i dont have service pack 2 and should get ... i do know i need more memory so im not worried about them. ...
    (microsoft.public.windowsxp.general)
  • Re: Excluding Process from getting paged,...
    ... paged to the pagefile on a windows xp system? ... I dont want to disable the pagefile, ... If you have lots of available memory, then your process won't get paged ...
    (microsoft.public.win32.programmer.kernel)
  • Virtual Memory
    ... just let windows manage it. ... with 1 gig of memory u dont ... >Memeory Change set Initial Size and Maximum Size to 3000 ... >should say 4000 and when I go back to Virtual Memory ...
    (microsoft.public.windowsxp.customize)
  • Re: in C how to store a value on a given memory address
    ... but dont that on a NT based Windows ... reserved by OS and that it should be the part of memory segment where variable is stored.... ... Nowadays, I work with Embedded Linux running on an MPC885, and trust me, there is no way out of the 'Modules' running in kernel mode that makes the address translation. ...
    (comp.lang.c)
  • RE: Virtual memory
    ... You can configure virtual memory in windows xp and thereby improve the ... How to set performance options in Windows XP ... if you have background programs such as printing or disk ... It is also known as the paging file. ...
    (microsoft.public.windowsxp.perform_maintain)