Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Programming Threads > transforming si...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 4073 of 4146
Post > Topic >>

transforming single-threaded allocators...

by "Chris M. Thomasson" <no@[EMAIL PROTECTED] > Oct 7, 2008 at 09:32 PM

I have developed a non-blocking algorithm that allows one to transform an 
inherently single-threaded memory allocator into a scaleable
multi-threaded 
allocator. This invention allows a programmer to just create an allocator 
algorithm without worrying about any multi-threading issues. Once your
done 
with your single-threaded allocator, well, when you apply my non-blocking 
algorithm, and PRESTO! Its now a scaleable multi-threaded allocator! Is
that 
cool or what?

Okay, here is an initial proof of concept, I have transformed the Windows 
Heap object created with the HEAP_NO_SERIALIZE flag. This flag disables
the 
internal lock used by the heap, which makes it a heck of a lot more 
efficient. However, since the heap is no longer serialized, one cannot use

it in a multi-threaded application as a general allocator; until now...
The 
algorithm I created is fairly simple; basically, it goes like this:
___________________________________________________________________________
I create thread local user allocator in every thread.

Alloc request is forwarded to this thread-local user allocator directly.

If free request goes from thread that allocate block, then free request is

forwarded to this thread-local user allocator.

If free request goes from another thread, then you ac***ulate this block
in 
per-thread stack-based freelist.

Blocks from this freelist are actually freed in batches when thread 
allocates/deallocates another block.
___________________________________________________________________________




I mentioned this algorithm a while back:

http://groups.google.com/group/comp.programming.threads/browse_frm/thread/eb87f9cb2cb62d84


Well, I have released a pre-alpha version of it which demonstrates how to 
transform the Windows Heap object under GPL license; the example
source-code 
can be found here:

http://webpages.charter.net/appcore/vzoom/malloc/vzmalloc_win_v000_c.html


Can you please run the test as-is, which uses stock malloc impl, and
record 
the output... Then uncomment the following line:


#define USE_MEM_ALLOC


which engages my algorithm; run the test again; and post the differences
in 
timings between the two. I think you will be fairly surprised at the 
performance enhancement. The lock in the Windows Heap object that `malloc'

is based on severely damages its scalability when used in a multi-threaded

environment. When `USE_MEM_ALLOC' is defined, ALL of the locking is
removed 
and the heaps are created on a per-thread basis. This distribution and 
clever sup****t algorithm I invented allows for the Windows Heap to scale 
quite nicely indeed.

I am going to tweak the algorithm such that one could plug in different 
allocators on a per-thread basis! In other words, thread A can use a 
different allocation algorithm than thread B, and so on. My algorithm 
actually sup****ts this. I think the possibilities are truly amazing. It
even 
allows thread A to allocate and free in thread B even though they use 
completely different allocation algorithm. That's pretty darn cool. Some
may 
think its even impossible; its not!

BTW, I am thinking that this algorithm might be able to be used to
transform 
other single-threaded things besides allocators... Humm, need to think
some 
more on that.
 




 6 Posts in Topic:
transforming single-threaded allocators...
"Chris M. Thomasson&  2008-10-07 21:32:07 
Re: transforming single-threaded allocators...
"Chris M. Thomasson&  2008-10-07 21:36:24 
Re: transforming single-threaded allocators...
"Chris M. Thomasson&  2008-10-07 22:26:09 
Re: transforming single-threaded allocators...
"Chris M. Thomasson&  2008-10-07 22:30:07 
Re: transforming single-threaded allocators...
"Chris M. Thomasson&  2008-10-07 22:47:43 
Re: transforming single-threaded allocators...
"Chris M. Thomasson&  2008-10-08 02:44:19 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 9:09:48 CST 2008.