one suggestion for improving the performance of gc and memroy management

zsxxsz zhengshuxin at hexun.com
Mon Dec 21 17:56:37 PST 2009


Some days before, someone talked about the D's performance in multicore
system. dsimcha gave one suggestion that in gc using spinlock maybe better
than mutexlock. I have another idea about the gc and memroy management: each
thread use it's own memory slice pool with using thread local storage, which
can avoiding the global lock on system memory management. In the same thread,
if some object alloc and free some memory in its own memory slice pool, no
lock will be used; If one object allocated in one thread, but be used and
freed in the other thread, the using object thread should push the object to
its owner thread, and the owner thread use timer-like method to free the
object to its memory slice pool, in this process, the owner thread's memory
slice pool lock should be used(but it's some little situation that one object
allocated in one thread and freed in another thread).
In my webserver written with C, it got the great performance improvement in
multicore system. The webserver is a noblock server, one thread can handle
above 1000 concurrent connections. Before using the thread local storage
memory slice pool, when I start one thread, I get 10000 requests/second, but
if I start two threads, I get 8000 requests/second; After using thread local
storage memory slice pool, when starting one thread, I get 10000
requests/second, if starting two threads, I get 20000 requests/second. OK,
that's real great in practice programming.



More information about the Digitalmars-d mailing list