Commit cc10b7c7 authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:4775], remove NONLEAF_CHILDINFO->n_bytes_in_buffer

git-svn-id: file:///svn/toku/tokudb@42751 c7de825b-a66e-492c-adef-691d508d4ae1
parent 50f371cc
......@@ -127,7 +127,6 @@ struct brtnode_nonleaf_childinfo {
OMT broadcast_list;
OMT fresh_message_tree;
OMT stale_message_tree;
unsigned int n_bytes_in_buffer; /* How many bytes are in each buffer (including overheads for the disk-representation) */
};
unsigned int toku_bnc_nbytesinbuf(NONLEAF_CHILDINFO bnc);
......
......@@ -932,7 +932,6 @@ static void
deserialize_child_buffer(NONLEAF_CHILDINFO bnc, struct rbuf *rbuf,
DESCRIPTOR desc, brt_compare_func cmp) {
int r;
int n_bytes_in_buffer = 0;
int n_in_this_buffer = rbuf_int(rbuf);
void **fresh_offsets, **stale_offsets;
void **broadcast_offsets;
......@@ -977,7 +976,6 @@ deserialize_child_buffer(NONLEAF_CHILDINFO bnc, struct rbuf *rbuf,
}
r = toku_fifo_enq(bnc->buffer, key, keylen, val, vallen, type, msn, xids, is_fresh, dest); /* Copies the data into the fifo */
lazy_assert_zero(r);
n_bytes_in_buffer += keylen + vallen + KEY_VALUE_OVERHEAD + BRT_CMD_OVERHEAD + xids_get_serialize_size(xids);
//printf("Inserted\n");
xids_destroy(&xids);
}
......@@ -999,7 +997,6 @@ deserialize_child_buffer(NONLEAF_CHILDINFO bnc, struct rbuf *rbuf,
r = toku_omt_create_steal_sorted_array(&bnc->broadcast_list, &broadcast_offsets, nbroadcast_offsets, n_in_this_buffer);
assert_zero(r);
}
bnc->n_bytes_in_buffer = n_bytes_in_buffer;
}
// dump a buffer to stderr
......@@ -1095,7 +1092,6 @@ BASEMENTNODE toku_create_empty_bn_no_buffer(void) {
NONLEAF_CHILDINFO toku_create_empty_nl(void) {
NONLEAF_CHILDINFO XMALLOC(cn);
cn->n_bytes_in_buffer = 0;
int r = toku_fifo_create(&cn->buffer); assert_zero(r);
r = toku_omt_create(&cn->fresh_message_tree); assert_zero(r);
r = toku_omt_create(&cn->stale_message_tree); assert_zero(r);
......@@ -1106,7 +1102,6 @@ NONLEAF_CHILDINFO toku_create_empty_nl(void) {
// does NOT create OMTs, just the FIFO
NONLEAF_CHILDINFO toku_clone_nl(NONLEAF_CHILDINFO orig_childinfo) {
NONLEAF_CHILDINFO XMALLOC(cn);
cn->n_bytes_in_buffer = orig_childinfo->n_bytes_in_buffer;
cn->fresh_message_tree = NULL;
cn->stale_message_tree = NULL;
cn->broadcast_list = NULL;
......@@ -1779,7 +1774,6 @@ deserialize_and_upgrade_internal_node(BRTNODE node,
// Deserialize de-compressed buffers.
for (int i = 0; i < node->n_children; ++i) {
NONLEAF_CHILDINFO bnc = BNC(node, i);
int n_bytes_in_buffer = 0;
int n_in_this_buffer = rbuf_int(rb);
void **fresh_offsets;
......@@ -1843,7 +1837,6 @@ deserialize_and_upgrade_internal_node(BRTNODE node,
true,
dest);
lazy_assert_zero(r);
n_bytes_in_buffer += keylen + vallen + BRT_CMD_OVERHEAD + KEY_VALUE_OVERHEAD + xids_get_serialize_size(xids);
xids_destroy(&xids);
}
......@@ -1870,8 +1863,6 @@ deserialize_and_upgrade_internal_node(BRTNODE node,
n_in_this_buffer);
assert_zero(r);
}
bnc->n_bytes_in_buffer = n_bytes_in_buffer;
}
// Assign the highest msn from our upgrade message FIFO queues.
......
......@@ -288,7 +288,7 @@ get_node_reactivity (BRTNODE node) {
unsigned int
toku_bnc_nbytesinbuf(NONLEAF_CHILDINFO bnc)
{
return bnc->n_bytes_in_buffer;
return toku_fifo_buffer_size_in_use(bnc->buffer);
}
// return TRUE if the size of the buffers plus the amount of work done is large enough. (But return false if there is nothing to be flushed (the buffers empty)).
......@@ -2024,7 +2024,6 @@ toku_bnc_insert_msg(NONLEAF_CHILDINFO bnc, const void *key, ITEMLEN keylen, cons
//
// This is only exported for tests.
{
int diff = keylen + datalen + KEY_VALUE_OVERHEAD + BRT_CMD_OVERHEAD + xids_get_serialize_size(xids);
long offset;
int r = toku_fifo_enq(bnc->buffer, key, keylen, data, datalen, type, msn, xids, is_fresh, &offset);
assert_zero(r);
......@@ -2044,7 +2043,6 @@ toku_bnc_insert_msg(NONLEAF_CHILDINFO bnc, const void *key, ITEMLEN keylen, cons
} else {
assert(FALSE);
}
bnc->n_bytes_in_buffer += diff;
return r;
}
......@@ -2456,7 +2454,7 @@ toku_bnc_flush_to_child(
logger->live_root_txns);
assert_zero(r);
// take advantage of surrounding mutex, update stats.
size_t buffsize = bnc->n_bytes_in_buffer;
size_t buffsize = toku_fifo_buffer_size_in_use(bnc->buffer);
STATUS_VALUE(BRT_MSG_BYTES_OUT) += buffsize;
// may be misleading if there's a broadcast message in there
STATUS_VALUE(BRT_MSG_BYTES_CURR) -= buffsize;
......
......@@ -148,6 +148,11 @@ void toku_fifo_size_is_stabilized(FIFO fifo) {
}
}
unsigned int toku_fifo_buffer_size_in_use (FIFO fifo) {
return fifo->memory_used;
}
unsigned long toku_fifo_memory_size_in_use(FIFO fifo) {
return sizeof(*fifo)+fifo->memory_used;
}
......
......@@ -65,6 +65,7 @@ int toku_fifo_enq (FIFO, const void *key, ITEMLEN keylen, const void *data, ITEM
// int toku_fifo_peek_cmdstruct (FIFO, BRT_MSG, DBT*, DBT*); // fill in the BRT_MSG, using the two DBTs for the DBT part.
// THIS ONLY REMAINS FOR TESTING, DO NOT USE IT IN CODE
unsigned int toku_fifo_buffer_size_in_use (FIFO fifo);
unsigned long toku_fifo_memory_size_in_use(FIFO fifo); // return how much memory in the fifo holds useful data
unsigned long toku_fifo_memory_footprint(FIFO fifo); // return how much memory the fifo occupies
......@@ -105,6 +106,8 @@ void toku_fifo_clone(FIFO orig_fifo, FIFO* cloned_fifo);
BOOL toku_are_fifos_same(FIFO fifo1, FIFO fifo2);
#if defined(__cplusplus) || defined(__cilkplusplus)
};
#endif
......
......@@ -331,9 +331,6 @@ test_prefetching(void) {
CKERR(r);
// data in the buffers does not matter in this test
BNC(&sn, 0)->n_bytes_in_buffer = 0;
BNC(&sn, 1)->n_bytes_in_buffer = 0;
BNC(&sn, 2)->n_bytes_in_buffer = 0;
//Cleanup:
xids_destroy(&xids_0);
xids_destroy(&xids_123);
......
......@@ -268,8 +268,6 @@ test_serialize_nonleaf(void) {
r = toku_bnc_insert_msg(BNC(&sn, 0), "a", 2, "aval", 5, BRT_NONE, next_dummymsn(), xids_0, true, NULL, string_key_cmp); assert_zero(r);
r = toku_bnc_insert_msg(BNC(&sn, 0), "b", 2, "bval", 5, BRT_NONE, next_dummymsn(), xids_123, false, NULL, string_key_cmp); assert_zero(r);
r = toku_bnc_insert_msg(BNC(&sn, 1), "x", 2, "xval", 5, BRT_NONE, next_dummymsn(), xids_234, true, NULL, string_key_cmp); assert_zero(r);
BNC(&sn, 0)->n_bytes_in_buffer = 2*(BRT_CMD_OVERHEAD+KEY_VALUE_OVERHEAD+2+5) + xids_get_serialize_size(xids_0) + xids_get_serialize_size(xids_123);
BNC(&sn, 1)->n_bytes_in_buffer = 1*(BRT_CMD_OVERHEAD+KEY_VALUE_OVERHEAD+2+5) + xids_get_serialize_size(xids_234);
//Cleanup:
xids_destroy(&xids_0);
xids_destroy(&xids_123);
......
......@@ -224,7 +224,6 @@ test_serialize_nonleaf(int valsize, int nelts, double entropy) {
r = toku_bnc_insert_msg(bnc, &k, sizeof k, buf, valsize, BRT_NONE, next_dummymsn(), xids_123, true, NULL, long_key_cmp); assert_zero(r);
}
bnc->n_bytes_in_buffer = nperchild*(BRT_CMD_OVERHEAD+KEY_VALUE_OVERHEAD+(sizeof k)+valsize+xids_get_serialize_size(xids_123));
if (ck < 7) {
sn.childkeys[ck] = kv_pair_malloc(&k, sizeof k, 0, 0);
sn.totalchildkeylens += sizeof k;
......
......@@ -1225,8 +1225,6 @@ test_serialize_nonleaf(enum brtnode_verify_type bft, BOOL do_clone) {
r = toku_bnc_insert_msg(BNC(&sn, 0), "a", 2, "aval", 5, BRT_NONE, next_dummymsn(), xids_0, true, NULL, string_key_cmp); assert_zero(r);
r = toku_bnc_insert_msg(BNC(&sn, 0), "b", 2, "bval", 5, BRT_NONE, next_dummymsn(), xids_123, false, NULL, string_key_cmp); assert_zero(r);
r = toku_bnc_insert_msg(BNC(&sn, 1), "x", 2, "xval", 5, BRT_NONE, next_dummymsn(), xids_234, true, NULL, string_key_cmp); assert_zero(r);
BNC(&sn, 0)->n_bytes_in_buffer = 2*(BRT_CMD_OVERHEAD+KEY_VALUE_OVERHEAD+2+5) + xids_get_serialize_size(xids_0) + xids_get_serialize_size(xids_123);
BNC(&sn, 1)->n_bytes_in_buffer = 1*(BRT_CMD_OVERHEAD+KEY_VALUE_OVERHEAD+2+5) + xids_get_serialize_size(xids_234);
//Cleanup:
xids_destroy(&xids_0);
xids_destroy(&xids_123);
......
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