1
/************************************************************************
2
The test for the index page
4
(c) 1994-1996 Innobase Oy
6
Created 1/31/1994 Heikki Tuuri
7
*************************************************************************/
12
#include "data0data.h"
13
#include "data0type.h"
14
#include "dict0dict.h"
22
#include "..\page0page.h"
23
#include "..\page0cur.h"
25
os_file_t files[1000];
38
#define FILE_SIZE 1000 /* must be > 512 */
39
#define POOL_SIZE 1000
40
#define COUNTER_OFFSET 1500
48
buf_block_t* bl_arr[POOL_SIZE];
50
/************************************************************************
51
Io-handler thread function. */
63
segment = *((ulint*)arg);
65
printf("Io handler thread %lu starts\n", segment);
68
ret = fil_aio_wait(segment, &mess);
71
buf_page_io_complete((buf_block_t*)mess);
73
mutex_enter(&ios_mutex);
75
mutex_exit(&ios_mutex);
82
/*************************************************************************
83
Creates the files for the file system test and inserts them to
96
printf("--------------------------------------------------------\n");
97
printf("Create or open database files\n");
99
strcpy(name, "j:\\tsfile00");
101
for (k = 0; k < N_SPACES; k++) {
102
for (i = 0; i < N_FILES; i++) {
104
name[9] = (char)((ulint)'0' + k);
105
name[10] = (char)((ulint)'0' + i);
107
files[i] = os_file_create(name, OS_FILE_CREATE,
108
OS_FILE_TABLESPACE, &ret);
111
ut_a(os_file_get_last_error() ==
112
OS_FILE_ALREADY_EXISTS);
114
files[i] = os_file_create(
116
OS_FILE_TABLESPACE, &ret);
121
ret = os_file_close(files[i]);
125
fil_space_create(name, k, OS_FILE_TABLESPACE);
128
ut_a(fil_validate());
130
fil_node_create(name, FILE_SIZE, k);
136
mutex_create(&ios_mutex);
138
for (i = 0; i < 5; i++) {
141
thr[i] = os_thread_create(handler_thread, n + i, id + i);
145
/*********************************************************************
146
Test for index page. */
165
printf("-------------------------------------------------\n");
166
printf("TEST 1. Basic test\n");
168
heap = mem_heap_create(0);
170
table = dict_table_create("TS_TABLE1", 3);
172
dict_table_add_col(table, "COL1", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
173
dict_table_add_col(table, "COL2", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
174
dict_table_add_col(table, "COL3", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
176
ut_a(0 == dict_table_publish(table));
178
index = dict_index_create("TS_TABLE1", "IND1", 0, 3, 0);
180
dict_index_add_field(index, "COL1", 0);
181
dict_index_add_field(index, "COL2", 0);
182
dict_index_add_field(index, "COL3", 0);
184
ut_a(0 == dict_index_publish(index));
186
index = dict_index_get("TS_TABLE1", "IND1");
189
tuple = dtuple_create(heap, 3);
193
block = buf_page_create(0, 5, &mtr);
194
buf_page_x_lock(block, &mtr);
196
frame = buf_block_get_frame(block);
198
page = page_create(frame, &mtr);
200
for (i = 0; i < 512; i++) {
202
rnd = (rnd + 534671) % 512;
205
ut_a(page_validate(page, index));
208
dtuple_gen_test_tuple(tuple, rnd);
210
/* dtuple_print(tuple);*/
212
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
214
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
219
/* page_print_list(page, 151); */
222
/* page_print_list(page, 151); */
224
ut_a(page_validate(page, index));
225
ut_a(page_get_n_recs(page) == 512);
227
for (i = 0; i < 512; i++) {
229
rnd = (rnd + 7771) % 512;
232
ut_a(page_validate(page, index));
235
dtuple_gen_test_tuple(tuple, rnd);
237
/* dtuple_print(tuple);*/
239
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
241
page_cur_delete_rec(&cursor, &mtr);
246
/* page_print_list(page, 151); */
249
ut_a(page_get_n_recs(page) == 0);
251
ut_a(page_validate(page, index));
252
page = page_create(frame, &mtr);
256
for (i = 0; i < 512; i++) {
258
rnd = (rnd + 1) % 512;
261
ut_a(page_validate(page, index));
264
dtuple_gen_test_tuple(tuple, rnd);
266
/* dtuple_print(tuple);*/
268
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
270
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
275
/* page_print_list(page, 151); */
278
ut_a(page_validate(page, index));
279
ut_a(page_get_n_recs(page) == 512);
283
for (i = 0; i < 512; i++) {
285
rnd = (rnd + 1) % 512;
288
ut_a(page_validate(page, index));
291
dtuple_gen_test_tuple(tuple, rnd);
293
/* dtuple_print(tuple);*/
295
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
297
page_cur_delete_rec(&cursor, &mtr);
302
/* page_print_list(page, 151); */
305
ut_a(page_validate(page, index));
306
ut_a(page_get_n_recs(page) == 0);
307
page = page_create(frame, &mtr);
311
for (i = 0; i < 512; i++) {
313
rnd = (rnd - 1) % 512;
316
ut_a(page_validate(page, index));
319
dtuple_gen_test_tuple(tuple, rnd);
321
/* dtuple_print(tuple);*/
323
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
325
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
330
/* page_print_list(page, 151); */
333
ut_a(page_validate(page, index));
334
ut_a(page_get_n_recs(page) == 512);
338
for (i = 0; i < 512; i++) {
340
rnd = (rnd - 1) % 512;
343
ut_a(page_validate(page, index));
346
dtuple_gen_test_tuple(tuple, rnd);
348
/* dtuple_print(tuple);*/
350
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
352
page_cur_delete_rec(&cursor, &mtr);
357
/* page_print_list(page, 151); */
360
ut_a(page_validate(page, index));
361
ut_a(page_get_n_recs(page) == 0);
367
/*********************************************************************
368
Test for index page. */
390
printf("-------------------------------------------------\n");
391
printf("TEST 2. Speed test\n");
395
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
396
ut_memcpy(bigbuf, bigbuf + 800, 800);
400
printf("Wall time for %lu mem copys of 800 bytes %lu millisecs\n",
406
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
407
ut_memcpy(bigbuf + rnd, bigbuf + rnd + 800, 800);
415
printf("Wall time for %lu mem copys of 800 bytes %lu millisecs\n",
418
heap = mem_heap_create(0);
420
table = dict_table_create("TS_TABLE2", 2);
422
dict_table_add_col(table, "COL1", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
423
dict_table_add_col(table, "COL2", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
425
ut_a(0 == dict_table_publish(table));
427
index = dict_index_create("TS_TABLE2", "IND2", 0, 2, 0);
429
dict_index_add_field(index, "COL1", 0);
430
dict_index_add_field(index, "COL2", 0);
432
ut_a(0 == dict_index_publish(index));
434
index = dict_index_get("TS_TABLE2", "IND2");
437
tuple = dtuple_create(heap, 3);
442
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
446
block = buf_page_create(0, 5, &mtr);
447
buf_page_x_lock(block, &mtr);
449
frame = buf_block_get_frame(block);
451
page = page_create(frame, &mtr);
453
for (j = 0; j < 200; j++) {
454
rnd = (rnd + 54841) % 1000;
455
dtuple_gen_test_tuple3(tuple, rnd, buf);
456
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
458
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
465
printf("Wall time for insertion of %lu recs %lu milliseconds\n",
470
block = buf_page_get(0, 5, &mtr);
471
buf_page_s_lock(block, &mtr);
473
page = buf_block_get_frame(block);
474
ut_a(page_validate(page, index));
480
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
483
block = buf_page_create(0, 5, &mtr);
484
buf_page_x_lock(block, &mtr);
486
frame = buf_block_get_frame(block);
488
page = page_create(frame, &mtr);
490
for (j = 0; j < 200; j++) {
491
rnd = (rnd + 54841) % 1000;
492
dtuple_gen_test_tuple3(tuple, rnd, buf);
499
"Wall time for %lu empty loops with page create %lu milliseconds\n",
504
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
509
block = buf_page_create(0, 5, &mtr);
510
buf_page_x_lock(block, &mtr);
512
frame = buf_block_get_frame(block);
514
page = page_create(frame, &mtr);
519
for (j = 0; j < 200; j++) {
522
block = buf_page_get(0, 5, &mtr2);
523
buf_page_x_lock(block, &mtr2);
525
page = buf_block_get_frame(block);
527
rnd = (rnd + 1) % 1000;
528
dtuple_gen_test_tuple3(tuple, rnd, buf);
529
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
531
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr2);
540
"Wall time for sequential insertion of %lu recs %lu milliseconds\n",
545
block = buf_page_get(0, 5, &mtr);
546
buf_page_s_lock(block, &mtr);
548
page = buf_block_get_frame(block);
549
ut_a(page_validate(page, index));
554
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
557
block = buf_page_create(0, 5, &mtr);
558
buf_page_x_lock(block, &mtr);
560
frame = buf_block_get_frame(block);
562
page = page_create(frame, &mtr);
565
for (j = 0; j < 200; j++) {
566
rnd = (rnd - 1) % 1000;
567
dtuple_gen_test_tuple3(tuple, rnd, buf);
568
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
570
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
578
"Wall time for descend. seq. insertion of %lu recs %lu milliseconds\n",
583
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
586
block = buf_page_create(0, 5, &mtr);
587
buf_page_x_lock(block, &mtr);
589
frame = buf_block_get_frame(block);
591
page = page_create(frame, &mtr);
595
for (j = 0; j < 200; j++) {
596
rnd = (rnd + 54841) % 1000;
597
dtuple_gen_test_tuple3(tuple, rnd, buf);
598
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
600
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
605
for (j = 0; j < 200; j++) {
606
rnd = (rnd + 54841) % 1000;
607
dtuple_gen_test_tuple3(tuple, rnd, buf);
608
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
610
page_cur_delete_rec(&cursor, &mtr);
612
ut_a(page_get_n_recs(page) == 0);
618
printf("Wall time for insert and delete of %lu recs %lu milliseconds\n",
623
block = buf_page_create(0, 5, &mtr);
624
buf_page_x_lock(block, &mtr);
626
frame = buf_block_get_frame(block);
628
page = page_create(frame, &mtr);
632
for (j = 0; j < 200; j++) {
633
rnd = (rnd + 54841) % 1000;
634
dtuple_gen_test_tuple3(tuple, rnd, buf);
635
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
637
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
640
ut_a(page_validate(page, index));
645
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
647
for (j = 0; j < 200; j++) {
648
/* rnd = (rnd + 54841) % 1000;*/
649
dtuple_gen_test_tuple3(tuple, rnd, buf);
650
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
655
printf("Wall time for search of %lu recs %lu milliseconds\n",
660
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
662
for (j = 0; j < 200; j++) {
663
rnd = (rnd + 54841) % 1000;
664
dtuple_gen_test_tuple3(tuple, rnd, buf);
669
printf("Wall time for %lu empty loops %lu milliseconds\n",
674
/********************************************************************
675
Main test function. */
687
buf_pool_init(100, 100);
703
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
704
printf("TESTS COMPLETED SUCCESSFULLY!\n");