-
Notifications
You must be signed in to change notification settings - Fork 55
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
INTERNAL: Change tot_elem_cnt to subtree element count in set #817
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,7 +146,6 @@ static set_hash_node *do_set_node_alloc(uint8_t hash_depth, const void *cookie) | |
|
||
node->refcount = 0; | ||
node->hdepth = hash_depth; | ||
node->tot_hash_cnt = 0; | ||
node->tot_elem_cnt = 0; | ||
memset(node->hcnt, 0, SET_HASHTAB_SIZE*sizeof(uint16_t)); | ||
memset(node->htab, 0, SET_HASHTAB_SIZE*sizeof(void*)); | ||
|
@@ -219,8 +218,6 @@ static void do_set_node_link(set_meta_info *info, | |
|
||
par_node->htab[par_hidx] = node; | ||
par_node->hcnt[par_hidx] = -1; /* child hash node */ | ||
par_node->tot_elem_cnt -= num_found; | ||
par_node->tot_hash_cnt += 1; | ||
} | ||
|
||
if (1) { /* apply memory space */ | ||
|
@@ -237,7 +234,6 @@ static void do_set_node_unlink(set_meta_info *info, | |
if (par_node == NULL) { | ||
node = info->root; | ||
info->root = NULL; | ||
assert(node->tot_hash_cnt == 0); | ||
assert(node->tot_elem_cnt == 0); | ||
} else { | ||
assert(par_node->hcnt[par_hidx] == -1); /* child hash node */ | ||
|
@@ -246,7 +242,6 @@ static void do_set_node_unlink(set_meta_info *info, | |
int hidx, fcnt = 0; | ||
|
||
node = (set_hash_node *)par_node->htab[par_hidx]; | ||
assert(node->tot_hash_cnt == 0); | ||
|
||
for (hidx = 0; hidx < SET_HASHTAB_SIZE; hidx++) { | ||
assert(node->hcnt[hidx] >= 0); | ||
|
@@ -263,13 +258,10 @@ static void do_set_node_unlink(set_meta_info *info, | |
assert(node->hcnt[hidx] == 0); | ||
} | ||
} | ||
assert(fcnt == node->tot_elem_cnt); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์ฌ๊ธฐ assert ๋ฌธ์ ๊ทธ๋๋ก ๋ก์๋ค. |
||
node->tot_elem_cnt = 0; | ||
|
||
par_node->htab[par_hidx] = head; | ||
par_node->hcnt[par_hidx] = fcnt; | ||
par_node->tot_elem_cnt += fcnt; | ||
par_node->tot_hash_cnt -= 1; | ||
} | ||
|
||
if (info->stotal > 0) { /* apply memory space */ | ||
|
@@ -324,7 +316,14 @@ static ENGINE_ERROR_CODE do_set_elem_link(set_meta_info *info, set_elem_item *el | |
elem->next = node->htab[hidx]; | ||
node->htab[hidx] = elem; | ||
node->hcnt[hidx] += 1; | ||
node->tot_elem_cnt += 1; | ||
node = info->root; | ||
while (node != NULL) { | ||
node->tot_elem_cnt += 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
while (node != NULL) {
node->tot_elem_cnt -= 1;
hidx = SET_GET_HASHIDX(elem->hval, node->hdepth);
if (node->hcnt[hidx] >= 0)
break;
node = node->htab[hidx];
} |
||
hidx = SET_GET_HASHIDX(elem->hval, node->hdepth); | ||
if (node->hcnt[hidx] >= 0) | ||
break; | ||
node = node->htab[hidx]; | ||
} | ||
jhpark816 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ์๋ ์ฝ๋์ ๊ฐ์ด ํ์ฌ ๋
ธ๋์์ tot_elem_cnt ์ฆ๊ฐ์ํค๋ ์ฝ๋์ elem->next = node->htab[hidx];
node->htab[hidx] = elem;
node->hcnt[hidx] += 1;
node->tot_elem_cnt += 1;
set_hash_node *par_node = info->root;
while (par_node != node) {
par_node->tot_elem_cnt += 1;
hidx = SET_GET_HASHIDX(elem->hval, par_node->hdepth);
assert(par_node->hcnt[hidx] == -1);
par_node = par_node->htab[hidx];
}
info->ccnt++; |
||
|
||
info->ccnt++; | ||
|
||
|
@@ -396,10 +395,10 @@ static ENGINE_ERROR_CODE do_set_elem_traverse_delete(set_meta_info *info, set_ha | |
set_hash_node *child_node = node->htab[hidx]; | ||
ret = do_set_elem_traverse_delete(info, child_node, hval, val, vlen); | ||
if (ret == ENGINE_SUCCESS) { | ||
if (child_node->tot_hash_cnt == 0 && | ||
child_node->tot_elem_cnt < (SET_MAX_HASHCHAIN_SIZE/2)) { | ||
if (child_node->tot_elem_cnt < (SET_MAX_HASHCHAIN_SIZE/2)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
์กฐ๊ธ์ด๋ผ๋ ํ์ ์ด ์์ง ์๋๋ค๋ฉด, ์๋์ ๊ฐ์ด is_leaf_node() ์ถ๊ฐํ๋ฉด ์ข๊ฒ ์ต๋๋ค. if (child_node->tot_elem_cnt < (SET_MAX_HASHCHAIN_SIZE/2)
&& is_leaf_node(child_node)) {
do_set_node_unlink(info, node, hidx);
} |
||
do_set_node_unlink(info, node, hidx); | ||
} | ||
node->tot_elem_cnt -= 1; | ||
} | ||
} else { | ||
ret = ENGINE_ELEM_ENOENT; | ||
|
@@ -431,7 +430,7 @@ static ENGINE_ERROR_CODE do_set_elem_delete_with_value(set_meta_info *info, | |
int hval = genhash_string_hash(val, vlen); | ||
ret = do_set_elem_traverse_delete(info, info->root, hval, val, vlen); | ||
if (ret == ENGINE_SUCCESS) { | ||
if (info->root->tot_hash_cnt == 0 && info->root->tot_elem_cnt == 0) { | ||
if (info->root->tot_elem_cnt == 0) { | ||
do_set_node_unlink(info, NULL, 0); | ||
} | ||
} | ||
|
@@ -497,13 +496,14 @@ static int do_set_elem_traverse_dfs(set_meta_info *info, set_hash_node *node, | |
if (node->hcnt[hidx] == -1) { | ||
set_hash_node *child_node = (set_hash_node *)node->htab[hidx]; | ||
int rcnt = (count > 0 ? (count - fcnt) : 0); | ||
fcnt += do_set_elem_traverse_dfs(info, child_node, rcnt, delete, | ||
(elem_array==NULL ? NULL : &elem_array[fcnt])); | ||
int ecnt = do_set_elem_traverse_dfs(info, child_node, rcnt, delete, | ||
(elem_array==NULL ? NULL : &elem_array[fcnt])); | ||
fcnt += ecnt; | ||
if (delete) { | ||
if (child_node->tot_hash_cnt == 0 && | ||
child_node->tot_elem_cnt < (SET_MAX_HASHCHAIN_SIZE/2)) { | ||
if (child_node->tot_elem_cnt < (SET_MAX_HASHCHAIN_SIZE/2)) { | ||
do_set_node_unlink(info, node, hidx); | ||
} | ||
node->tot_elem_cnt -= ecnt; | ||
} | ||
} else if (node->hcnt[hidx] > 0) { | ||
set_elem_item *elem = node->htab[hidx]; | ||
|
@@ -551,7 +551,7 @@ static uint32_t do_set_elem_delete(set_meta_info *info, const uint32_t count, | |
uint32_t fcnt = 0; | ||
if (info->root != NULL) { | ||
fcnt = do_set_elem_traverse_dfs(info, info->root, count, true, NULL); | ||
if (info->root->tot_hash_cnt == 0 && info->root->tot_elem_cnt == 0) { | ||
if (info->root->tot_elem_cnt == 0) { | ||
do_set_node_unlink(info, NULL, 0); | ||
} | ||
} | ||
|
@@ -569,7 +569,7 @@ static uint32_t do_set_elem_get(set_meta_info *info, | |
CLOG_ELEM_DELETE_BEGIN((coll_meta_info*)info, count, ELEM_DELETE_NORMAL); | ||
} | ||
fcnt = do_set_elem_traverse_dfs(info, info->root, count, delete, elem_array); | ||
if (delete && info->root->tot_hash_cnt == 0 && info->root->tot_elem_cnt == 0) { | ||
if (delete && info->root->tot_elem_cnt == 0) { | ||
do_set_node_unlink(info, NULL, 0); | ||
} | ||
if (delete) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,8 +236,7 @@ typedef struct _set_hash_node { | |
uint16_t refcount; | ||
uint8_t slabs_clsid; /* which slab class we're in */ | ||
uint8_t hdepth; | ||
uint16_t tot_elem_cnt; | ||
uint16_t tot_hash_cnt; | ||
uint32_t tot_elem_cnt; | ||
int16_t hcnt[SET_HASHTAB_SIZE]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jeesup0103 ๊ฐ hash bucket์ ์๋ element ๊ฐ์๋ hcnt[i] ๊ฐ์ ํ์ธํ ์ ์๊ณ , hcnt[i]์์ ํ์ node์ ์๋ element ๊ฐ์๋ฅผ ์ ์งํ๋ ๋ฐฉ์๋ ์๊ฐํด ๋ณผ ์ ์๋ ๋ฐ, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jhpark816 ๊ทธ๋ฆฌ๊ณ , |
||
void *htab[SET_HASHTAB_SIZE]; | ||
} set_hash_node; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์์ ํ๋ ๊น์, num_found, num_elems ๋ณ์๋ฅผ ๋ชจ๋ ์ ๊ฑฐํด๋ ๋ ๊ฒ ๊ฐ์ต๋๋ค.