Mail Archives: djgpp/2002/02/11/18:45:14
Eli Zaretskii wrote:
>
> > From: CBFalconer <cbfalconer AT yahoo DOT com>
> > Newsgroups: comp.os.msdos.djgpp
> > Date: Mon, 11 Feb 2002 15:10:03 GMT
> >
> > Flat profile:
> >
> > Each sample counts as 0.0555556 seconds.
> > % cumulative self self total
> > time seconds seconds calls ns/call ns/call name
> > 82.04 9.39 9.39 30001 312952.53 314921.80 merge
> [...]
> > which puts the problem (going by name) precisely where it was
> > expected.
>
> Yep, pretty much so. It had to be merge.
>
> > I still don't know how you are organizing the free list,
>
> In a nutshell, they are kept in linked lists arranged in buckets by
> block sizes, each sublist for a size that is a different power of 2.
>
> Try stepping through malloc and free for several allocations and
> deallocations of vastly different sizes, and I think you will see the
> pattern clearly.
>
> > If something identifies such blocks as being free or not, independant
> > of the free list, this could be made linear.
>
> You will see in the code that the LSB of the size/next pointer header
> is used as the allocated/free marker.
>
> > This implies that
> > all blocks contain fields for next, size, and one bit for flags.
>
> Yes, there's a header and a trailer, each one 4-byte long. See teh
> definition of struct BLOCK.
What defines the sizes for which you keep separate lists? I hate
reading OPs source :-) at least without a clear statement of
algorithms.
BTW, your messages are suddenly supporting references and getting
threaded properly! Did you change newsreaders?
- Raw text -