X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-workers-bounces using -f Message-ID: <3C89BC4E.C2517F4A@yahoo.com> Date: Sat, 09 Mar 2002 02:39:59 -0500 From: CBFalconer Organization: Ched Research X-Mailer: Mozilla 4.75 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: djgpp-workers AT delorie DOT com Subject: Re: Malloc/free DJGPP code References: <3C895AC1 DOT C4E06221 AT yahoo DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Reply-To: djgpp-workers AT delorie DOT com CBFalconer wrote: > ... snip ... > > The last test I threw at it was 2000 allocations through the Here are further results from a profile run in which 400,000 items were inserted and freed. The run would not have been possible under the old malloc, it would still be freeing things! These are all run on my 486DX2/80 [1] c:\c\hashlib>timerun hshtestp 4 400000 Timer 3 on: 1:40:08 HASHLIB test04 New table, inserting 400000 values Status: Entries=399979, Deleted=0, Probes=1861507, Misses=1003401 Walking returned 0 0 items were inserted 0 times 399958 items were inserted 1 times 21 items were inserted 2 times 0 items were inserted 3 times 0 items were inserted 4 times 0 items were inserted 5 times 0 items were inserted 6 times 0 items were inserted 7 times 0 items were inserted 8 times 0 items were inserted 9 or more times Timer 3 off: 1:40:51 Elapsed: 0:00:42.90 NOTE: The corresponding times for VC6 release/debug versions are about 22 and 64 seconds. The djgpp stuff was all compiled with -gstabs+ -O2. LCCWIN32 has the same limitations as the original DJGPP malloc package on free. Reruns of hshtestp seem to cut the time down to about 30 secs, and 19 when freeing is disabled. I suspect the presence of disk caches. [1] c:\c\hashlib>gprof -b hshtestp.exe >prof.txt ---------- prof.txt ----------- > Flat profile: > > Each sample counts as 0.0555556 seconds. > % cumulative self self total > time seconds seconds calls ns/call ns/call name > 17.83 6.11 6.11 inserted > 10.21 9.61 3.50 400034 8749.26 8749.26 split > 9.08 12.72 3.11 mcount > 8.75 15.72 3.00 putintbl > 7.94 18.44 2.72 400048 6804.74 6804.74 searchfree > 6.32 20.61 2.17 t1cmp > 4.54 22.17 1.56 399997 3888.92 10485.21 dofree > 4.54 23.72 1.56 399965 3889.23 3889.23 extractfree > 4.05 25.11 1.39 399997 3472.25 13957.46 free > 3.89 26.44 1.33 t1dupe > 3.57 27.67 1.22 400048 3055.19 18957.04 malloc > 2.59 28.56 0.89 getcounts > 2.11 29.28 0.72 452440 1596.28 1596.50 mv2freelist > 2.11 30.00 0.72 t1hash > 1.46 30.50 0.50 dotest4 > 1.46 31.00 0.50 maketbl > 1.30 31.44 0.44 199902 2223.31 6112.23 combinehi > 1.30 31.89 0.44 __dpmi_int > 1.30 32.33 0.44 hshinsert > 0.97 32.67 0.33 __brk > 0.97 33.00 0.33 randomMT > 0.81 33.28 0.28 hshwalk > 0.65 33.50 0.22 reloadMT > 0.65 33.72 0.22 t1undupe > 0.49 33.89 0.17 t1rehash > 0.32 34.00 0.11 reorganize > 0.16 34.06 0.06 13487 4119.19 4119.43 extendsbrk > 0.16 34.11 0.06 _doprnt > 0.16 34.17 0.06 hshkill > 0.16 34.22 0.06 uclock > 0.08 34.25 0.03 __exit > 0.08 34.28 0.03 __sbrk > > Call graph > > > granularity: each sample hit covers 4 byte(s) for 0.18% of 31.17 seconds > > index % time self children called name > > [1] 28.6 1.33 7.58 t1dupe [1] > 1.22 6.36 399979/400048 malloc [2] > ----------------------------------------------- > 0.00 0.00 1/400048 __crt0_load_environment_file [38] > 0.00 0.00 1/400048 atexit [40] > 0.00 0.00 1/400048 _flsbuf [39] > 0.00 0.00 1/400048 hshinit [41] > 0.00 0.00 2/400048 calloc [37] > 0.00 0.00 2/400048 __glob [36] > 0.00 0.00 4/400048 add [35] > 0.00 0.00 7/400048 c1xmalloc [34] > 0.00 0.00 9/400048 __putenv [33] > 0.00 0.00 13/400048 maketbl [16] > 0.00 0.00 28/400048 setup_environment [32] > 1.22 6.36 399979/400048 t1dupe [1] > [2] 24.3 1.22 6.36 400048 malloc [2] > 3.50 0.00 400034/400034 split [7] > 2.72 0.00 400048/400048 searchfree [9] > 0.08 0.00 52441/452440 mv2freelist [14] > 0.06 0.00 13487/13487 extendsbrk [27] > ----------------------------------------------- > > [3] 19.6 6.11 0.00 inserted [3] > ----------------------------------------------- > > [4] 18.6 0.22 5.58 t1undupe [4] > 1.39 4.19 399979/399997 free [5] > ----------------------------------------------- > 0.00 0.00 1/399997 __putenv [33] > 0.00 0.00 1/399997 __crt0_load_environment_file [38] > 0.00 0.00 1/399997 __crt1_startup [42] > 0.00 0.00 1/399997 hshkill [26] > 0.00 0.00 2/399997 __glob [36] > 0.00 0.00 12/399997 reorganize [25] > 1.39 4.19 399979/399997 t1undupe [4] > [5] 17.9 1.39 4.19 399997 free [5] > 1.56 2.64 399997/399997 dofree [6] > ----------------------------------------------- > 1.56 2.64 399997/399997 free [5] > [6] 13.5 1.56 2.64 399997 dofree [6] > 0.44 0.78 199886/199902 combinehi [12] > 0.78 0.00 200079/399965 extractfree [11] > 0.64 0.00 399997/452440 mv2freelist [14] > ----------------------------------------------- > 3.50 0.00 400034/400034 malloc [2] > [7] 11.2 3.50 0.00 400034 split [7] > ----------------------------------------------- > > [8] 9.6 3.00 0.00 putintbl [8] > ----------------------------------------------- > 2.72 0.00 400048/400048 malloc [2] > [9] 8.7 2.72 0.00 400048 searchfree [9] > ----------------------------------------------- > > [10] 7.0 2.17 0.00 t1cmp [10] > ----------------------------------------------- > 0.78 0.00 199886/399965 combinehi [12] > 0.78 0.00 200079/399965 dofree [6] > [11] 5.0 1.56 0.00 399965 extractfree [11] > ----------------------------------------------- > 0.00 0.00 16/199902 mv2freelist [14] > 0.44 0.78 199886/199902 dofree [6] > [12] 3.9 0.44 0.78 199902 combinehi [12] > 0.78 0.00 199886/399965 extractfree [11] > ----------------------------------------------- > > [13] 2.9 0.89 0.00 getcounts [13] > ----------------------------------------------- > 0.00 0.00 2/452440 extendsbrk [27] > 0.08 0.00 52441/452440 malloc [2] > 0.64 0.00 399997/452440 dofree [6] > [14] 2.3 0.72 0.00 452440 mv2freelist [14] > 0.00 0.00 16/199902 combinehi [12] > ----------------------------------------------- > > [15] 2.3 0.72 0.00 t1hash [15] > ----------------------------------------------- > > [16] 1.6 0.50 0.00 maketbl [16] > 0.00 0.00 13/400048 malloc [2] > ----------------------------------------------- > > [17] 1.6 0.50 0.00 dotest4 [17] > ----------------------------------------------- > > [18] 1.4 0.44 0.00 __dpmi_int [18] > ----------------------------------------------- > > [19] 1.4 0.44 0.00 hshinsert [19] > ----------------------------------------------- > > [20] 1.1 0.33 0.00 __brk [20] > ----------------------------------------------- > > [21] 1.1 0.33 0.00 randomMT [21] > ----------------------------------------------- > > [22] 0.9 0.28 0.00 hshwalk [22] > ----------------------------------------------- > > [23] 0.7 0.22 0.00 reloadMT [23] > ----------------------------------------------- > > [24] 0.5 0.17 0.00 t1rehash [24] > ----------------------------------------------- > > [25] 0.4 0.11 0.00 reorganize [25] > 0.00 0.00 12/399997 free [5] > ----------------------------------------------- > > [26] 0.2 0.06 0.00 hshkill [26] > 0.00 0.00 1/399997 free [5] > ----------------------------------------------- > 0.06 0.00 13487/13487 malloc [2] > [27] 0.2 0.06 0.00 13487 extendsbrk [27] > 0.00 0.00 2/452440 mv2freelist [14] > ----------------------------------------------- > > [28] 0.2 0.06 0.00 _doprnt [28] > ----------------------------------------------- > > [29] 0.2 0.06 0.00 uclock [29] > ----------------------------------------------- > > [30] 0.1 0.03 0.00 __exit [30] > ----------------------------------------------- > > [31] 0.1 0.03 0.00 __sbrk [31] > ----------------------------------------------- > > [32] 0.0 0.00 0.00 setup_environment [32] > 0.00 0.00 28/400048 malloc [2] > ----------------------------------------------- > > [33] 0.0 0.00 0.00 __putenv [33] > 0.00 0.00 9/400048 malloc [2] > 0.00 0.00 1/399997 free [5] > ----------------------------------------------- > > [34] 0.0 0.00 0.00 c1xmalloc [34] > 0.00 0.00 7/400048 malloc [2] > ----------------------------------------------- > > [35] 0.0 0.00 0.00 add [35] > 0.00 0.00 4/400048 malloc [2] > ----------------------------------------------- > > [36] 0.0 0.00 0.00 __glob [36] > 0.00 0.00 2/400048 malloc [2] > 0.00 0.00 2/399997 free [5] > ----------------------------------------------- > > [37] 0.0 0.00 0.00 calloc [37] > 0.00 0.00 2/400048 malloc [2] > ----------------------------------------------- > > [38] 0.0 0.00 0.00 __crt0_load_environment_file [38] > 0.00 0.00 1/400048 malloc [2] > 0.00 0.00 1/399997 free [5] > ----------------------------------------------- > > [39] 0.0 0.00 0.00 _flsbuf [39] > 0.00 0.00 1/400048 malloc [2] > ----------------------------------------------- > > [40] 0.0 0.00 0.00 atexit [40] > 0.00 0.00 1/400048 malloc [2] > ----------------------------------------------- > > [41] 0.0 0.00 0.00 hshinit [41] > 0.00 0.00 1/400048 malloc [2] > ----------------------------------------------- > > [42] 0.0 0.00 0.00 __crt1_startup [42] > 0.00 0.00 1/399997 free [5] > ----------------------------------------------- > > Index by function name > > [20] __brk [13] getcounts [23] reloadMT (cokusmt.c) > [18] __dpmi_int [19] hshinsert [25] reorganize (hashlib.c) > [30] __exit [26] hshkill [9] searchfree (nmalloc.c) > [31] __sbrk [22] hshwalk [7] split (nmalloc.c) > [28] _doprnt [3] inserted (hashlib.c) [10] t1cmp > [12] combinehi (nmalloc.c) [16] maketbl (hashlib.c) [1] t1dupe > [6] dofree (nmalloc.c) [2] malloc [15] t1hash > [17] dotest4 (236) mcount [24] t1rehash > [27] extendsbrk (nmalloc.c) [14] mv2freelist (nmalloc.c) [4] t1undupe > [11] extractfree (nmalloc.c) [8] putintbl (hashlib.c) [29] uclock > [5] free [21] randomMT Now lets see what others can find wrong with it! -- Chuck F (cbfalconer AT yahoo DOT com) (cbfalconer AT XXXXworldnet DOT att DOT net) Available for consulting/temporary embedded and systems. (Remove "XXXX" from reply address. yahoo works unmodified) mailto:uce AT ftc DOT gov (for spambots to harvest)