Boost logo

Boost :

Subject: [boost] [pool] Thread specific pool allocator
From: James Bremner (ravenspoint_at_[hidden])
Date: 2009-09-12 12:01:31


I develop code to run on multiple processor machines. Moderate use of the
standard template library (STL) containers cause programs to slow down when
the work is split between threads running on different processors. This is
because the STL default memory allocator is a thread-safe singleton and
causes contention between the threads.

The memory allocator provided by boost::pool_allocator is also a thread safe
singleton.

I have coded a thread specific memory allocator based on boost::pool and
boost:thread_specific_pointer. My allocator creates a new instantiation for
each thread it is used in, and so avoids contention between threads. The
containers created with this allocator must be used carefully, not written
to by more than one thread, because the allocator is not thread-safe ( that
is the point! ) - however they provide dramatic performance improvements
when my code runs on multiple processors.

I do not expect my coding is to the high standard of the boost libraries,
but I do believe it shows that something very useful can be done with a few
lines of code. Any chance of a boost:thread_specific_pool_allocator in the
near future?

 James Bremner

      


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk