📄 tsrecv97.c
字号:
return(0);}/*********************************************************************Another test for inserts. */ulinttest2_2(/*====*/ void* arg){ ulint tm, oldtm; sess_t* sess; com_endpoint_t* com_endpoint; mem_heap_t* heap; que_fork_t* fork; dict_table_t* table; dict_index_t* index; dict_tree_t* tree; que_thr_t* thr; trx_t* trx; ulint i; ulint rnd; dtuple_t* row; dtuple_t* entry; byte buf[100]; ulint count = 0; ins_node_t* node; btr_pcur_t pcur; mtr_t mtr; printf("-------------------------------------------------\n"); printf("TEST 2.2. MASSIVE DESCENDING INSERT\n"); heap = mem_heap_create(512); com_endpoint = (com_endpoint_t*)heap; /* This is a dummy non-NULL value */ mutex_enter(&kernel_mutex); sess = sess_open(ut_dulint_zero, com_endpoint, (byte*)"user1", 6); trx = sess->trx; mutex_exit(&kernel_mutex);loop: ut_a(trx_start(trx, ULINT_UNDEFINED)); /*-------------------------------------*/ /* MASSIVE INSERT */ fork = que_fork_create(NULL, NULL, QUE_FORK_INSERT, heap); fork->trx = trx; thr = que_thr_create(fork, fork, heap); table = dict_table_get("TS_TABLE1", trx); row = dtuple_create(heap, 3 + DATA_N_SYS_COLS); dict_table_copy_types(row, table); node = ins_node_create(fork, thr, row, table, heap); thr->child = node; row_ins_init_sys_fields_at_sql_compile(node->row, node->table, heap); row_ins_init_sys_fields_at_sql_prepare(node->row, node->table, trx); node->init_all_sys_fields = FALSE; mutex_enter(&kernel_mutex); que_graph_publish(fork, trx->sess); trx->graph = fork; mutex_exit(&kernel_mutex); rnd = *((ulint*)arg) + 1; oldtm = ut_clock(); for (i = 0; i < *((ulint*)arg); i++) { rnd = (rnd - 1) % 200000; dtuple_gen_test_tuple3(row, rnd, DTUPLE_TEST_FIXED30, buf); mutex_enter(&kernel_mutex); ut_a( thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0)); mutex_exit(&kernel_mutex); que_run_threads(thr); if (i % 1000 == 0) {/* printf( "********************************Inserted %lu rows\n", i); ibuf_print(); */ } } tm = ut_clock(); printf("Wall time for %lu inserts %lu milliseconds\n", i, tm - oldtm); /* Check inserted entries */ entry = dtuple_create(heap, 1); dtuple_gen_search_tuple3(entry, 0, buf); mtr_start(&mtr); index = dict_table_get_first_index(table); tree = dict_index_get_tree(index); btr_pcur_open(index, entry, PAGE_CUR_L, BTR_SEARCH_LEAF, &pcur, &mtr); ut_a(btr_pcur_is_before_first_in_tree(&pcur, &mtr)); for (i = 0; i < *((ulint*)arg); i++) { ut_a(btr_pcur_move_to_next(&pcur, &mtr)); dtuple_gen_search_tuple3(entry, i + 1, buf); ut_a(0 == cmp_dtuple_rec(entry, btr_pcur_get_rec(&pcur))); } ut_a(!btr_pcur_move_to_next(&pcur, &mtr)); ut_a(btr_pcur_is_after_last_in_tree(&pcur, &mtr)); btr_pcur_close(&pcur); mtr_commit(&mtr); btr_validate_tree(tree);/* dict_table_print_by_name("TS_TABLE1"); */ /*-------------------------------------*/ /* ROLLBACK */ fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap); fork->trx = trx; thr = que_thr_create(fork, fork, heap); thr->child = roll_node_create(fork, thr, heap); mutex_enter(&kernel_mutex); que_graph_publish(fork, trx->sess); trx->graph = fork; ut_a(thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0)); mutex_exit(&kernel_mutex); oldtm = ut_clock(); que_run_threads(thr); tm = ut_clock(); printf("Wall time for rollback of %lu inserts %lu milliseconds\n", i, tm - oldtm); os_thread_sleep(1000000); dtuple_gen_search_tuple3(entry, 0, buf); mtr_start(&mtr); btr_pcur_open(index, entry, PAGE_CUR_L, BTR_SEARCH_LEAF, &pcur, &mtr); ut_a(btr_pcur_is_before_first_in_tree(&pcur, &mtr)); ut_a(!btr_pcur_move_to_next(&pcur, &mtr)); ut_a(btr_pcur_is_after_last_in_tree(&pcur, &mtr)); btr_pcur_close(&pcur); mtr_commit(&mtr); /*-------------------------------------*/#ifdef notdefined /* COMMIT */ fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap); fork->trx = trx; thr = que_thr_create(fork, fork, heap); thr->child = commit_node_create(fork, thr, heap); mutex_enter(&kernel_mutex); que_graph_publish(fork, trx->sess); trx->graph = fork; ut_a(thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0)); mutex_exit(&kernel_mutex); oldtm = ut_clock(); que_run_threads(thr); tm = ut_clock(); printf("Wall time for commit %lu milliseconds\n", tm - oldtm);#endif /*-------------------------------------*/ count++; if (count < 1) { goto loop; } btr_validate_tree(tree); mem_heap_free(heap); return(0);}/*********************************************************************Multithreaded test for random inserts. */ulinttest2mt(/*====*/ void* arg){ ulint tm, oldtm; sess_t* sess; com_endpoint_t* com_endpoint; mem_heap_t* heap; que_fork_t* fork; dict_table_t* table; dict_index_t* index; dict_tree_t* tree; que_thr_t* thr; trx_t* trx; ulint i; ulint rnd; dtuple_t* row; byte buf[100]; ulint count = 0; ins_node_t* node; printf("-------------------------------------------------\n"); printf("TEST 2MT. MULTITHREADED RANDOM INSERT\n"); heap = mem_heap_create(512); com_endpoint = (com_endpoint_t*)heap; /* This is a dummy non-NULL value */ mutex_enter(&kernel_mutex); sess = sess_open(ut_dulint_zero, com_endpoint, (byte*)"user1", 6); trx = sess->trx; mutex_exit(&kernel_mutex); rnd = 78675;loop: ut_a(trx_start(trx, ULINT_UNDEFINED)); /*-------------------------------------*/ /* MASSIVE INSERT */ fork = que_fork_create(NULL, NULL, QUE_FORK_INSERT, heap); fork->trx = trx; thr = que_thr_create(fork, fork, heap); table = dict_table_get("TS_TABLE1", trx); row = dtuple_create(heap, 3 + DATA_N_SYS_COLS); dict_table_copy_types(row, table); node = ins_node_create(fork, thr, row, table, heap); thr->child = node; row_ins_init_sys_fields_at_sql_compile(node->row, node->table, heap); row_ins_init_sys_fields_at_sql_prepare(node->row, node->table, trx); node->init_all_sys_fields = FALSE; mutex_enter(&kernel_mutex); que_graph_publish(fork, trx->sess); trx->graph = fork; mutex_exit(&kernel_mutex); oldtm = ut_clock(); for (i = 0; i < *((ulint*)arg); i++) { if (i % 100 == 0) {/* buf_print(); *//* ibuf_print(); */ } rnd = (rnd + 7857641) % 500; dtuple_gen_test_tuple3(row, rnd, DTUPLE_TEST_FIXED30, buf); mutex_enter(&kernel_mutex); ut_a( thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0)); mutex_exit(&kernel_mutex); que_run_threads(thr); } tm = ut_clock(); printf("Wall time for %lu inserts %lu milliseconds\n", i, tm - oldtm); index = dict_table_get_first_index(table); tree = dict_index_get_tree(index); printf("Validating tree\n"); btr_validate_tree(tree); printf("Validated\n"); /*-------------------------------------*/ /* ROLLBACK */ fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap); fork->trx = trx; thr = que_thr_create(fork, fork, heap); thr->child = roll_node_create(fork, thr, heap); mutex_enter(&kernel_mutex); que_graph_publish(fork, trx->sess); trx->graph = fork; ut_a(thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0)); mutex_exit(&kernel_mutex); oldtm = ut_clock(); que_run_threads(thr); tm = ut_clock(); printf("Wall time for rollback of %lu inserts %lu milliseconds\n", i, tm - oldtm); os_thread_sleep(3000000); /*-------------------------------------*/#ifdef notdefined /* COMMIT */ fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap); fork->trx = trx; thr = que_thr_create(fork, fork, heap); thr->child = commit_node_create(fork, thr, heap); mutex_enter(&kernel_mutex); que_graph_publish(fork, trx->sess); trx->graph = fork; ut_a(thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0)); mutex_exit(&kernel_mutex); oldtm = ut_clock(); que_run_threads(thr); tm = ut_clock(); printf("Wall time for commit %lu milliseconds\n", tm - oldtm);#endif /*-------------------------------------*/ count++; if (count < COUNT) { goto loop; } return(0);}/*********************************************************************Test for multithreaded sequential inserts. */ulinttest2_1mt(/*======*/ void* arg){ ulint tm, oldtm; sess_t* sess; com_endpoint_t* com_endpoint; mem_heap_t* heap; que_fork_t* fork; dict_table_t* table; dict_index_t* index; dict_tree_t* tree; que_thr_t* thr; trx_t* trx; ulint i; ulint rnd; dtuple_t* row; byte buf[100]; ulint count = 0; ins_node_t* node; printf("-------------------------------------------------\n"); printf("TEST 2.1MT. MULTITHREADED ASCENDING INSERT\n"); rnd = 8757677; heap = mem_heap_create(512); com_endpoint = (com_endpoint_t*)heap; /* This is a dummy non-NULL value */ mutex_enter(&kernel_mutex); sess = sess_open(ut_dulint_zero, com_endpoint, (byte*)"user1", 6); trx = sess->trx; mutex_exit(&kernel_mutex);loop: ut_a(trx_start(trx, ULINT_UNDEFINED)); /*-------------------------------------*/ /* MASSIVE INSERT */ fork = que_fork_create(NULL, NULL, QUE_FORK_INSERT, heap); fork->trx = trx; thr = que_thr_create(fork, fork, heap); table = dict_table_get("TS_TABLE1", trx); row = dtuple_create(heap, 3 + DATA_N_SYS_COLS); dict_table_copy_types(row, table); node = ins_node_create(fork, thr, row, table, heap); thr->child = node; row_ins_init_sys_fields_at_sql_compile(node->row, node->table, heap); row_ins_init_sys_fields_at_sql_prepare(node->row, node->table, trx); node->init_all_sys_fields = FALSE; mutex_enter(&kernel_mutex); que_graph_publish(fork, trx->sess); trx->graph = fork; mutex_exit(&kernel_mutex); oldtm = ut_clock(); rnd += 98667501; for (i = 0; i < *((ulint*)arg); i++) { rnd = (rnd + 1) % 500; dtuple_gen_test_tuple3(row, rnd, DTUPLE_TEST_FIXED30, buf); mutex_enter(&kernel_mutex); ut_a( thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0)); mutex_exit(&kernel_mutex); que_run_threads(thr); } tm = ut_clock(); printf("Wall time for %lu inserts %lu milliseconds\n", i, tm - oldtm); /*-------------------------------------*/ /* ROLLBACK */ fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap); fork->trx = trx; thr = que_thr_create(fork, fork, heap); thr->child = roll_node_create(fork, thr, heap); mutex_enter(&kernel_mutex); que_graph_publish(fork, trx->sess); trx->graph = fork; ut_a(thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0)); mutex_exit(&kernel_mutex); oldtm = ut_clock(); que_run_threads(thr); tm = ut_clock(); printf("Wall time for rollback of %lu inserts %lu milliseconds\n", i, tm - oldtm); os_thread_sleep(3000000); index = dict_table_get_first_index(table); tree = dict_index_get_tree(index); printf("Validating tree\n"); btr_validate_tree(tree); printf("Validated\n"); /*-------------------------------------*/#ifdef notdefined /* COMMIT */ fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap); fork->trx = trx; thr = que_thr_create(fork, fork, heap); thr->child = commit_node_create(fork, thr, heap); mutex_enter(&kernel_mutex); que_graph_publish(fork, trx->sess); trx->graph = fork; ut_a(thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0)); mutex_exit(&kernel_mutex); oldtm = ut_clock(); que_run_threads(thr); tm = ut_clock(); printf("Wall time for commit %lu milliseconds\n", tm - oldtm);#endif /*-------------------------------------*/ count++; if (count < COUNT) { goto loop; } return(0);}/*********************************************************************Test for multithreaded sequential inserts. */ulinttest2_2mt(/*======*/ void* arg){ ulint tm, oldtm; sess_t* sess; com_endpoint_t* com_endpoint; mem_heap_t* heap; que_fork_t* fork; dict_table_t* table; que_thr_t* thr; trx_t* trx; ulint i; ulint rnd; dtuple_t* row; byte buf[100]; ulint count = 0; ins_node_t* node; printf("-------------------------------------------------\n"); printf("TEST 2.2MT. MULTITHREADED DESCENDING INSERT\n"); rnd = 87677; heap = mem_heap_create(512); com_endpoint = (com_endpoint_t*)heap; /* This is a dummy non-NULL value */ mutex_enter(&kernel_mutex); sess = sess_open(ut_dulint_zero, com_endpoint, (byte*)"user1", 6); trx = sess->trx; mutex_exit(&kernel_mutex);loop: ut_a(trx_start(trx, ULINT_UNDEFINED)); /*-------------------------------------*/ /* MASSIVE INSERT */ fork = que_fork_create(NULL, NULL, QUE_FORK_INSERT, heap); fork->trx = trx; thr = que_thr_create(fork, fork, heap); table = dict_table_get("TS_TABLE1", trx); row = dtuple_create(heap, 3 + DATA_N_SYS_COLS); dict_table_copy_types(row, table); node = ins_node_create(fork, thr, row, table, heap); thr->child = node; row_ins_init_sys_fields_at_sql_compile(node->row, node->table, heap); row_ins_init_sys_fields_at_sql_prepare(node->row, node->table, trx); node->init_all_sys_fields = FALSE; mutex_enter(&kernel_mutex);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -