Commit 773bb8c9 authored by John Esmet's avatar John Esmet

fixes #132 Calculate size delta statistics once during the partial

eviction callback
parent ed9b5fc6
...@@ -1067,6 +1067,8 @@ BASEMENTNODE toku_detach_bn(FTNODE node, int childnum) { ...@@ -1067,6 +1067,8 @@ BASEMENTNODE toku_detach_bn(FTNODE node, int childnum) {
int toku_ftnode_pe_callback (void *ftnode_pv, PAIR_ATTR UU(old_attr), PAIR_ATTR* new_attr, void* extraargs) { int toku_ftnode_pe_callback (void *ftnode_pv, PAIR_ATTR UU(old_attr), PAIR_ATTR* new_attr, void* extraargs) {
FTNODE node = (FTNODE)ftnode_pv; FTNODE node = (FTNODE)ftnode_pv;
FT ft = (FT) extraargs; FT ft = (FT) extraargs;
long size_before = 0;
int num_partial_evictions = 0;
// Don't partially evict dirty nodes // Don't partially evict dirty nodes
if (node->dirty) { if (node->dirty) {
goto exit; goto exit;
...@@ -1083,11 +1085,10 @@ int toku_ftnode_pe_callback (void *ftnode_pv, PAIR_ATTR UU(old_attr), PAIR_ATTR* ...@@ -1083,11 +1085,10 @@ int toku_ftnode_pe_callback (void *ftnode_pv, PAIR_ATTR UU(old_attr), PAIR_ATTR*
for (int i = 0; i < node->n_children; i++) { for (int i = 0; i < node->n_children; i++) {
if (BP_STATE(node,i) == PT_AVAIL) { if (BP_STATE(node,i) == PT_AVAIL) {
if (BP_SHOULD_EVICT(node,i)) { if (BP_SHOULD_EVICT(node,i)) {
long size_before = ftnode_memory_size(node); if (num_partial_evictions++ == 0) {
size_before = ftnode_memory_size(node);
}
compress_internal_node_partition(node, i, ft->h->compression_method); compress_internal_node_partition(node, i, ft->h->compression_method);
long delta = size_before - ftnode_memory_size(node);
STATUS_INC(FT_PARTIAL_EVICTIONS_NONLEAF, 1);
STATUS_INC(FT_PARTIAL_EVICTIONS_NONLEAF_BYTES, delta);
} }
else { else {
BP_SWEEP_CLOCK(node,i); BP_SWEEP_CLOCK(node,i);
...@@ -1107,23 +1108,21 @@ int toku_ftnode_pe_callback (void *ftnode_pv, PAIR_ATTR UU(old_attr), PAIR_ATTR* ...@@ -1107,23 +1108,21 @@ int toku_ftnode_pe_callback (void *ftnode_pv, PAIR_ATTR UU(old_attr), PAIR_ATTR*
for (int i = 0; i < node->n_children; i++) { for (int i = 0; i < node->n_children; i++) {
// Get rid of compressed stuff no matter what. // Get rid of compressed stuff no matter what.
if (BP_STATE(node,i) == PT_COMPRESSED) { if (BP_STATE(node,i) == PT_COMPRESSED) {
long size_before = ftnode_memory_size(node); if (num_partial_evictions++ == 0) {
size_before = ftnode_memory_size(node);
}
SUB_BLOCK sb = BSB(node, i); SUB_BLOCK sb = BSB(node, i);
toku_free(sb->compressed_ptr); toku_free(sb->compressed_ptr);
toku_free(sb); toku_free(sb);
set_BNULL(node, i); set_BNULL(node, i);
BP_STATE(node,i) = PT_ON_DISK; BP_STATE(node,i) = PT_ON_DISK;
long delta = size_before - ftnode_memory_size(node);
STATUS_INC(FT_PARTIAL_EVICTIONS_LEAF, 1);
STATUS_INC(FT_PARTIAL_EVICTIONS_LEAF_BYTES, delta);
} }
else if (BP_STATE(node,i) == PT_AVAIL) { else if (BP_STATE(node,i) == PT_AVAIL) {
if (BP_SHOULD_EVICT(node,i)) { if (BP_SHOULD_EVICT(node,i)) {
long size_before = ftnode_memory_size(node); if (num_partial_evictions++ == 0) {
size_before = ftnode_memory_size(node);
}
toku_evict_bn_from_memory(node, i, ft); toku_evict_bn_from_memory(node, i, ft);
long delta = size_before - ftnode_memory_size(node);
STATUS_INC(FT_PARTIAL_EVICTIONS_LEAF, 1);
STATUS_INC(FT_PARTIAL_EVICTIONS_LEAF_BYTES, delta);
} }
else { else {
BP_SWEEP_CLOCK(node,i); BP_SWEEP_CLOCK(node,i);
...@@ -1138,6 +1137,17 @@ int toku_ftnode_pe_callback (void *ftnode_pv, PAIR_ATTR UU(old_attr), PAIR_ATTR* ...@@ -1138,6 +1137,17 @@ int toku_ftnode_pe_callback (void *ftnode_pv, PAIR_ATTR UU(old_attr), PAIR_ATTR*
} }
} }
if (num_partial_evictions > 0) {
long delta = size_before - ftnode_memory_size(node);
if (node->height == 0) {
STATUS_INC(FT_PARTIAL_EVICTIONS_LEAF, num_partial_evictions);
STATUS_INC(FT_PARTIAL_EVICTIONS_LEAF_BYTES, delta);
} else {
STATUS_INC(FT_PARTIAL_EVICTIONS_NONLEAF, num_partial_evictions);
STATUS_INC(FT_PARTIAL_EVICTIONS_NONLEAF_BYTES, delta);
}
}
exit: exit:
*new_attr = make_ftnode_pair_attr(node); *new_attr = make_ftnode_pair_attr(node);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment