- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I find that I can usee tbb memory allocator for my stl containers in 2 ways
- use malloc_proxy
- pass scallable_allocator with constructor
Does both give the same result? What I meant is instead of having to replace all my stl constructor's can I achieve the same with malloc_proxy? I need a per thread cache for my object memory allocations.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Jithin E. wrote:
Does both give the same result? What I meant is instead of having to replace all my stl constructor's can I achieve the same with malloc_proxy? I need a per thread cache for my object memory allocations.
Hello Jithin,
I general case it is enough. "general case" means that you do not use some custom allocator that calls system functions like VirtualAlloc() or mmap() directly.
--Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for clarifying. I tried both approaches and I found performance to be almost similar with malloc_proxy slightly better with multiple threads
But neither solves my broader problem of performance bottle neck with a multi threaded program where each thread create larges amount of objects. I am suspecting that per thread cache overflows for each thread and hence there is a contention at malloc level for each threads.
EDIT: Also how do I give te syntax for a vector of vectors. Eg: - std::vector <std::vector <const char *, tbb::scalable_allocator<const char *> > > x_; For the outer vector I am not able to give an allocator. like std::vector <std::vector <const char *, tbb::scalable_allocator<const char *> >, std::vector > x_; Gives an error on vector not being a type.
Vladimir Polin (Intel) wrote:
Quote:
Jithin E.wrote:Does both give the same result? What I meant is instead of having to replace all my stl constructor's can I achieve the same with malloc_proxy? I need a per thread cache for my object memory allocations.
Hello Jithin,
I general case it is enough. "general case" means that you do not use some custom allocator that calls system functions like VirtualAlloc() or mmap() directly.
--Vladimir
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you approximate the number of entries for the outer vector?
Generally it would be counter-productive to make the outer vector use a scalable allocator, you would be growing this to a size once. The internal vectors would make sense since these could get recycled (assuming the interior vectors are relatively small).
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
jimdempseyatthecove wrote:
Can you approximate the number of entries for the outer vector?
Generally it would be counter-productive to make the outer vector use a scalable allocator, you would be growing this to a size once. The internal vectors would make sense since these could get recycled (assuming the interior vectors are relatively small).Jim Dempsey
Internal vectors are not that small. Also in places where I am using scalable allocator for vectors the vector size is actually big (about 10000 object pointers) per thread.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page