Slow GC?

Vladimir Panteleev thecybershadow at gmail.com
Fri Mar 14 21:44:37 PDT 2008


On Sat, 15 Mar 2008 04:48:27 +0200, Walter Bright <newshound1 at digitalmars.com> wrote:

> Vladimir Panteleev wrote:
>> Good optimizations often require significant and complicated changes
>> to the code. Luckily this one doesn't :)
>
>
> What exactly does the patch do?

In gcx.mark(), it remembers the last pointer it examined that pointed to a B_PAGE or B_PAGEPLUS memory page. If the next value that looks like a pointer (is >=minAddr && <maxAddr) also points to the same memory page ((lastPointer & ~(PAGESIZE-1)) == (newPointer & ~(PAGESIZE-1))), it skips looking at it, thus skipping a call to findPool, looking up the page's bin size, and testing / setting the respective bits.

This greatly optimizes the GC for scanning areas that have consecutive pointers pointing to the same block of memory, e.g. slices of a bigger array. Note that I also changed "if (p >= minAddr)" to "if (p >= minAddr && p < maxAddr)" (which should also give a speed boost when scanning objects with static byte/ubyte/char arrays or floats).

-- 
Best regards,
 Vladimir                          mailto:thecybershadow at gmail.com



More information about the Digitalmars-d mailing list