﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	resolution	keywords	cc	phab_field
2020	[PATCH] Memory Pool + Bucket Allocator	Jorma Rebane	Jorma Rebane	"This patch adds a custom high performance memory pool implementation to 0 A.D. In addition an STL-compatible custom allocator (bucket_allocator<T>) is included.

Adding memory pools will greatly improve the overall performance of 0 A.D. In order to make this convenient a wrapper header ""ps_stl.h"" is also included that wraps the STL containers with the custom bucket allocator.


The bucket allocator uses Thread-Local-Storage to create a collection of memory-pools. It is called a bucket allocator because all allocations are divided into sized 'buckets':
{{{
Buckets [0..24]		4 8 12 16 20 24 
Buckets [25..64]	32 40 48 56 64 
Buckets [65..128]	80 96 112 128 
Buckets [129..256]	160 192 224 256 
Buckets [257..1024]	384 512 640 768 896 1024
}}}

Names of the wrapped stl containers in ps_stl.h:
{{{
psvector<T>
pslist<T>
psbasic_string<T>
psstring
pswstring
psmap<Key, T>
psset<T>
psunordered_map<Key, T>
psunordered_set<T>
}}}


These are the performance comparisons from the patch test suite:
{{{
    >> DEBUG
    .std_alloc growshrink:     7081ms
    .std_alloc temporaries:    105ms
    .pool_alloc growshrink:    61ms
    .pool_alloc temporaries:   7ms
    .tls_bucket growshrink:    51ms
    .tls_bucket temporaries:   9ms
    .stress_test std::stl:     1245ms
    .stress_test ps::stl:      499ms
     
    >> RELEASE
    .std_alloc growshrink:     4761ms
    .std_alloc temporaries:    77ms
    .pool_alloc growshrink:    8ms
    .pool_alloc temporaries:   1ms
    .tls_bucket growshrink:    8ms
    .tls_bucket temporaries:   3ms
    .stress_test std::stl:     424ms
    .stress_test ps::stl:      25ms
}}}

After adding this patch, the 0 A.D. source can be changed iteratively to include the new ps_stl.h wrapped containers without having to change the whole codebase."	enhancement	new	Must Have	Alpha 14	Core engine		patch review performance memory		
