Friday, 15 April 2011

performance - Why the speed of a Java process inside multiple loops slows down as it goes? -



performance - Why the speed of a Java process inside multiple loops slows down as it goes? -

i'm using win 7, java 8, on multicore intel workstation. have :

int sampleweeksarray[]=new int[]{23,25,33},idarray[]=new int[]{0,1,2}; (int startday=25;startday<36;startday++) (int sampleweeks : sampleweeksarray) (int id : idarray) (float valuefactor=0.08f;valuefactor<0.13f;valuefactor+=0.01) { datadigester datadigester=new datadigester(); datadigester.startday=startday; datadigester.sampleweeks=sampleweeks; datadigester.id=id; datadigester.valuefactor=valuefactor; datadigester.dorun(); }

inside datadigester.dorun() reads in text info files, parse each line , statistics arrays, vectors , hashmaps , uses threadpoolexecutor run multiple processes, save results file.

the unusual thing each single run of dorun() takes 10 minutes, within loops, started 10 min. gradually slows downwards 20, 30 min. each dorun().

if stop loop when it's taking 30 min., start on stopped, 1 time again took 10 min. , slows downwards 20, 30 min. again. why ?

i set in next lines after dorun(), didn't improve speed, still slows downwards :

thread.sleep(20*1000); // rest 20 seconds system.gc();

inside each loop, datadigester datadigester=new datadigester() creates new object, should recycled after dorun(), why slowed downwards ?

i've noticed windows task manager, memory usage goes loops maintain going. seems java somehow burdens , slows down, in case how maintain speed @ constant of 10 min. each run within loops ?

it's hard without knowing datadigester , does, can think of number of possible reasons:

if datadigester.dorun starts new thread - number of threads goes up, time available per thread goes down. if utilizes hardware threads, time go 1 time go 1 2 threads per hardware thread.

datadigester may have static construction adds to, , grows slower , slower more add together it

java performance loops

No comments:

Post a Comment