Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Joe Martin
OpenLDAP
Commits
4b01cb37
Commit
4b01cb37
authored
Sep 26, 2015
by
Howard Chu
Browse files
ITS#8221 don't merge branch pages needlessly
parent
ddb7478e
Changes
1
Show whitespace changes
Inline
Side-by-side
libraries/liblmdb/mdb.c
View file @
4b01cb37
...
...
@@ -7685,17 +7685,23 @@ mdb_rebalance(MDB_cursor *mc)
{
MDB_node
*
node
;
int
rc
;
unsigned
int
ptop
,
minkeys
;
unsigned
int
ptop
,
minkeys
,
thresh
;
MDB_cursor
mn
;
indx_t
oldki
;
minkeys
=
1
+
(
IS_BRANCH
(
mc
->
mc_pg
[
mc
->
mc_top
]));
if
(
IS_BRANCH
(
mc
->
mc_pg
[
mc
->
mc_top
]))
{
minkeys
=
1
;
thresh
=
1
;
}
else
{
minkeys
=
2
;
thresh
=
FILL_THRESHOLD
;
}
DPRINTF
((
"rebalancing %s page %"
Z
"u (has %u keys, %.1f%% full)"
,
IS_LEAF
(
mc
->
mc_pg
[
mc
->
mc_top
])
?
"leaf"
:
"branch"
,
mdb_dbg_pgno
(
mc
->
mc_pg
[
mc
->
mc_top
]),
NUMKEYS
(
mc
->
mc_pg
[
mc
->
mc_top
]),
(
float
)
PAGEFILL
(
mc
->
mc_txn
->
mt_env
,
mc
->
mc_pg
[
mc
->
mc_top
])
/
10
));
if
(
PAGEFILL
(
mc
->
mc_txn
->
mt_env
,
mc
->
mc_pg
[
mc
->
mc_top
])
>=
FILL_THRESHOLD
&&
if
(
PAGEFILL
(
mc
->
mc_txn
->
mt_env
,
mc
->
mc_pg
[
mc
->
mc_top
])
>=
thresh
&&
NUMKEYS
(
mc
->
mc_pg
[
mc
->
mc_top
])
>=
minkeys
)
{
DPRINTF
((
"no need to rebalance page %"
Z
"u, above fill threshold"
,
mdb_dbg_pgno
(
mc
->
mc_pg
[
mc
->
mc_top
])));
...
...
@@ -7829,8 +7835,7 @@ mdb_rebalance(MDB_cursor *mc)
* move one key from it. Otherwise we should try to merge them.
* (A branch page must never have less than 2 keys.)
*/
minkeys
=
1
+
(
IS_BRANCH
(
mn
.
mc_pg
[
mn
.
mc_top
]));
if
(
PAGEFILL
(
mc
->
mc_txn
->
mt_env
,
mn
.
mc_pg
[
mn
.
mc_top
])
>=
FILL_THRESHOLD
&&
NUMKEYS
(
mn
.
mc_pg
[
mn
.
mc_top
])
>
minkeys
)
{
if
(
PAGEFILL
(
mc
->
mc_txn
->
mt_env
,
mn
.
mc_pg
[
mn
.
mc_top
])
>=
thresh
&&
NUMKEYS
(
mn
.
mc_pg
[
mn
.
mc_top
])
>
minkeys
)
{
rc
=
mdb_node_move
(
&
mn
,
mc
);
if
(
mc
->
mc_ki
[
ptop
])
{
oldki
++
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment