> >> > > >> > typedef struct { > >> > // sum of all (simultaneous) allocs > >> > uint64_t pool_size; > >> > > >> > // Minimum alloc size application will request from pool > >> > uint32_t min_alloc; > >> > > >> > // Maximum alloc size application will request from pool > >> > uint32_t max_alloc; > >> > > >> > } odp_shm_pool_param_t; > >> > >> That makes more sense. > >> Not sure we really need a struct for 3 values, but it could well be so > >> on the north interface if you want. > > > > With param struct it's easier to add new params in backwards compatible > manner (if needed). Also, we use 'param' with all other create calls. > > > > I think the min_alloc will mostly be either be 1 (pool for many > different things unknown at pool cration time) or equal to max_alloc > (Pool of one single thing). So things look a bit overkill to me. > > But I will do as you want. :-)
It depends how well application knows in advance about usage. For example, if it uses a pool for building a data base of struct foo's (80 bytes) and struct bar's (100 bytes), then it can expect best performance for min=80, max=100, rather than min=1, max=100. > >> OK. As buddy allocation garantees a minimum of 50% efficiency, we can > >> do like that: > >> if (min_alloc == max_alloc) > >> => slab (size = pool size rounded up to ineteger nb of min_alloc) > >> else > >> => buddy (next_power_of_2(2*given_pool_sz)) > >> > >> OK? > > > > Seems OK. Also, the algorithm is easy to tune afterward. E.g. you could > use slab for bit wider range - it should be faster of the two, since it's > simpler. > > > > if (min_alloc == max_alloc || min_alloc > 0.8*max_alloc) > > I guess the tipping point is 2 instead of 0.8: if max_alloc > > 2*min_alloc then a buddy allocator will perform better than a slab. If > not, a slab is better, because the buddy allocator will have to cope > for the worse case. The selection will be based on CPU cycle vs. memory consumption figures. Up to some point, the user is willing to sacrifice higher memory usage for lower CPU cycle consumption. The point will be based on cpu/memory performance difference of the two implementations, system memory size, cache size, etc. It may be min = 0.8*max, min = 0.5*max, or something else. -Petri