Skip to content
Snippets Groups Projects
Commit 391c6a16 authored by Konstantin Shulgin's avatar Konstantin Shulgin
Browse files

MHash code clean-up.

parent c01e007f
No related branches found
No related tags found
No related merge requests found
......@@ -49,8 +49,6 @@ e * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
SOFTWARE.
*/
#import <config.h>
#ifndef MH_INCREMENTAL_RESIZE
#define MH_INCREMENTAL_RESIZE 1
#endif
......@@ -107,6 +105,7 @@ struct _mh(t) {
#define mh_value(h, i) ({ (h)->p[(i)].val; })
#define mh_size(h) ({ (h)->size; })
#define mh_begin(h) ({ 0; })
#define mh_end(h) ({ (h)->n_buckets; })
......@@ -122,7 +121,7 @@ void _mh(dump)(struct _mh(t) *h);
#define get_slot(h, key) _mh(get_slot)(h, key)
#define put_slot(h, key) _mh(put_slot)(h, key)
static uint32_t
static inline uint32_t
_mh(get_slot)(struct _mh(t) *h, mh_key_t key)
{
uint32_t inc, k, i;
......@@ -143,7 +142,7 @@ _mh(get_slot)(struct _mh(t) *h, mh_key_t key)
}
#if 0
static uint32_t
static inline uint32_t
_mh(put_slot)(struct _mh(t) *h, mh_key_t key)
{
uint32_t inc, k, i, p = h->n_buckets;
......@@ -171,7 +170,7 @@ _mh(put_slot)(struct _mh(t) *h, mh_key_t key)
#endif
/* Faster variant of above loop */
static uint32_t
static inline uint32_t
_mh(put_slot)(struct _mh(t) *h, mh_key_t key)
{
uint32_t inc, k, i, p = h->n_buckets;
......@@ -354,14 +353,16 @@ _mh(start_resize)(struct _mh(t) *h, uint32_t buckets, uint32_t batch)
if (buckets < h->n_buckets)
buckets = h->n_buckets;
if (buckets < h->size * 2) {
for (int k = h->prime; k < __ac_HASH_PRIME_SIZE; k++)
for (int k = h->prime; k < __ac_HASH_PRIME_SIZE - 1; k++)
if (__ac_prime_list[k] > h->size) {
h->prime = k + 1;
break;
}
}
h->batch = batch > 0 ? batch : h->n_buckets / (256 * 1024);
if (h->batch < 256) /* minimum batch is 3 */
if (h->batch < 256)
/* minimum batch must be greater or equal than
1 / (1 - f), where f is upper bound percent = 0.7 */
h->batch = 256;
memcpy(s, h, sizeof(*h));
s->resizing = 0;
......
......@@ -69,90 +69,6 @@
...
}
##
## realloc(ptr, 0)
##
{
<realloc with 0 byte>
Memcheck:Leak
fun:malloc
fun:realloc
fun:kh_destroy_int_ptr_map
...
}
{
<realloc with 0 byte>
Memcheck:Leak
fun:malloc
fun:realloc
fun:tnt_xrealloc
fun:kh_destroy_lstr_ptr_map
...
}
{
<realloc with 0 byte>
Memcheck:Leak
fun:malloc
fun:realloc
fun:kh_destroy_fid2fiber
fun:fiber_free
fun:tarantool_free
...
}
{
<realloc with 0 byte>
Memcheck:Leak
fun:malloc
fun:realloc
fun:tnt_xrealloc
fun:kh_destroy_lstr_ptr_map
fun:index_hash_str_free
fun:index_free
...
}
{
<realloc with 0 byte>
Memcheck:Leak
fun:malloc
fun:realloc
fun:tnt_xrealloc
fun:kh_resize_lstr_ptr_map
fun:kh_put_lstr_ptr_map
fun:index_replace_hash_str
...
}
{
<realloc with 0 byte>
Memcheck:Leak
fun:malloc
fun:realloc
fun:kh_resize_int_ptr_map
fun:kh_put_int_ptr_map
fun:index_replace_hash_num
...
}
{
<realloc with 0 byte>
Memcheck:Leak
fun:malloc
fun:realloc
fun:kh_resize_fid2fiber
fun:kh_put_fid2fiber
fun:register_fid
fun:fiber_create
fun:spawn_child
fun:recover_init
fun:mod_init
fun:main
}
##
## backtrace
##
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment