[music-dsp] [ANN] rollendurchmesserzeitsammler v0.0.5

Kjetil S. Matheussen k.s.matheussen at notam02.no
Wed Jul 30 07:33:56 EDT 2008


The Audio Rollendurchmesserzeitsammler is a conservative garbage
collector especially made for running inside an audio DSP thread.

New about this release is that I have finally replaced TLSF
(http://rtportal.upv.es/rtmalloc/) with a pool-based dynamic
memory allocator, which makes allocation using the
rollendurchmesserzeitsammler approximately as fast as
using custom memory pools.

Using the rollendurchmesserzeitsammler
should be a lot more convenient than memory pools though, and
since memory is not freed manually, but instead
is automatically freed in a separate lower-priority thread,
there is a slight chance that using rollendurchmesserzeitsammler
instead of custom memory pools could make some DSP code run
faster.

In non-synthetic benchmarks, I have not been able to see any
significant improvement in CPU use because of this compared to
using the TLSF allocator. But for programs doing 
millions of allocations per second, the new memory allocator
will probably perform significantly better than TLSF, if it
would ever make sense doing so many and frequent allocations
of course...


Download source from http://www.notam02.no/arkiv/src/?M=D


Changes 0.0.4 -> 0.0.5
* Implemented a custom pool-based dynamic memory allocater. This new
   memory allocator is now set as default. To use TLSF instead, set
   "USE_TLSF=-DUSE_TLSF" in the Makefile before compiling. The following
   changes are caused by this switch:
* Allocating memory is now approx 10 times faster (13 vs. 168
   instructions for the allocation itself, but there are some GC
   overhead too)
* The allocator copies used memory only (not just the whole heap).
   But not always! This was a lot more complicated to to with TLSF
   so I didn't do that. Note that for the garbage collector to still
   be hard realtime safe, the programs must ensure that full copies
   are taken now and then. (There's a change in the API for doing that)
* Doing a garbage collection is much faster since the heaps are usually
   much smaller (because only used memory is copied) and that freeing
   is 10-20 times faster.
* Further improvements for reducing memory overhead and make
   searching for used mem to be O(log n) instead of O(n) is
   much simpler now. (this is TODO though)
* However 1: In case the code using the garbage collector will
   continue forever to allocate memory of different sizes, the
   new dynamic memory allocator could eventually run out of memory
   even if the program itself doesn't use very much memory.
   I don't think this is very likely to happen for DSP routines though,
   and there might even be solutions to fix this problem if it should
   ever come up. For now, just switching to TLSF fixes the problem.
* However 2: in non-synthetic benchmarks, I have not been able to see any
   practical improvement in CPU use, apart from the slight improvement
   in CPU available for use in non-realtime threads because taking
   snapshots usually takes a lot less time now. But for programs doing
   millions of allocations per second, the new memory allocator will
   probably perform significantly better than TLSF, if it would ever
   make sense doing so many allocations of course.



More information about the music-dsp mailing list