-
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 |
---|---|---|
|
@@ -219,7 +219,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; | ||
} | ||
|
||
|
@@ -263,12 +262,10 @@ static void do_set_node_unlink(set_meta_info *info, | |
assert(node->hcnt[hidx] == 0); | ||
} | ||
} | ||
assert(fcnt == node->tot_elem_cnt); | ||
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; | ||
} | ||
|
||
|
@@ -324,7 +321,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; | ||
hidx = SET_GET_HASHIDX(elem->hval, node->hdepth); | ||
if (node->hcnt[hidx] >= 0) | ||
break; | ||
node = node->htab[hidx]; | ||
} | ||
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. delete ํ๋ ๊ฒฝ์ฐ์ ์ ์ฌํ๊ฒ |
||
|
||
info->ccnt++; | ||
|
||
|
@@ -400,6 +404,7 @@ static ENGINE_ERROR_CODE do_set_elem_traverse_delete(set_meta_info *info, set_ha | |
child_node->tot_elem_cnt < (SET_MAX_HASHCHAIN_SIZE/2)) { | ||
do_set_node_unlink(info, node, hidx); | ||
} | ||
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. ์๋ ํํ๋ก ๋ณ๊ฒฝํ์์ฃ . tot_elem_cnt -= 1; |
||
} | ||
} else { | ||
ret = ENGINE_ELEM_ENOENT; | ||
|
@@ -497,13 +502,15 @@ 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)) { | ||
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]; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -236,7 +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; | ||
uint32_t tot_elem_cnt; | ||
uint16_t tot_hash_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. unit32_t tot_elem_cnt ๋ child node์ ์๋ elements ์๋ฅผ ํฌํจํ๋ ๊ฒ์ผ๋ก ๋ณ๊ฒฝํ๋ค๋ฉด, tot_hash_cnt๊ฐ ์ด์ฉ๋๋ 2๊ฐ์ง ๊ฒฝ์ฐ๊ฐ ์์ต๋๋ค. ์ฒซ์งธ, ์๋ ๊ฒฝ์ฐ์์ if (info->root->tot_hash_cnt == 0 && info->root->tot_elem_cnt == 0) {
do_set_node_unlink(info, NULL, 0);
} ๋์จฐ, ์๋ ๊ฒฝ์ฐ์์ tot_hash_cnt ํ๋๋ฅผ ์ ๊ฑฐํ๋ ๋์ ์ if (child_node->tot_hash_cnt == 0 &&
child_node->tot_elem_cnt < (SET_MAX_HASHCHAIN_SIZE/2)) {
do_set_node_unlink(info, node, hidx);
}
=>
if (child_node->tot_elem_cnt < (SET_MAX_HASHCHAIN_SIZE/2)
&& get_child_node_count(node) == 0) {
do_set_node_unlink(info, node, hidx);
} ๊ทธ๋ฆฌ๊ณ 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]; | ||
|
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.
do_set_node_link()
,do_set_node_unlink()
,do_set_elem_link()
3๊ฐ ํจ์๋ ์์ ํ๋๋ฐ,do_set_elem_unlink()
๋ ๊ธฐ์กด ๊ตฌํ์ ๊ทธ๋๋ก ์ฌ์ฉํ๊ณ ์์ต๋๋ค.do_set_elem_traverse_XXX()
์์ ์ฒ๋ฆฌํ๊ธฐ ๋๋ฌธ์ธ๊ฐ์?XXX_link()
์XXX_unlink()
์์tot_elem_cnt
๊ฐ์ ๋ณ๊ฒฝํ๊ณ ,traverse
ํจ์์์๋ ๋น๊ต ์ฐ์ฐ๋ง ์ํํ์ต๋๋ค.๊ธฐ์กด์ฒ๋ผ ๋ฐ๋ ์ด๋ฆ์ ๊ฐ๋ ํจ์์ ๋์์ด ์๋ก ์ง์ ์ด๋ฃจ๋๋ก ๊ตฌํํ๊ธฐ๋ ์ด๋ ค์ด๊ฐ์?
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.
tot_elem_cnt
๊ฐ์do_set_elem_traverse_XXX()
์์ ์ฒ๋ฆฌ ๋ฉ๋๋ค.do_set_elem_unlink()
์์do_set_elem_link()
์ ๊ฐ์ด ํด์๊ฐ์ ๊ธฐ์ค์ผ๋ก while๋ฌธ์ ๋ฐ๋ณตํด์ ๋ถ๋ชจ ๋ ธ๋๋ค์tot_elem_cnt
๊ฐ์ ์ ๋ฐ์ดํธ ํ ์ ์์ต๋๋ค.๊ทธ๋ฌ๋ฉด ํ๋์ element๋ฅผ ์ญ์ ํ ๋๋ง๋ค ๋ถ๋ชจ ๋ ธ๋๋ค์ ์ ๋ฐ์ดํธ ํด์ผํ๋ ๋น์ฉ์ ๋ฐ์ํฉ๋๋ค. (ํ์ฌ PR์์๋ ๋ ธ๋๋น ํ๋ฒ ์ ๋ฐ์ดํธ)