X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f X-Recipient: djgpp-workers AT delorie DOT com Message-ID: <47571B5D.5090305@iki.fi> Date: Wed, 05 Dec 2007 23:42:53 +0200 From: Andris Pavenis User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: djgpp-workers AT delorie DOT com Subject: gcc-4.3. snapshots and DJGPP memory allocator efficiency Content-Type: multipart/mixed; boundary="------------020801090205030302060307" Reply-To: djgpp-workers AT delorie DOT com This is a multi-part message in MIME format. --------------020801090205030302060307 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit There seem to be serious performance problems in GCC-4.3 for DJGPP due to slowness of free() call especially for Ada compiler. Tried to bootstrap gcc-4.3-20071130 for DJGPP (after reverting some earlier changes in libiberty/configure.ac present in snapshot). Initially thought that compiler (gnat1.exe) has went into some infinite loop when compiling gcc/ada/ali.adb for stage2. Found that extremly long time is being spent in libibrty/hashtab.c in procedure htab_delete() which in that case uses free() to release several millions allocated memory block. htab_delete() took perhaps about 30 minutes on Intel Core 2 Quad 2.4GHz processor (I did not measure accuratelly). There is of course not much use of 4 processor cores as DJGPP cannot use them all. Currently I see that perhaps the same thing happens (I haven't verified with debugger) when compiling gcc/ada/g-catiio.adb (killed after about 60 minutes, I don't know how much it will still would require) Wrote simple test (see attachment). I'm getting from this test on mostly idle machine (cannot get rid of WinXP though): for s in 50000 100000 150000 200000 250000; do ./memalloctest $s; done 50000 0.055 0.000 0.440 100000 0.000 0.000 1.978 150000 0.055 0.000 5.055 200000 0.055 0.000 18.626 250000 0.055 0.000 41.868 So one can imagine what we'll get if the number will be some millions... Andris --------------020801090205030302060307 Content-Type: text/plain; name="memalloctest.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="memalloctest.cpp" #include #include #include #include #include double GetTime(void) { return ((double)clock()) / CLOCKS_PER_SEC; } void test(int size) { unsigned x0 = time(NULL) | 1; unsigned char **foo = new unsigned char* [size]; double t1 = GetTime(); for (int i = 0; i < size; i++) { x0 = x0 * 65559; foo[i] = new unsigned char [8+x0%64]; } double t2 = GetTime(); std::random_shuffle(foo, foo+size); double t3 = GetTime(); for (int i = 0; i < size; i++) delete [] (foo[i]); double t4 = GetTime(); printf("%8d %8.3f %8.3f %8.3f \n", size, t2-t1, t3-t2, t4-t3); delete [] foo; } int main(int argc, char **argv) { assert(argc == 2); int size = atoi(argv[1]); assert(size > 0); test(size); return 0; } --------------020801090205030302060307--