Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rebased fixes for 1.4.x codeline #2

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,4 +1,4 @@
*.[ao] *.[aois]
*.gcov *.gcov
*.gcda *.gcda
*.gcno *.gcno
Expand Down
14 changes: 7 additions & 7 deletions assoc.c
Expand Up @@ -71,8 +71,8 @@ item *assoc_find(const char *key, const size_t nkey) {
item *it; item *it;
unsigned int oldbucket; unsigned int oldbucket;


if (expanding && if (unlikely(expanding) &&
(oldbucket = (hv & hashmask(hashpower - 1))) >= expand_bucket) unlikely((oldbucket = (hv & hashmask(hashpower - 1))) >= expand_bucket))
{ {
it = old_hashtable[oldbucket]; it = old_hashtable[oldbucket];
} else { } else {
Expand Down Expand Up @@ -101,7 +101,7 @@ static item** _hashitem_before (const char *key, const size_t nkey) {
item **pos; item **pos;
unsigned int oldbucket; unsigned int oldbucket;


if (expanding && if (unlikely(expanding) &&
(oldbucket = (hv & hashmask(hashpower - 1))) >= expand_bucket) (oldbucket = (hv & hashmask(hashpower - 1))) >= expand_bucket)
{ {
pos = &old_hashtable[oldbucket]; pos = &old_hashtable[oldbucket];
Expand All @@ -121,7 +121,7 @@ static void assoc_expand(void) {


primary_hashtable = calloc(hashsize(hashpower + 1), sizeof(void *)); primary_hashtable = calloc(hashsize(hashpower + 1), sizeof(void *));
if (primary_hashtable) { if (primary_hashtable) {
if (settings.verbose > 1) if (unlikely(settings.verbose > 1))
fprintf(stderr, "Hash table expansion starting\n"); fprintf(stderr, "Hash table expansion starting\n");
hashpower++; hashpower++;
expanding = true; expanding = true;
Expand All @@ -141,7 +141,7 @@ int assoc_insert(item *it) {
assert(assoc_find(ITEM_key(it), it->nkey) == 0); /* shouldn't have duplicately named things defined */ assert(assoc_find(ITEM_key(it), it->nkey) == 0); /* shouldn't have duplicately named things defined */


hv = hash(ITEM_key(it), it->nkey, 0); hv = hash(ITEM_key(it), it->nkey, 0);
if (expanding && if (unlikely(expanding) &&
(oldbucket = (hv & hashmask(hashpower - 1))) >= expand_bucket) (oldbucket = (hv & hashmask(hashpower - 1))) >= expand_bucket)
{ {
it->h_next = old_hashtable[oldbucket]; it->h_next = old_hashtable[oldbucket];
Expand All @@ -152,7 +152,7 @@ int assoc_insert(item *it) {
} }


hash_items++; hash_items++;
if (! expanding && hash_items > (hashsize(hashpower) * 3) / 2) { if (! unlikely(expanding) && hash_items > (hashsize(hashpower) * 3) / 2) {
assoc_expand(); assoc_expand();
} }


Expand Down Expand Up @@ -213,7 +213,7 @@ static void *assoc_maintenance_thread(void *arg) {
if (expand_bucket == hashsize(hashpower - 1)) { if (expand_bucket == hashsize(hashpower - 1)) {
expanding = false; expanding = false;
free(old_hashtable); free(old_hashtable);
if (settings.verbose > 1) if (unlikely(settings.verbose > 1))
fprintf(stderr, "Hash table expansion done\n"); fprintf(stderr, "Hash table expansion done\n");
} }
} }
Expand Down
68 changes: 0 additions & 68 deletions doc/threads.txt

This file was deleted.

4 changes: 2 additions & 2 deletions items.c
Expand Up @@ -466,7 +466,7 @@ item *do_item_get(const char *key, const size_t nkey) {
item *it = assoc_find(key, nkey); item *it = assoc_find(key, nkey);
int was_found = 0; int was_found = 0;


if (settings.verbose > 2) { if (unlikely(settings.verbose > 2)) {
if (it == NULL) { if (it == NULL) {
fprintf(stderr, "> NOT FOUND %s", key); fprintf(stderr, "> NOT FOUND %s", key);
} else { } else {
Expand Down Expand Up @@ -501,7 +501,7 @@ item *do_item_get(const char *key, const size_t nkey) {
DEBUG_REFCNT(it, '+'); DEBUG_REFCNT(it, '+');
} }


if (settings.verbose > 2) if (unlikely(settings.verbose > 2))
fprintf(stderr, "\n"); fprintf(stderr, "\n");


return it; return it;
Expand Down