Re: C++ Memory Management Innovation: GC Allocator
On Apr 24, 3:43 pm, "Chris Thomasson" <cris...@comcast.net> wrote:
There are benefits for using TLS. Think of a simple contrived scenario like:
void function() {
// I need to allocate from m_alloc...
// How can I do this without adding any parameters?
}
void thread() {
GenericAllocator m_alloc;
function();
}
AFAICT, your allocator can use TLS as-is... Basically, something like:
void function() {
GenericAllocator* const pm_alloc = pthread_getspecific(...);
// Now I can allocate from m_alloc! :^D
}
void thread() {
GenericAllocator m_alloc;
pthread_setspecific(..., &m_alloc);
function();
}
Don't you think that your design could "possibly" benefit from using TLS?
IMVHO, it would increase its flexibility...
I'm happy to say that performance of TlsScopeAlloc is close to
ScopeAlloc. Here is one of my result:
===== AutoFreeAlloc(1) =====
Average: ---> Elapse 71284646 ticks (71.28 ms) (0.00 min) ...
===== APR Pools(1) =====
Average: ---> Elapse 77065368 ticks (77.07 ms) (0.00 min) ...
===== TlsScopeAlloc(1) =====
Average: ---> Elapse 21068489 ticks (21.07 ms) (0.00 min) ...
===== ScopeAlloc(1) =====
Average: ---> Elapse 14929159 ticks (14.93 ms) (0.00 min) ...
===== MtAllocator(1) =====
Average: ---> Elapse 65385419 ticks (65.39 ms) (0.00 min) ...
===== DLMalloc(1) =====
Average: ---> Elapse 181303561 ticks (181.30 ms) (0.00 min) ...
===== BoostPool(1) =====
Average: ---> Elapse 264567223 ticks (264.57 ms) (0.00 min) ...
===== BoostObjectPool(1) =====
Average: ---> Elapse 397389191 ticks (397.39 ms) (0.01 min) ...
===== NewDelete(1) =====
Average: ---> Elapse 59987942 ticks (59.99 ms) (0.00 min) ...
===== AutoFreeAlloc(1000) =====
Average: ---> Elapse 1134564 ticks (1.13 ms) (0.00 min) ...
===== APR Pools(1000) =====
Average: ---> Elapse 8465549 ticks (8.47 ms) (0.00 min) ...
===== TlsScopeAlloc(1000) =====
Average: ---> Elapse 2119220 ticks (2.12 ms) (0.00 min) ...
===== ScopeAlloc(1000) =====
Average: ---> Elapse 2117445 ticks (2.12 ms) (0.00 min) ...
===== MtAllocator(1000) =====
Average: ---> Elapse 70740550 ticks (70.74 ms) (0.00 min) ...
===== DLMalloc(1000) =====
Average: ---> Elapse 207583238 ticks (207.58 ms) (0.00 min) ...
===== BoostPool(1000) =====
Average: ---> Elapse 7135785 ticks (7.14 ms) (0.00 min) ...
===== BoostObjectPool(1000) =====
Average: ---> Elapse 10780571 ticks (10.78 ms) (0.00 min) ...
===== NewDelete(1000) =====
Average: ---> Elapse 63238984 ticks (63.24 ms) (0.00 min) ...
===== AutoFreeAlloc(1000000) =====
Average: ---> Elapse 2631304 ticks (2.63 ms) (0.00 min) ...
===== APR Pools(1000000) =====
Average: ---> Elapse 8787553 ticks (8.79 ms) (0.00 min) ...
===== TlsScopeAlloc(1000000) =====
Average: ---> Elapse 2193191 ticks (2.19 ms) (0.00 min) ...
===== ScopeAlloc(1000000) =====
Average: ---> Elapse 2149852 ticks (2.15 ms) (0.00 min) ...
===== MtAllocator(1000000) =====
Average: ---> Elapse 89697667 ticks (89.70 ms) (0.00 min) ...
===== DLMalloc(1000000) =====
Average: ---> Elapse 258619410 ticks (258.62 ms) (0.00 min) ...
===== BoostPool(1000000) =====
Average: ---> Elapse 9320836 ticks (9.32 ms) (0.00 min) ...
===== BoostObjectPool(1000000) =====
Average: ---> Elapse 12252103 ticks (12.25 ms) (0.00 min) ...
===== NewDelete(1000000) =====
Average: ---> Elapse 125101384 ticks (125.10 ms) (0.00 min) ...
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]