Commit b6fe6a31 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

[t:4277] fix clang compilation warning and make orthopush-flush faster

clang complains about a variable-length static array in a struct, this is
nonstandard

decrease the nodesize and bn size of orthopush-flush, this makes it run a
lot faster without losing effectiveness


git-svn-id: file:///svn/toku/tokudb@43465 c7de825b-a66e-492c-adef-691d508d4ae1
parent 01bbb5f8
...@@ -122,7 +122,6 @@ if(BUILD_TESTING) ...@@ -122,7 +122,6 @@ if(BUILD_TESTING)
## some take even longer, with valgrind ## some take even longer, with valgrind
set(extra_long_tests set(extra_long_tests
subblock-test-checksum subblock-test-checksum
orthopush-flush
benchmark-test benchmark-test
) )
set_tests_properties(${extra_long_tests} PROPERTIES TIMEOUT 5400) set_tests_properties(${extra_long_tests} PROPERTIES TIMEOUT 5400)
......
...@@ -65,8 +65,8 @@ rand_bytes_limited(void *dest, int size) ...@@ -65,8 +65,8 @@ rand_bytes_limited(void *dest, int size)
static void static void
insert_random_message(NONLEAF_CHILDINFO bnc, BRT_MSG_S **save, bool *is_fresh_out, XIDS xids, int pfx) insert_random_message(NONLEAF_CHILDINFO bnc, BRT_MSG_S **save, bool *is_fresh_out, XIDS xids, int pfx)
{ {
int keylen = (random() % 1024) + 16; int keylen = (random() % 128) + 16;
int vallen = (random() % 1024) + 16; int vallen = (random() % 128) + 16;
void *key = toku_xmalloc(keylen + (sizeof pfx)); void *key = toku_xmalloc(keylen + (sizeof pfx));
void *val = toku_xmalloc(vallen); void *val = toku_xmalloc(vallen);
*(int *) key = pfx; *(int *) key = pfx;
...@@ -101,21 +101,21 @@ static void ...@@ -101,21 +101,21 @@ static void
insert_random_message_to_leaf(BRT t, BRTNODE leafnode, BASEMENTNODE blb, LEAFENTRY *save, XIDS xids, int pfx) insert_random_message_to_leaf(BRT t, BRTNODE leafnode, BASEMENTNODE blb, LEAFENTRY *save, XIDS xids, int pfx)
{ {
int keylen = (random() % 16) + 16; int keylen = (random() % 16) + 16;
int vallen = (random() % 1024) + 16; int vallen = (random() % 128) + 16;
struct of_pair { uint32_t *pfxp;
int32_t pfx; char key[(sizeof *pfxp) + keylen];
char key[keylen];
} keyp;
char val[vallen]; char val[vallen];
keyp.pfx = pfx; pfxp = (uint32_t *) &key[0];
rand_bytes_limited(&keyp.key, keylen); *pfxp = pfx;
char *randkeyp = &key[sizeof *pfxp];
rand_bytes_limited(randkeyp, keylen);
rand_bytes(val, vallen); rand_bytes(val, vallen);
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
DBT keydbt_s, *keydbt, valdbt_s, *valdbt; DBT keydbt_s, *keydbt, valdbt_s, *valdbt;
keydbt = &keydbt_s; keydbt = &keydbt_s;
valdbt = &valdbt_s; valdbt = &valdbt_s;
toku_fill_dbt(keydbt, &keyp, keylen + (sizeof pfx)); toku_fill_dbt(keydbt, key, (sizeof *pfxp) + keylen);
toku_fill_dbt(valdbt, val, vallen); toku_fill_dbt(valdbt, val, vallen);
BRT_MSG_S msg; BRT_MSG_S msg;
msg.type = BRT_INSERT; msg.type = BRT_INSERT;
...@@ -142,21 +142,21 @@ static void ...@@ -142,21 +142,21 @@ static void
insert_same_message_to_leaves(BRT t, BRTNODE child1, BASEMENTNODE blb1, BRTNODE child2, BASEMENTNODE blb2, LEAFENTRY *save, XIDS xids, int pfx) insert_same_message_to_leaves(BRT t, BRTNODE child1, BASEMENTNODE blb1, BRTNODE child2, BASEMENTNODE blb2, LEAFENTRY *save, XIDS xids, int pfx)
{ {
int keylen = (random() % 16) + 16; int keylen = (random() % 16) + 16;
int vallen = (random() % 1024) + 16; int vallen = (random() % 128) + 16;
struct of_pair { uint32_t *pfxp;
int32_t pfx; char key[(sizeof *pfxp) + keylen];
char key[keylen];
} keyp;
char val[vallen]; char val[vallen];
keyp.pfx = pfx; pfxp = (uint32_t *) &key[0];
rand_bytes_limited(&keyp.key, keylen); *pfxp = pfx;
char *randkeyp = &key[sizeof *pfxp];
rand_bytes_limited(randkeyp, keylen);
rand_bytes(val, vallen); rand_bytes(val, vallen);
MSN msn = next_dummymsn(); MSN msn = next_dummymsn();
DBT keydbt_s, *keydbt, valdbt_s, *valdbt; DBT keydbt_s, *keydbt, valdbt_s, *valdbt;
keydbt = &keydbt_s; keydbt = &keydbt_s;
valdbt = &valdbt_s; valdbt = &valdbt_s;
toku_fill_dbt(keydbt, &keyp, keylen + (sizeof pfx)); toku_fill_dbt(keydbt, key, (sizeof *pfxp) + keylen);
toku_fill_dbt(valdbt, val, vallen); toku_fill_dbt(valdbt, val, vallen);
BRT_MSG_S msg; BRT_MSG_S msg;
msg.type = BRT_INSERT; msg.type = BRT_INSERT;
...@@ -244,12 +244,12 @@ static void ...@@ -244,12 +244,12 @@ static void
flush_to_internal(BRT t) { flush_to_internal(BRT t) {
int r; int r;
BRT_MSG_S **MALLOC_N(128*1024,parent_messages); // 4m / 32 = 128k BRT_MSG_S **MALLOC_N(4096,parent_messages); // 128k / 32 = 4096
BRT_MSG_S **MALLOC_N(128*1024,child_messages); BRT_MSG_S **MALLOC_N(4096,child_messages);
bool *MALLOC_N(128*1024,parent_messages_is_fresh); bool *MALLOC_N(4096,parent_messages_is_fresh);
bool *MALLOC_N(128*1024,child_messages_is_fresh); bool *MALLOC_N(4096,child_messages_is_fresh);
memset(parent_messages_is_fresh, 0, 128*1024*(sizeof parent_messages_is_fresh[0])); memset(parent_messages_is_fresh, 0, 4096*(sizeof parent_messages_is_fresh[0]));
memset(child_messages_is_fresh, 0, 128*1024*(sizeof child_messages_is_fresh[0])); memset(child_messages_is_fresh, 0, 4096*(sizeof child_messages_is_fresh[0]));
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = xids_get_root_xids();
XIDS xids_123, xids_234; XIDS xids_123, xids_234;
...@@ -260,20 +260,20 @@ flush_to_internal(BRT t) { ...@@ -260,20 +260,20 @@ flush_to_internal(BRT t) {
NONLEAF_CHILDINFO child_bnc = toku_create_empty_nl(); NONLEAF_CHILDINFO child_bnc = toku_create_empty_nl();
int i; int i;
for (i = 0; toku_bnc_memory_used(child_bnc) < 4*M; ++i) { for (i = 0; toku_bnc_memory_used(child_bnc) < 128*1024; ++i) {
insert_random_message(child_bnc, &child_messages[i], &child_messages_is_fresh[i], xids_123, 0); insert_random_message(child_bnc, &child_messages[i], &child_messages_is_fresh[i], xids_123, 0);
} }
int num_child_messages = i; int num_child_messages = i;
NONLEAF_CHILDINFO parent_bnc = toku_create_empty_nl(); NONLEAF_CHILDINFO parent_bnc = toku_create_empty_nl();
for (i = 0; toku_bnc_memory_used(parent_bnc) < 4*M; ++i) { for (i = 0; toku_bnc_memory_used(parent_bnc) < 128*1024; ++i) {
insert_random_message(parent_bnc, &parent_messages[i], &parent_messages_is_fresh[i], xids_234, 0); insert_random_message(parent_bnc, &parent_messages[i], &parent_messages_is_fresh[i], xids_234, 0);
} }
int num_parent_messages = i; int num_parent_messages = i;
BRTNODE XMALLOC(child); BRTNODE XMALLOC(child);
BLOCKNUM blocknum = { 42 }; BLOCKNUM blocknum = { 42 };
toku_initialize_empty_brtnode(child, blocknum, 1, 1, BRT_LAYOUT_VERSION, 4*M, 0, my_header); toku_initialize_empty_brtnode(child, blocknum, 1, 1, BRT_LAYOUT_VERSION, 128*1024, 0, my_header);
destroy_nonleaf_childinfo(BNC(child, 0)); destroy_nonleaf_childinfo(BNC(child, 0));
set_BNC(child, 0, child_bnc); set_BNC(child, 0, child_bnc);
BP_STATE(child, 0) = PT_AVAIL; BP_STATE(child, 0) = PT_AVAIL;
...@@ -359,12 +359,12 @@ static void ...@@ -359,12 +359,12 @@ static void
flush_to_internal_multiple(BRT t) { flush_to_internal_multiple(BRT t) {
int r; int r;
BRT_MSG_S **MALLOC_N(128*1024,parent_messages); // 4m / 32 = 128k BRT_MSG_S **MALLOC_N(4096,parent_messages); // 128k / 32 = 4096
BRT_MSG_S **MALLOC_N(128*1024,child_messages); BRT_MSG_S **MALLOC_N(4096,child_messages);
bool *MALLOC_N(128*1024,parent_messages_is_fresh); bool *MALLOC_N(4096,parent_messages_is_fresh);
bool *MALLOC_N(128*1024,child_messages_is_fresh); bool *MALLOC_N(4096,child_messages_is_fresh);
memset(parent_messages_is_fresh, 0, 128*1024*(sizeof parent_messages_is_fresh[0])); memset(parent_messages_is_fresh, 0, 4096*(sizeof parent_messages_is_fresh[0]));
memset(child_messages_is_fresh, 0, 128*1024*(sizeof child_messages_is_fresh[0])); memset(child_messages_is_fresh, 0, 4096*(sizeof child_messages_is_fresh[0]));
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = xids_get_root_xids();
XIDS xids_123, xids_234; XIDS xids_123, xids_234;
...@@ -383,7 +383,7 @@ flush_to_internal_multiple(BRT t) { ...@@ -383,7 +383,7 @@ flush_to_internal_multiple(BRT t) {
} }
} }
int total_size = 0; int total_size = 0;
for (i = 0; total_size < 4*M; ++i) { for (i = 0; total_size < 128*1024; ++i) {
total_size -= toku_bnc_memory_used(child_bncs[i%8]); total_size -= toku_bnc_memory_used(child_bncs[i%8]);
insert_random_message(child_bncs[i%8], &child_messages[i], &child_messages_is_fresh[i], xids_123, i%8); insert_random_message(child_bncs[i%8], &child_messages[i], &child_messages_is_fresh[i], xids_123, i%8);
total_size += toku_bnc_memory_used(child_bncs[i%8]); total_size += toku_bnc_memory_used(child_bncs[i%8]);
...@@ -396,14 +396,14 @@ flush_to_internal_multiple(BRT t) { ...@@ -396,14 +396,14 @@ flush_to_internal_multiple(BRT t) {
int num_child_messages = i; int num_child_messages = i;
NONLEAF_CHILDINFO parent_bnc = toku_create_empty_nl(); NONLEAF_CHILDINFO parent_bnc = toku_create_empty_nl();
for (i = 0; toku_bnc_memory_used(parent_bnc) < 4*M; ++i) { for (i = 0; toku_bnc_memory_used(parent_bnc) < 128*1024; ++i) {
insert_random_message(parent_bnc, &parent_messages[i], &parent_messages_is_fresh[i], xids_234, 0); insert_random_message(parent_bnc, &parent_messages[i], &parent_messages_is_fresh[i], xids_234, 0);
} }
int num_parent_messages = i; int num_parent_messages = i;
BRTNODE XMALLOC(child); BRTNODE XMALLOC(child);
BLOCKNUM blocknum = { 42 }; BLOCKNUM blocknum = { 42 };
toku_initialize_empty_brtnode(child, blocknum, 1, 8, BRT_LAYOUT_VERSION, 4*M, 0, my_header); toku_initialize_empty_brtnode(child, blocknum, 1, 8, BRT_LAYOUT_VERSION, 128*1024, 0, my_header);
for (i = 0; i < 8; ++i) { for (i = 0; i < 8; ++i) {
destroy_nonleaf_childinfo(BNC(child, i)); destroy_nonleaf_childinfo(BNC(child, i));
set_BNC(child, i, child_bncs[i]); set_BNC(child, i, child_bncs[i]);
...@@ -508,12 +508,12 @@ static void ...@@ -508,12 +508,12 @@ static void
flush_to_leaf(BRT t, bool make_leaf_up_to_date, bool use_flush) { flush_to_leaf(BRT t, bool make_leaf_up_to_date, bool use_flush) {
int r; int r;
BRT_MSG_S **MALLOC_N(128*1024,parent_messages); // 4m / 32 = 128k BRT_MSG_S **MALLOC_N(4096,parent_messages); // 128k / 32 = 4096
LEAFENTRY *MALLOC_N(128*1024,child_messages); LEAFENTRY *MALLOC_N(4096,child_messages);
bool *MALLOC_N(128*1024,parent_messages_is_fresh); bool *MALLOC_N(4096,parent_messages_is_fresh);
memset(parent_messages_is_fresh, 0, 128*1024*(sizeof parent_messages_is_fresh[0])); memset(parent_messages_is_fresh, 0, 4096*(sizeof parent_messages_is_fresh[0]));
int *MALLOC_N(128*1024,parent_messages_applied); int *MALLOC_N(4096,parent_messages_applied);
memset(parent_messages_applied, 0, 128*1024*(sizeof parent_messages_applied[0])); memset(parent_messages_applied, 0, 4096*(sizeof parent_messages_applied[0]));
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = xids_get_root_xids();
XIDS xids_123, xids_234; XIDS xids_123, xids_234;
...@@ -534,7 +534,7 @@ flush_to_leaf(BRT t, bool make_leaf_up_to_date, bool use_flush) { ...@@ -534,7 +534,7 @@ flush_to_leaf(BRT t, bool make_leaf_up_to_date, bool use_flush) {
BRTNODE XMALLOC(child); BRTNODE XMALLOC(child);
BLOCKNUM blocknum = { 42 }; BLOCKNUM blocknum = { 42 };
toku_initialize_empty_brtnode(child, blocknum, 0, 8, BRT_LAYOUT_VERSION, 4*M, 0, my_header); toku_initialize_empty_brtnode(child, blocknum, 0, 8, BRT_LAYOUT_VERSION, 128*1024, 0, my_header);
for (i = 0; i < 8; ++i) { for (i = 0; i < 8; ++i) {
destroy_basement_node(BLB(child, i)); destroy_basement_node(BLB(child, i));
set_BLB(child, i, child_blbs[i]); set_BLB(child, i, child_blbs[i]);
...@@ -542,7 +542,7 @@ flush_to_leaf(BRT t, bool make_leaf_up_to_date, bool use_flush) { ...@@ -542,7 +542,7 @@ flush_to_leaf(BRT t, bool make_leaf_up_to_date, bool use_flush) {
} }
int total_size = 0; int total_size = 0;
for (i = 0; total_size < 4*M; ++i) { for (i = 0; total_size < 128*1024; ++i) {
total_size -= child_blbs[i%8]->n_bytes_in_buffer; total_size -= child_blbs[i%8]->n_bytes_in_buffer;
insert_random_message_to_leaf(t, child, child_blbs[i%8], &child_messages[i], xids_123, i%8); insert_random_message_to_leaf(t, child, child_blbs[i%8], &child_messages[i], xids_123, i%8);
total_size += child_blbs[i%8]->n_bytes_in_buffer; total_size += child_blbs[i%8]->n_bytes_in_buffer;
...@@ -567,12 +567,12 @@ flush_to_leaf(BRT t, bool make_leaf_up_to_date, bool use_flush) { ...@@ -567,12 +567,12 @@ flush_to_leaf(BRT t, bool make_leaf_up_to_date, bool use_flush) {
} }
{ {
int num_stale = random() % 10000; int num_stale = random() % 2000;
memset(&parent_messages_is_fresh[num_stale], true, (128*1024 - num_stale) * (sizeof parent_messages_is_fresh[0])); memset(&parent_messages_is_fresh[num_stale], true, (4096 - num_stale) * (sizeof parent_messages_is_fresh[0]));
} }
NONLEAF_CHILDINFO parent_bnc = toku_create_empty_nl(); NONLEAF_CHILDINFO parent_bnc = toku_create_empty_nl();
MSN max_parent_msn = MIN_MSN; MSN max_parent_msn = MIN_MSN;
for (i = 0; toku_bnc_memory_used(parent_bnc) < 4*M; ++i) { for (i = 0; toku_bnc_memory_used(parent_bnc) < 128*1024; ++i) {
insert_random_update_message(parent_bnc, &parent_messages[i], parent_messages_is_fresh[i], xids_234, i%8, &parent_messages_applied[i], &max_parent_msn); insert_random_update_message(parent_bnc, &parent_messages[i], parent_messages_is_fresh[i], xids_234, i%8, &parent_messages_applied[i], &max_parent_msn);
} }
int num_parent_messages = i; int num_parent_messages = i;
...@@ -610,7 +610,7 @@ flush_to_leaf(BRT t, bool make_leaf_up_to_date, bool use_flush) { ...@@ -610,7 +610,7 @@ flush_to_leaf(BRT t, bool make_leaf_up_to_date, bool use_flush) {
} else { } else {
BRTNODE XMALLOC(parentnode); BRTNODE XMALLOC(parentnode);
BLOCKNUM parentblocknum = { 17 }; BLOCKNUM parentblocknum = { 17 };
toku_initialize_empty_brtnode(parentnode, parentblocknum, 1, 1, BRT_LAYOUT_VERSION, 4*M, 0, my_header); toku_initialize_empty_brtnode(parentnode, parentblocknum, 1, 1, BRT_LAYOUT_VERSION, 128*1024, 0, my_header);
destroy_nonleaf_childinfo(BNC(parentnode, 0)); destroy_nonleaf_childinfo(BNC(parentnode, 0));
set_BNC(parentnode, 0, parent_bnc); set_BNC(parentnode, 0, parent_bnc);
BP_STATE(parentnode, 0) = PT_AVAIL; BP_STATE(parentnode, 0) = PT_AVAIL;
...@@ -737,12 +737,12 @@ static void ...@@ -737,12 +737,12 @@ static void
flush_to_leaf_with_keyrange(BRT t, bool make_leaf_up_to_date) { flush_to_leaf_with_keyrange(BRT t, bool make_leaf_up_to_date) {
int r; int r;
BRT_MSG_S **MALLOC_N(128*1024,parent_messages); // 4m / 32 = 128k BRT_MSG_S **MALLOC_N(4096,parent_messages); // 128k / 32 = 4k
LEAFENTRY *MALLOC_N(128*1024,child_messages); LEAFENTRY *MALLOC_N(4096,child_messages);
bool *MALLOC_N(128*1024,parent_messages_is_fresh); bool *MALLOC_N(4096,parent_messages_is_fresh);
memset(parent_messages_is_fresh, 0, 128*1024*(sizeof parent_messages_is_fresh[0])); memset(parent_messages_is_fresh, 0, 4096*(sizeof parent_messages_is_fresh[0]));
int *MALLOC_N(128*1024,parent_messages_applied); int *MALLOC_N(4096,parent_messages_applied);
memset(parent_messages_applied, 0, 128*1024*(sizeof parent_messages_applied[0])); memset(parent_messages_applied, 0, 4096*(sizeof parent_messages_applied[0]));
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = xids_get_root_xids();
XIDS xids_123, xids_234; XIDS xids_123, xids_234;
...@@ -761,7 +761,7 @@ flush_to_leaf_with_keyrange(BRT t, bool make_leaf_up_to_date) { ...@@ -761,7 +761,7 @@ flush_to_leaf_with_keyrange(BRT t, bool make_leaf_up_to_date) {
BRTNODE XMALLOC(child); BRTNODE XMALLOC(child);
BLOCKNUM blocknum = { 42 }; BLOCKNUM blocknum = { 42 };
toku_initialize_empty_brtnode(child, blocknum, 0, 8, BRT_LAYOUT_VERSION, 4*M, 0, my_header); toku_initialize_empty_brtnode(child, blocknum, 0, 8, BRT_LAYOUT_VERSION, 128*1024, 0, my_header);
for (i = 0; i < 8; ++i) { for (i = 0; i < 8; ++i) {
destroy_basement_node(BLB(child, i)); destroy_basement_node(BLB(child, i));
set_BLB(child, i, child_blbs[i]); set_BLB(child, i, child_blbs[i]);
...@@ -769,7 +769,7 @@ flush_to_leaf_with_keyrange(BRT t, bool make_leaf_up_to_date) { ...@@ -769,7 +769,7 @@ flush_to_leaf_with_keyrange(BRT t, bool make_leaf_up_to_date) {
} }
int total_size = 0; int total_size = 0;
for (i = 0; total_size < 4*M; ++i) { for (i = 0; total_size < 128*1024; ++i) {
total_size -= child_blbs[i%8]->n_bytes_in_buffer; total_size -= child_blbs[i%8]->n_bytes_in_buffer;
insert_random_message_to_leaf(t, child, child_blbs[i%8], &child_messages[i], xids_123, i%8); insert_random_message_to_leaf(t, child, child_blbs[i%8], &child_messages[i], xids_123, i%8);
total_size += child_blbs[i%8]->n_bytes_in_buffer; total_size += child_blbs[i%8]->n_bytes_in_buffer;
...@@ -790,12 +790,12 @@ flush_to_leaf_with_keyrange(BRT t, bool make_leaf_up_to_date) { ...@@ -790,12 +790,12 @@ flush_to_leaf_with_keyrange(BRT t, bool make_leaf_up_to_date) {
} }
{ {
int num_stale = random() % 10000; int num_stale = random() % 2000;
memset(&parent_messages_is_fresh[num_stale], true, (128*1024 - num_stale) * (sizeof parent_messages_is_fresh[0])); memset(&parent_messages_is_fresh[num_stale], true, (4096 - num_stale) * (sizeof parent_messages_is_fresh[0]));
} }
NONLEAF_CHILDINFO parent_bnc = toku_create_empty_nl(); NONLEAF_CHILDINFO parent_bnc = toku_create_empty_nl();
MSN max_parent_msn = MIN_MSN; MSN max_parent_msn = MIN_MSN;
for (i = 0; toku_bnc_memory_used(parent_bnc) < 4*M; ++i) { for (i = 0; toku_bnc_memory_used(parent_bnc) < 128*1024; ++i) {
insert_random_update_message(parent_bnc, &parent_messages[i], parent_messages_is_fresh[i], xids_234, i%8, &parent_messages_applied[i], &max_parent_msn); insert_random_update_message(parent_bnc, &parent_messages[i], parent_messages_is_fresh[i], xids_234, i%8, &parent_messages_applied[i], &max_parent_msn);
} }
int num_parent_messages = i; int num_parent_messages = i;
...@@ -821,7 +821,9 @@ flush_to_leaf_with_keyrange(BRT t, bool make_leaf_up_to_date) { ...@@ -821,7 +821,9 @@ flush_to_leaf_with_keyrange(BRT t, bool make_leaf_up_to_date) {
} }
for (i = 0; i < num_parent_messages; ++i) { for (i = 0; i < num_parent_messages; ++i) {
if (make_leaf_up_to_date && !parent_messages_is_fresh[i]) { if (make_leaf_up_to_date &&
dummy_cmp(NULL, parent_messages[i]->u.id.key, &childkeys[7]) <= 0 &&
!parent_messages_is_fresh[i]) {
assert(parent_messages_applied[i] == 1); assert(parent_messages_applied[i] == 1);
} else { } else {
assert(parent_messages_applied[i] == 0); assert(parent_messages_applied[i] == 0);
...@@ -830,7 +832,7 @@ flush_to_leaf_with_keyrange(BRT t, bool make_leaf_up_to_date) { ...@@ -830,7 +832,7 @@ flush_to_leaf_with_keyrange(BRT t, bool make_leaf_up_to_date) {
BRTNODE XMALLOC(parentnode); BRTNODE XMALLOC(parentnode);
BLOCKNUM parentblocknum = { 17 }; BLOCKNUM parentblocknum = { 17 };
toku_initialize_empty_brtnode(parentnode, parentblocknum, 1, 1, BRT_LAYOUT_VERSION, 4*M, 0, my_header); toku_initialize_empty_brtnode(parentnode, parentblocknum, 1, 1, BRT_LAYOUT_VERSION, 128*1024, 0, my_header);
destroy_nonleaf_childinfo(BNC(parentnode, 0)); destroy_nonleaf_childinfo(BNC(parentnode, 0));
set_BNC(parentnode, 0, parent_bnc); set_BNC(parentnode, 0, parent_bnc);
BP_STATE(parentnode, 0) = PT_AVAIL; BP_STATE(parentnode, 0) = PT_AVAIL;
...@@ -910,12 +912,12 @@ static void ...@@ -910,12 +912,12 @@ static void
compare_apply_and_flush(BRT t, bool make_leaf_up_to_date) { compare_apply_and_flush(BRT t, bool make_leaf_up_to_date) {
int r; int r;
BRT_MSG_S **MALLOC_N(128*1024,parent_messages); // 4m / 32 = 128k BRT_MSG_S **MALLOC_N(4096,parent_messages); // 128k / 32 = 4k
LEAFENTRY *MALLOC_N(128*1024,child_messages); LEAFENTRY *MALLOC_N(4096,child_messages);
bool *MALLOC_N(128*1024,parent_messages_is_fresh); bool *MALLOC_N(4096,parent_messages_is_fresh);
memset(parent_messages_is_fresh, 0, 128*1024*(sizeof parent_messages_is_fresh[0])); memset(parent_messages_is_fresh, 0, 4096*(sizeof parent_messages_is_fresh[0]));
int *MALLOC_N(128*1024,parent_messages_applied); int *MALLOC_N(4096,parent_messages_applied);
memset(parent_messages_applied, 0, 128*1024*(sizeof parent_messages_applied[0])); memset(parent_messages_applied, 0, 4096*(sizeof parent_messages_applied[0]));
XIDS xids_0 = xids_get_root_xids(); XIDS xids_0 = xids_get_root_xids();
XIDS xids_123, xids_234; XIDS xids_123, xids_234;
...@@ -938,8 +940,8 @@ compare_apply_and_flush(BRT t, bool make_leaf_up_to_date) { ...@@ -938,8 +940,8 @@ compare_apply_and_flush(BRT t, bool make_leaf_up_to_date) {
BRTNODE XMALLOC(child1), XMALLOC(child2); BRTNODE XMALLOC(child1), XMALLOC(child2);
BLOCKNUM blocknum = { 42 }; BLOCKNUM blocknum = { 42 };
toku_initialize_empty_brtnode(child1, blocknum, 0, 8, BRT_LAYOUT_VERSION, 4*M, 0, my_header); toku_initialize_empty_brtnode(child1, blocknum, 0, 8, BRT_LAYOUT_VERSION, 128*1024, 0, my_header);
toku_initialize_empty_brtnode(child2, blocknum, 0, 8, BRT_LAYOUT_VERSION, 4*M, 0, my_header); toku_initialize_empty_brtnode(child2, blocknum, 0, 8, BRT_LAYOUT_VERSION, 128*1024, 0, my_header);
for (i = 0; i < 8; ++i) { for (i = 0; i < 8; ++i) {
destroy_basement_node(BLB(child1, i)); destroy_basement_node(BLB(child1, i));
set_BLB(child1, i, child1_blbs[i]); set_BLB(child1, i, child1_blbs[i]);
...@@ -950,7 +952,7 @@ compare_apply_and_flush(BRT t, bool make_leaf_up_to_date) { ...@@ -950,7 +952,7 @@ compare_apply_and_flush(BRT t, bool make_leaf_up_to_date) {
} }
int total_size = 0; int total_size = 0;
for (i = 0; total_size < 4*M; ++i) { for (i = 0; total_size < 128*1024; ++i) {
total_size -= child1_blbs[i%8]->n_bytes_in_buffer; total_size -= child1_blbs[i%8]->n_bytes_in_buffer;
insert_same_message_to_leaves(t, child1, child1_blbs[i%8], child2, child2_blbs[i%8], &child_messages[i], xids_123, i%8); insert_same_message_to_leaves(t, child1, child1_blbs[i%8], child2, child2_blbs[i%8], &child_messages[i], xids_123, i%8);
total_size += child1_blbs[i%8]->n_bytes_in_buffer; total_size += child1_blbs[i%8]->n_bytes_in_buffer;
...@@ -977,12 +979,12 @@ compare_apply_and_flush(BRT t, bool make_leaf_up_to_date) { ...@@ -977,12 +979,12 @@ compare_apply_and_flush(BRT t, bool make_leaf_up_to_date) {
} }
{ {
int num_stale = random() % 10000; int num_stale = random() % 2000;
memset(&parent_messages_is_fresh[num_stale], true, (128*1024 - num_stale) * (sizeof parent_messages_is_fresh[0])); memset(&parent_messages_is_fresh[num_stale], true, (4096 - num_stale) * (sizeof parent_messages_is_fresh[0]));
} }
NONLEAF_CHILDINFO parent_bnc = toku_create_empty_nl(); NONLEAF_CHILDINFO parent_bnc = toku_create_empty_nl();
MSN max_parent_msn = MIN_MSN; MSN max_parent_msn = MIN_MSN;
for (i = 0; toku_bnc_memory_used(parent_bnc) < 4*M; ++i) { for (i = 0; toku_bnc_memory_used(parent_bnc) < 128*1024; ++i) {
insert_random_update_message(parent_bnc, &parent_messages[i], parent_messages_is_fresh[i], xids_234, i%8, &parent_messages_applied[i], &max_parent_msn); insert_random_update_message(parent_bnc, &parent_messages[i], parent_messages_is_fresh[i], xids_234, i%8, &parent_messages_applied[i], &max_parent_msn);
} }
int num_parent_messages = i; int num_parent_messages = i;
...@@ -1014,7 +1016,7 @@ compare_apply_and_flush(BRT t, bool make_leaf_up_to_date) { ...@@ -1014,7 +1016,7 @@ compare_apply_and_flush(BRT t, bool make_leaf_up_to_date) {
BRTNODE XMALLOC(parentnode); BRTNODE XMALLOC(parentnode);
BLOCKNUM parentblocknum = { 17 }; BLOCKNUM parentblocknum = { 17 };
toku_initialize_empty_brtnode(parentnode, parentblocknum, 1, 1, BRT_LAYOUT_VERSION, 4*M, 0, my_header); toku_initialize_empty_brtnode(parentnode, parentblocknum, 1, 1, BRT_LAYOUT_VERSION, 128*1024, 0, my_header);
destroy_nonleaf_childinfo(BNC(parentnode, 0)); destroy_nonleaf_childinfo(BNC(parentnode, 0));
set_BNC(parentnode, 0, parent_bnc); set_BNC(parentnode, 0, parent_bnc);
BP_STATE(parentnode, 0) = PT_AVAIL; BP_STATE(parentnode, 0) = PT_AVAIL;
...@@ -1094,8 +1096,6 @@ compare_apply_and_flush(BRT t, bool make_leaf_up_to_date) { ...@@ -1094,8 +1096,6 @@ compare_apply_and_flush(BRT t, bool make_leaf_up_to_date) {
toku_free(parent_messages_applied); toku_free(parent_messages_applied);
} }
static int slow = 0;
static void static void
parse_args(int argc, const char *argv[]) { parse_args(int argc, const char *argv[]) {
const char *progname=argv[0]; const char *progname=argv[0];
...@@ -1105,8 +1105,6 @@ parse_args(int argc, const char *argv[]) { ...@@ -1105,8 +1105,6 @@ parse_args(int argc, const char *argv[]) {
verbose=1; verbose=1;
} else if (strcmp(argv[0],"-q")==0) { } else if (strcmp(argv[0],"-q")==0) {
verbose=0; verbose=0;
} else if (strcmp(argv[0],"--slow")==0) {
slow=1;
} else { } else {
fprintf(stderr, "Usage:\n %s [-v] [-q]\n", progname); fprintf(stderr, "Usage:\n %s [-v] [-q]\n", progname);
exit(1); exit(1);
...@@ -1126,20 +1124,9 @@ test_main (int argc, const char *argv[]) { ...@@ -1126,20 +1124,9 @@ test_main (int argc, const char *argv[]) {
assert(r==0); assert(r==0);
unlink(fname); unlink(fname);
BRT t; BRT t;
r = toku_open_brt(fname, 1, &t, 4*M, 64*1024, ct, null_txn, toku_builtin_compare_fun); assert(r==0); r = toku_open_brt(fname, 1, &t, 128*1024, 4096, ct, null_txn, toku_builtin_compare_fun); assert(r==0);
r = toku_brt_set_update(t, orthopush_flush_update_fun); assert(r==0); r = toku_brt_set_update(t, orthopush_flush_update_fun); assert(r==0);
// normally, just check a few things, but if --slow is provided, then
// be thorough about it and repeat tests (since they're randomized)
if (!slow) {;
flush_to_internal(t);
flush_to_internal_multiple(t);
flush_to_leaf(t, true, false);
flush_to_leaf_with_keyrange(t, false);
flush_to_leaf_with_keyrange(t, true);
compare_apply_and_flush(t, false);
compare_apply_and_flush(t, true);
} else {
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
flush_to_internal(t); flush_to_internal(t);
} }
...@@ -1158,7 +1145,6 @@ test_main (int argc, const char *argv[]) { ...@@ -1158,7 +1145,6 @@ test_main (int argc, const char *argv[]) {
compare_apply_and_flush(t, false); compare_apply_and_flush(t, false);
compare_apply_and_flush(t, true); compare_apply_and_flush(t, true);
} }
}
r = toku_close_brt_nolsn(t, 0); assert(r==0); r = toku_close_brt_nolsn(t, 0); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==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