Increase the small size slabs a bit.
Move 64Bit integer hashing function to common file for use in other places.
This commit is contained in:
parent
a6f3756e68
commit
7ff2cb74c4
3 changed files with 24 additions and 23 deletions
10
allocator.c
10
allocator.c
|
@ -51,20 +51,20 @@
|
||||||
#ifndef DEBUG_NO_SLAB
|
#ifndef DEBUG_NO_SLAB
|
||||||
/*
|
/*
|
||||||
* Number of slabs:
|
* Number of slabs:
|
||||||
* 256 bytes to 1M in power of 2 steps: 13
|
* 64 bytes to 1M in power of 2 steps: 15
|
||||||
* 1M to 128M in linear steps of 1M: 128
|
* 1M to 128M in linear steps of 1M: 128
|
||||||
* 200 dynamic slab slots: 200
|
* 200 dynamic slab slots: 200
|
||||||
*
|
*
|
||||||
* By doing this we try to get reasonable memory usage while not
|
* By doing this we try to get reasonable memory usage while not
|
||||||
* sacrificing performance.
|
* sacrificing performance.
|
||||||
*/
|
*/
|
||||||
#define NUM_POW2 13
|
#define NUM_POW2 15
|
||||||
#define NUM_LINEAR 128
|
#define NUM_LINEAR 128
|
||||||
#define NUM_SLAB_HASH 200 /* Dynamic slabs hashtable size. */
|
#define NUM_SLAB_HASH 200 /* Dynamic slabs hashtable size. */
|
||||||
#define NUM_SLABS (NUM_POW2 + NUM_LINEAR + NUM_SLAB_HASH)
|
#define NUM_SLABS (NUM_POW2 + NUM_LINEAR + NUM_SLAB_HASH)
|
||||||
#define SLAB_POS_HASH (NUM_POW2 + NUM_LINEAR)
|
#define SLAB_POS_HASH (NUM_POW2 + NUM_LINEAR)
|
||||||
#define SLAB_START_SZ 256 /* Starting slab size in Bytes. */
|
#define SLAB_START_SZ 64 /* Starting slab size in Bytes. */
|
||||||
#define SLAB_START_POW2 8 /* 2 ^ SLAB_START_POW2 = SLAB_START. */
|
#define SLAB_START_POW2 6 /* 2 ^ SLAB_START_POW2 = SLAB_START. */
|
||||||
|
|
||||||
#define HTABLE_SZ 8192
|
#define HTABLE_SZ 8192
|
||||||
#define ONEM (1UL * 1024UL * 1024UL)
|
#define ONEM (1UL * 1024UL * 1024UL)
|
||||||
|
@ -376,7 +376,7 @@ slab_alloc(void *p, size_t size)
|
||||||
|
|
||||||
if (!slab) {
|
if (!slab) {
|
||||||
if (size <= ONEM) {
|
if (size <= ONEM) {
|
||||||
/* First eleven slots are power of 2 sizes upto 1M. */
|
/* First fifteen slots are power of 2 sizes upto 1M. */
|
||||||
slab = &slabheads[find_slot(size)];
|
slab = &slabheads[find_slot(size)];
|
||||||
} else {
|
} else {
|
||||||
/* Next slots are in intervals of 1M. */
|
/* Next slots are in intervals of 1M. */
|
||||||
|
|
17
utils.c
17
utils.c
|
@ -169,23 +169,6 @@ bytes_to_size(uint64_t bytes)
|
||||||
return (num);
|
return (num);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Hash function for 64Bit pointers that generates a 32Bit hash value.
|
|
||||||
* Taken from Thomas Wang's Integer hashing paper:
|
|
||||||
* http://www.cris.com/~Ttwang/tech/inthash.htm
|
|
||||||
*/
|
|
||||||
uint32_t
|
|
||||||
hash6432shift(uint64_t key)
|
|
||||||
{
|
|
||||||
key = (~key) + (key << 18); // key = (key << 18) - key - 1;
|
|
||||||
key = key ^ (key >> 31);
|
|
||||||
key = key * 21; // key = (key + (key << 2)) + (key << 4);
|
|
||||||
key = key ^ (key >> 11);
|
|
||||||
key = key + (key << 6);
|
|
||||||
key = key ^ (key >> 22);
|
|
||||||
return (uint32_t) key;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read/Write helpers to ensure a full chunk is read or written
|
* Read/Write helpers to ensure a full chunk is read or written
|
||||||
* unless there is an error.
|
* unless there is an error.
|
||||||
|
|
20
utils.h
20
utils.h
|
@ -102,7 +102,6 @@ extern void err_exit(int show_errno, const char *format, ...);
|
||||||
extern const char *get_execname(const char *);
|
extern const char *get_execname(const char *);
|
||||||
extern int parse_numeric(ssize_t *val, const char *str);
|
extern int parse_numeric(ssize_t *val, const char *str);
|
||||||
extern char *bytes_to_size(uint64_t bytes);
|
extern char *bytes_to_size(uint64_t bytes);
|
||||||
extern uint32_t hash6432shift(uint64_t key);
|
|
||||||
extern ssize_t Read(int fd, void *buf, size_t count);
|
extern ssize_t Read(int fd, void *buf, size_t count);
|
||||||
extern ssize_t Read_Adjusted(int fd, uchar_t *buf, size_t count,
|
extern ssize_t Read_Adjusted(int fd, uchar_t *buf, size_t count,
|
||||||
ssize_t *rabin_count, void *ctx);
|
ssize_t *rabin_count, void *ctx);
|
||||||
|
@ -134,6 +133,25 @@ roundup_pow_two(unsigned int v) {
|
||||||
return (v);
|
return (v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Hash function for 64Bit pointers/numbers that generates
|
||||||
|
* a 32Bit hash value.
|
||||||
|
* Taken from Thomas Wang's Integer hashing paper:
|
||||||
|
* http://www.cris.com/~Ttwang/tech/inthash.htm
|
||||||
|
*/
|
||||||
|
static uint32_t
|
||||||
|
hash6432shift(uint64_t key)
|
||||||
|
{
|
||||||
|
key = (~key) + (key << 18); // key = (key << 18) - key - 1;
|
||||||
|
key = key ^ (key >> 31);
|
||||||
|
key = key * 21; // key = (key + (key << 2)) + (key << 4);
|
||||||
|
key = key ^ (key >> 11);
|
||||||
|
key = key + (key << 6);
|
||||||
|
key = key ^ (key >> 22);
|
||||||
|
return (uint32_t) key;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue