POV-Ray : Newsgroups : povray.off-topic : One thing which puzzles me about unix/linux : Re: One thing which puzzles me about unix/linux Server Time
1 Oct 2024 15:21:11 EDT (-0400)
  Re: One thing which puzzles me about unix/linux  
From: Warp
Date: 8 Apr 2008 14:55:49
Message: <47fbbfb5@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> >   Using a more efficient memory allocator can cause amazing speedups, as
> > I wrote on that page.

> That's one of the ways GC can be faster than manual memory management. 
> Many, many memory management libraries really suck bigtime, while a 
> tremendous amount of time is spent making GC fast.

  I don't see how GC would help that at all.

  The problem with the default allocator is that it has to be prepared to
allocate blocks of *any* size, and it should do it as memory-efficiently
as possible (ie. wasting as little memory as possible). This makes it
pretty complicated. It needs quite a lot of bookkeeping data, and keeping
track of free blocks of memory is rather complicated.
  This is even further complicated by the fact that the default memory
allocator must be thread-safe. This means that if two threads try to
allocate memory at the same time, the allocator must use mutual exclusion.
Mutual exclusion locks cause considerable overhead. In single-threaded
programs this overhead is useless, but there isn't an easy way around it.

  Why would GC help this? Even GC'd memory must be prepared to allocate
blocks of any size, and it must be thread-safe. I don't think GC would
help these problems.

  If I'm not completely mistaken, the major reasons why my allocator is
so much faster than the default allocator in libc is because it uses a
lot less bookkeeping data (because it only allocates blocks of fixed
size), the bookkeeping is much simpler and a lot faster to manage, and
my allocator is not thread-safe (which can be a big minus in some cases,
of course).

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.