|
Revision 739, 1.1 kB
(checked in by dormando, 21 months ago)
|
|
Don't re-calculate the slab class id for slabs_free() either.
This + previous patch slightly reduce user CPU time, especially during heavy evictions.
|
| Line | |
|---|
| 1 | /* slabs memory allocation */ |
|---|
| 2 | |
|---|
| 3 | /** Init the subsystem. 1st argument is the limit on no. of bytes to allocate, |
|---|
| 4 | 0 if no limit. 2nd argument is the growth factor; each slab will use a chunk |
|---|
| 5 | size equal to the previous slab's chunk size times this factor. |
|---|
| 6 | 3rd argument specifies if the slab allocator should allocate all memory |
|---|
| 7 | up front (if true), or allocate memory in chunks as it is needed (if false) |
|---|
| 8 | */ |
|---|
| 9 | void slabs_init(const size_t limit, const double factor, const bool prealloc); |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | /** |
|---|
| 13 | * Given object size, return id to use when allocating/freeing memory for object |
|---|
| 14 | * 0 means error: can't store such a large object |
|---|
| 15 | */ |
|---|
| 16 | |
|---|
| 17 | unsigned int slabs_clsid(const size_t size); |
|---|
| 18 | |
|---|
| 19 | /** Allocate object of given length. 0 on error */ /*@null@*/ |
|---|
| 20 | void *do_slabs_alloc(const size_t size, unsigned int id); |
|---|
| 21 | |
|---|
| 22 | /** Free previously allocated object */ |
|---|
| 23 | void do_slabs_free(void *ptr, size_t size, unsigned int id); |
|---|
| 24 | |
|---|
| 25 | /** Fill buffer with stats */ /*@null@*/ |
|---|
| 26 | char* do_slabs_stats(int *buflen); |
|---|
| 27 | |
|---|
| 28 | /* Request some slab be moved between classes |
|---|
| 29 | 1 = success |
|---|
| 30 | 0 = fail |
|---|
| 31 | -1 = tried. busy. send again shortly. */ |
|---|
| 32 | int do_slabs_reassign(unsigned char srcid, unsigned char dstid); |
|---|
| 33 | |
|---|