mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Remove unnecessary files
.del-univoldmysql.i~9253a6f92058c565: Delete: innobase/include/univoldmysql.i .del-univold.i~4b5ed652407f63f1: Delete: innobase/include/univold.i .del-tsut.c~4a154913fc9cd5c0: Delete: innobase/ut/ts/tsut.c .del-makefile~9b8356bbdb8bd94e: Delete: innobase/ut/ts/makefile .del-tsttrxold.c~eb6fd6091405d54e: Delete: innobase/trx/ts/tsttrxold.c .del-tstrx.c~5425c98548ec1e0d: Delete: innobase/trx/ts/tstrx.c .del-makefile~16d63c17c8edf62a: Delete: innobase/trx/ts/makefile .del-tsthr.c~b095667070d626a9: Delete: innobase/thr/ts/tsthr.c .del-makefile~d5e4661188c1939d: Delete: innobase/thr/ts/makefile .del-tssync.c~fed4676cd4eb8457: Delete: innobase/sync/ts/tssync.c .del-makefile~f23368879649c806: Delete: innobase/sync/ts/makefile .del-tssrv.c~b8a6f5ad9ae639c8: Delete: innobase/srv/ts/tssrv.c .del-tsdbc.c~d36206bdccf338f: Delete: innobase/srv/ts/tsdbc.c .del-makefile~da6e87ef29c12dca: Delete: innobase/srv/ts/makefile .del-tstcur.c~a9d5cf73b020ec41: Delete: innobase/row/ts/tstcur.c .del-makefile~2cdfe39689004e6: Delete: innobase/row/ts/makefile .del-tsrem.c~bb4e1e2e8c2ee179: Delete: innobase/rem/ts/tsrem.c .del-makefile~3e48a33b4970faef: Delete: innobase/rem/ts/makefile .del-tspage.c~f5baf63f9924e43b: Delete: innobase/page/ts/tspage.c .del-makefile~66de73bc499566f9: Delete: innobase/page/ts/makefile .del-tsosaux.c~9ec97a83392a984c: Delete: innobase/os/ts/tsosaux.c .del-tsos.c~f6057d3c171f5915: Delete: innobase/os/ts/tsos.c .del-makefile~9a1d210afa6d666e: Delete: innobase/os/ts/makefile .del-tsmtr.c~293250c7ebfe0d3: Delete: innobase/mtr/ts/tsmtr.c .del-tsbuf.c~e8d15ee095194d2c: Delete: innobase/mtr/ts/tsbuf.c .del-makefile~fdf4c2a4ddb23230: Delete: innobase/mtr/ts/makefile .del-tsmem.c~cc483e2ab96e625c: Delete: innobase/mem/ts/tsmem.c .del-makefile~6d58ab1de0ac572: Delete: innobase/mem/ts/makefile .del-tsmach.c~af65166bb53ddfe9: Delete: innobase/mach/ts/tsmach.c .del-makefile~b8cbd25992ee51b: Delete: innobase/mach/ts/makefile .del-tsha.c~13dd5ea03fda370c: Delete: innobase/ha/ts/tsha.c .del-makefile~1bf12ce7b2dadfd5: Delete: innobase/ha/ts/makefile .del-tsfsp.c~890ead1636f0eaba: Delete: innobase/fsp/ts/tsfsp.c .del-makefile~a466e9eb27493a80: Delete: innobase/fsp/ts/makefile .del-del.c~35c6283be580200: Delete: innobase/fsp/ts/del.c .del-tsfil.c~e554b6f3c189c081: Delete: innobase/fil/ts/tsfil.c .del-makefile~1df6f952a960fef4: Delete: innobase/fil/ts/makefile .del-tsdyn.c~6f976764b53f3191: Delete: innobase/dyn/ts/tsdyn.c .del-makefile~f64427335fafdc65: Delete: innobase/dyn/ts/makefile .del-tsdict.c~5e82f7b8ac2b2e15: Delete: innobase/dict/ts/tsdict.c .del-makefile~6356c424e9747647: Delete: innobase/dict/ts/makefile .del-tscom.c~26aae2c5c4ca1dce: Delete: innobase/com/ts/tscom.c .del-tscli.c~2f3e4b281141eac2: Delete: innobase/com/ts/tscli.c .del-makefile~608fd39568db7238: Delete: innobase/com/ts/makefile .del-tsos.c~1dadfc1ef69f2ba3: Delete: innobase/buf/ts/tsos.c .del-tsbuf.c~b4c3feee158ef154: Delete: innobase/buf/ts/tsbuf.c .del-makefile~598acb06bf1e466: Delete: innobase/buf/ts/makefile .del-tscli.c~8d35740cc1f6f864: Delete: innobase/btr/ts/trash/tscli.c .del-tssrv.c~ee30b746c485aec: Delete: innobase/btr/ts/tssrv.c .del-tss.c~21ae628550141a68: Delete: innobase/btr/ts/tss.c .del-tsrecv97.c~dbeb3bc494b241c1: Delete: innobase/btr/ts/tsrecv97.c .del-tsrecv.c~3415f8a936a8d9fd: Delete: innobase/btr/ts/tsrecv.c .del-tscli.c~77fc1962db99aa2e: Delete: innobase/btr/ts/tscli.c .del-tsbtrold5.c~72a60e768c944904: Delete: innobase/btr/ts/trash/tsbtrold5.c .del-tsbtrins.c~3e3bb3f95f058b46: Delete: innobase/btr/ts/tsbtrins.c .del-TSIT.C~f53cce6fab8d325: Delete: innobase/btr/ts/trash/TSIT.C .del-tsbtrfull.c~fbcbe41b64cc71b6: Delete: innobase/btr/ts/tsbtrfull.c .del-tsbtr97.c~84dbb84ea9fa267c: Delete: innobase/btr/ts/tsbtr97.c .del-makefile~491918b4162b927c: Delete: innobase/btr/ts/makefile .del-isql.c~bc0b8cc213905175: Delete: innobase/btr/ts/isql.c BitKeeper/deleted/.del-isql.c~bc0b8cc213905175: Delete: innobase/btr/ts/isql.c BitKeeper/deleted/.del-makefile~491918b4162b927c: Delete: innobase/btr/ts/makefile BitKeeper/deleted/.del-tsbtr97.c~84dbb84ea9fa267c: Delete: innobase/btr/ts/tsbtr97.c BitKeeper/deleted/.del-tsbtrfull.c~fbcbe41b64cc71b6: Delete: innobase/btr/ts/tsbtrfull.c BitKeeper/deleted/.del-TSIT.C~f53cce6fab8d325: Delete: innobase/btr/ts/trash/TSIT.C BitKeeper/deleted/.del-tsbtrins.c~3e3bb3f95f058b46: Delete: innobase/btr/ts/tsbtrins.c BitKeeper/deleted/.del-tsbtrold5.c~72a60e768c944904: Delete: innobase/btr/ts/trash/tsbtrold5.c BitKeeper/deleted/.del-tscli.c~77fc1962db99aa2e: Delete: innobase/btr/ts/tscli.c BitKeeper/deleted/.del-tsrecv.c~3415f8a936a8d9fd: Delete: innobase/btr/ts/tsrecv.c BitKeeper/deleted/.del-tsrecv97.c~dbeb3bc494b241c1: Delete: innobase/btr/ts/tsrecv97.c BitKeeper/deleted/.del-tss.c~21ae628550141a68: Delete: innobase/btr/ts/tss.c BitKeeper/deleted/.del-tssrv.c~ee30b746c485aec: Delete: innobase/btr/ts/tssrv.c BitKeeper/deleted/.del-tscli.c~8d35740cc1f6f864: Delete: innobase/btr/ts/trash/tscli.c BitKeeper/deleted/.del-makefile~598acb06bf1e466: Delete: innobase/buf/ts/makefile BitKeeper/deleted/.del-tsbuf.c~b4c3feee158ef154: Delete: innobase/buf/ts/tsbuf.c BitKeeper/deleted/.del-tsos.c~1dadfc1ef69f2ba3: Delete: innobase/buf/ts/tsos.c BitKeeper/deleted/.del-makefile~608fd39568db7238: Delete: innobase/com/ts/makefile BitKeeper/deleted/.del-tscli.c~2f3e4b281141eac2: Delete: innobase/com/ts/tscli.c BitKeeper/deleted/.del-tscom.c~26aae2c5c4ca1dce: Delete: innobase/com/ts/tscom.c BitKeeper/deleted/.del-makefile~6356c424e9747647: Delete: innobase/dict/ts/makefile BitKeeper/deleted/.del-tsdict.c~5e82f7b8ac2b2e15: Delete: innobase/dict/ts/tsdict.c BitKeeper/deleted/.del-makefile~f64427335fafdc65: Delete: innobase/dyn/ts/makefile BitKeeper/deleted/.del-tsdyn.c~6f976764b53f3191: Delete: innobase/dyn/ts/tsdyn.c BitKeeper/deleted/.del-makefile~1df6f952a960fef4: Delete: innobase/fil/ts/makefile BitKeeper/deleted/.del-tsfil.c~e554b6f3c189c081: Delete: innobase/fil/ts/tsfil.c BitKeeper/deleted/.del-del.c~35c6283be580200: Delete: innobase/fsp/ts/del.c BitKeeper/deleted/.del-makefile~a466e9eb27493a80: Delete: innobase/fsp/ts/makefile BitKeeper/deleted/.del-tsfsp.c~890ead1636f0eaba: Delete: innobase/fsp/ts/tsfsp.c BitKeeper/deleted/.del-makefile~1bf12ce7b2dadfd5: Delete: innobase/ha/ts/makefile BitKeeper/deleted/.del-tsha.c~13dd5ea03fda370c: Delete: innobase/ha/ts/tsha.c BitKeeper/deleted/.del-makefile~b8cbd25992ee51b: Delete: innobase/mach/ts/makefile BitKeeper/deleted/.del-tsmach.c~af65166bb53ddfe9: Delete: innobase/mach/ts/tsmach.c BitKeeper/deleted/.del-makefile~6d58ab1de0ac572: Delete: innobase/mem/ts/makefile BitKeeper/deleted/.del-tsmem.c~cc483e2ab96e625c: Delete: innobase/mem/ts/tsmem.c BitKeeper/deleted/.del-makefile~fdf4c2a4ddb23230: Delete: innobase/mtr/ts/makefile BitKeeper/deleted/.del-tsbuf.c~e8d15ee095194d2c: Delete: innobase/mtr/ts/tsbuf.c BitKeeper/deleted/.del-tsmtr.c~293250c7ebfe0d3: Delete: innobase/mtr/ts/tsmtr.c BitKeeper/deleted/.del-makefile~9a1d210afa6d666e: Delete: innobase/os/ts/makefile BitKeeper/deleted/.del-tsos.c~f6057d3c171f5915: Delete: innobase/os/ts/tsos.c BitKeeper/deleted/.del-tsosaux.c~9ec97a83392a984c: Delete: innobase/os/ts/tsosaux.c BitKeeper/deleted/.del-makefile~66de73bc499566f9: Delete: innobase/page/ts/makefile BitKeeper/deleted/.del-tspage.c~f5baf63f9924e43b: Delete: innobase/page/ts/tspage.c BitKeeper/deleted/.del-makefile~3e48a33b4970faef: Delete: innobase/rem/ts/makefile BitKeeper/deleted/.del-tsrem.c~bb4e1e2e8c2ee179: Delete: innobase/rem/ts/tsrem.c BitKeeper/deleted/.del-makefile~2cdfe39689004e6: Delete: innobase/row/ts/makefile BitKeeper/deleted/.del-tstcur.c~a9d5cf73b020ec41: Delete: innobase/row/ts/tstcur.c BitKeeper/deleted/.del-makefile~da6e87ef29c12dca: Delete: innobase/srv/ts/makefile BitKeeper/deleted/.del-tsdbc.c~d36206bdccf338f: Delete: innobase/srv/ts/tsdbc.c BitKeeper/deleted/.del-tssrv.c~b8a6f5ad9ae639c8: Delete: innobase/srv/ts/tssrv.c BitKeeper/deleted/.del-makefile~f23368879649c806: Delete: innobase/sync/ts/makefile BitKeeper/deleted/.del-tssync.c~fed4676cd4eb8457: Delete: innobase/sync/ts/tssync.c BitKeeper/deleted/.del-makefile~d5e4661188c1939d: Delete: innobase/thr/ts/makefile BitKeeper/deleted/.del-tsthr.c~b095667070d626a9: Delete: innobase/thr/ts/tsthr.c BitKeeper/deleted/.del-makefile~16d63c17c8edf62a: Delete: innobase/trx/ts/makefile BitKeeper/deleted/.del-tstrx.c~5425c98548ec1e0d: Delete: innobase/trx/ts/tstrx.c BitKeeper/deleted/.del-tsttrxold.c~eb6fd6091405d54e: Delete: innobase/trx/ts/tsttrxold.c BitKeeper/deleted/.del-makefile~9b8356bbdb8bd94e: Delete: innobase/ut/ts/makefile BitKeeper/deleted/.del-tsut.c~4a154913fc9cd5c0: Delete: innobase/ut/ts/tsut.c BitKeeper/deleted/.del-univold.i~4b5ed652407f63f1: Delete: innobase/include/univold.i BitKeeper/deleted/.del-univoldmysql.i~9253a6f92058c565: Delete: innobase/include/univoldmysql.i BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted
This commit is contained in:
@ -55,6 +55,7 @@ konstantin@mysql.com
|
||||
kostja@oak.local
|
||||
lenz@kallisto.mysql.com
|
||||
lenz@mysql.com
|
||||
marko@hundin.mysql.fi
|
||||
miguel@hegel.(none)
|
||||
miguel@hegel.br
|
||||
miguel@hegel.local
|
||||
|
@ -1,312 +0,0 @@
|
||||
/************************************************************************
|
||||
Test for the client: interactive SQL
|
||||
|
||||
(c) 1996-1997 Innobase Oy
|
||||
|
||||
Created 2/16/1996 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "univ.i"
|
||||
#include "ib_odbc.h"
|
||||
#include "mem0mem.h"
|
||||
#include "sync0sync.h"
|
||||
#include "os0thread.h"
|
||||
#include "os0proc.h"
|
||||
#include "os0sync.h"
|
||||
#include "srv0srv.h"
|
||||
|
||||
ulint n_exited = 0;
|
||||
|
||||
char cli_srv_endpoint_name[100];
|
||||
char cli_user_name[100];
|
||||
|
||||
ulint n_warehouses = ULINT_MAX;
|
||||
ulint n_customers_d = ULINT_MAX;
|
||||
bool is_tpc_d = FALSE;
|
||||
ulint n_rounds = ULINT_MAX;
|
||||
ulint n_users = ULINT_MAX;
|
||||
ulint startdate = 0;
|
||||
ulint enddate = 0;
|
||||
bool own_warehouse = FALSE;
|
||||
|
||||
ulint mem_pool_size = ULINT_MAX;
|
||||
|
||||
/*************************************************************************
|
||||
Reads a keywords and a values from an initfile. In case of an error, exits
|
||||
from the process. */
|
||||
static
|
||||
void
|
||||
cli_read_initfile(
|
||||
/*==============*/
|
||||
FILE* initfile) /* in: file pointer */
|
||||
{
|
||||
char str_buf[10000];
|
||||
ulint ulint_val;
|
||||
|
||||
srv_read_init_val(initfile, FALSE, "SRV_ENDPOINT_NAME", str_buf,
|
||||
&ulint_val);
|
||||
|
||||
ut_a(ut_strlen(str_buf) < COM_MAX_ADDR_LEN);
|
||||
|
||||
ut_memcpy(cli_srv_endpoint_name, str_buf, COM_MAX_ADDR_LEN);
|
||||
|
||||
srv_read_init_val(initfile, FALSE, "USER_NAME", str_buf,
|
||||
&ulint_val);
|
||||
ut_a(ut_strlen(str_buf) < COM_MAX_ADDR_LEN);
|
||||
|
||||
ut_memcpy(cli_user_name, str_buf, COM_MAX_ADDR_LEN);
|
||||
|
||||
srv_read_init_val(initfile, TRUE, "MEM_POOL_SIZE", str_buf,
|
||||
&mem_pool_size);
|
||||
|
||||
srv_read_init_val(initfile, TRUE, "N_WAREHOUSES", str_buf,
|
||||
&n_warehouses);
|
||||
|
||||
srv_read_init_val(initfile, TRUE, "N_CUSTOMERS_D", str_buf,
|
||||
&n_customers_d);
|
||||
|
||||
srv_read_init_val(initfile, TRUE, "IS_TPC_D", str_buf,
|
||||
&is_tpc_d);
|
||||
|
||||
srv_read_init_val(initfile, TRUE, "N_ROUNDS", str_buf,
|
||||
&n_rounds);
|
||||
|
||||
srv_read_init_val(initfile, TRUE, "N_USERS", str_buf,
|
||||
&n_users);
|
||||
|
||||
srv_read_init_val(initfile, TRUE, "STARTDATE", str_buf,
|
||||
&startdate);
|
||||
|
||||
srv_read_init_val(initfile, TRUE, "ENDDATE", str_buf,
|
||||
&enddate);
|
||||
|
||||
srv_read_init_val(initfile, TRUE, "OWN_WAREHOUSE", str_buf,
|
||||
&own_warehouse);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Reads configuration info for the client. */
|
||||
static
|
||||
void
|
||||
cli_boot(
|
||||
/*=====*/
|
||||
char* name) /* in: the initialization file name */
|
||||
{
|
||||
FILE* initfile;
|
||||
|
||||
initfile = fopen(name, "r");
|
||||
|
||||
if (initfile == NULL) {
|
||||
printf(
|
||||
"Error in client booting: could not open initfile whose name is %s!\n",
|
||||
name);
|
||||
os_process_exit(1);
|
||||
}
|
||||
|
||||
cli_read_initfile(initfile);
|
||||
|
||||
fclose(initfile);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Interactive SQL loop. */
|
||||
static
|
||||
void
|
||||
isql(
|
||||
/*=*/
|
||||
FILE* inputfile) /* in: input file containing SQL strings,
|
||||
or stdin */
|
||||
{
|
||||
HENV env;
|
||||
HDBC conn;
|
||||
RETCODE ret;
|
||||
HSTMT sql_query;
|
||||
ulint tm, oldtm;
|
||||
char buf[1000];
|
||||
char* str;
|
||||
ulint count;
|
||||
ulint n_begins;
|
||||
ulint len;
|
||||
ulint n;
|
||||
ulint i;
|
||||
ulint n_lines;
|
||||
|
||||
ret = SQLAllocEnv(&env);
|
||||
|
||||
ut_a(ret == SQL_SUCCESS);
|
||||
|
||||
ret = SQLAllocConnect(env, &conn);
|
||||
|
||||
ut_a(ret == SQL_SUCCESS);
|
||||
|
||||
ret = SQLConnect(conn, (UCHAR*)cli_srv_endpoint_name,
|
||||
(SWORD)ut_strlen(cli_srv_endpoint_name),
|
||||
cli_user_name,
|
||||
(SWORD)ut_strlen(cli_user_name),
|
||||
(UCHAR*)"password", 8);
|
||||
ut_a(ret == SQL_SUCCESS);
|
||||
|
||||
printf("Connection established\n");
|
||||
|
||||
printf("Interactive SQL performs queries by first making a stored\n");
|
||||
printf("procedure from them, and then calling the procedure.\n");
|
||||
printf("Put a semicolon after each statement and\n");
|
||||
printf("end your query with two <enter>s.\n\n");
|
||||
printf("You can also give a single input file\n");
|
||||
printf("as a command line argument to isql.\n\n");
|
||||
printf("In the file separate SQL queries and procedure bodies\n");
|
||||
printf("by a single empty line. Do not write the final END; into\n");
|
||||
printf("a procedure body.\n\n");
|
||||
|
||||
count = 0;
|
||||
loop:
|
||||
count++;
|
||||
n = 0;
|
||||
n_lines = 0;
|
||||
|
||||
sprintf(buf, "PROCEDURE P%s%lu () IS\nBEGIN ", cli_user_name,
|
||||
count);
|
||||
for (;;) {
|
||||
len = ut_strlen(buf + n) - 1;
|
||||
n += len;
|
||||
|
||||
if (len == 0) {
|
||||
break;
|
||||
} else {
|
||||
sprintf(buf + n, "\n");
|
||||
n++;
|
||||
n_lines++;
|
||||
}
|
||||
|
||||
str = fgets(buf + n, 1000, inputfile);
|
||||
|
||||
if ((str == NULL) && (inputfile != stdin)) {
|
||||
/* Reached end-of-file: switch to input from
|
||||
keyboard */
|
||||
|
||||
inputfile = stdin;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
ut_a(str);
|
||||
}
|
||||
|
||||
if (n_lines == 1) {
|
||||
/* Empty procedure */
|
||||
|
||||
goto loop;
|
||||
}
|
||||
|
||||
/* If the statement is actually the body of a procedure,
|
||||
erase the first BEGIN from the string: */
|
||||
|
||||
n_begins = 0;
|
||||
|
||||
for (i = 0; i < n - 5; i++) {
|
||||
|
||||
if (ut_memcmp(buf + i, "BEGIN", 5) == 0) {
|
||||
|
||||
n_begins++;
|
||||
}
|
||||
}
|
||||
|
||||
if (n_begins > 1) {
|
||||
|
||||
for (i = 0; i < n - 5; i++) {
|
||||
|
||||
if (ut_memcmp(buf + i, "BEGIN", 5) == 0) {
|
||||
|
||||
/* Erase the first BEGIN: */
|
||||
ut_memcpy(buf + i, " ", 5);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(buf + n, "END;\n");
|
||||
|
||||
printf("SQL procedure to execute:\n%s\n", buf);
|
||||
|
||||
ret = SQLAllocStmt(conn, &sql_query);
|
||||
|
||||
ut_a(ret == SQL_SUCCESS);
|
||||
|
||||
ret = SQLPrepare(sql_query, (UCHAR*)buf, ut_strlen(buf));
|
||||
|
||||
ut_a(ret == SQL_SUCCESS);
|
||||
|
||||
ret = SQLExecute(sql_query);
|
||||
|
||||
ut_a(ret == SQL_SUCCESS);
|
||||
|
||||
sprintf(buf, "{P%s%lu ()}", cli_user_name, count);
|
||||
|
||||
ret = SQLAllocStmt(conn, &sql_query);
|
||||
|
||||
ut_a(ret == SQL_SUCCESS);
|
||||
|
||||
ret = SQLPrepare(sql_query, (UCHAR*)buf, ut_strlen(buf));
|
||||
|
||||
ut_a(ret == SQL_SUCCESS);
|
||||
|
||||
printf("Starting to execute the query\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
ret = SQLExecute(sql_query);
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall time for query %lu milliseconds\n\n", tm - oldtm);
|
||||
|
||||
ut_a(ret == SQL_SUCCESS);
|
||||
|
||||
goto loop;
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(int argc, char* argv[])
|
||||
/*========================*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
FILE* inputfile;
|
||||
|
||||
if (argc > 2) {
|
||||
printf("Only one input file allowed\n");
|
||||
|
||||
os_process_exit(1);
|
||||
|
||||
} else if (argc == 2) {
|
||||
inputfile = fopen(argv[1], "r");
|
||||
|
||||
if (inputfile == NULL) {
|
||||
printf(
|
||||
"Error: could not open the inputfile whose name is %s!\n",
|
||||
argv[1]);
|
||||
os_process_exit(1);
|
||||
}
|
||||
} else {
|
||||
inputfile = stdin;
|
||||
}
|
||||
|
||||
cli_boot("cli_init");
|
||||
|
||||
sync_init();
|
||||
|
||||
mem_init(mem_pool_size);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
isql(inputfile);
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
include ..\..\makefile.i
|
||||
|
||||
doall: tssrv tscli isql
|
||||
|
||||
tssrv: ..\btr.lib tssrv.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\btr.lib ..\..\eval.lib ..\..\ibuf.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tssrv.c $(LFL)
|
||||
|
||||
tscli: ..\btr.lib tscli.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\btr.lib ..\..\ib_odbc.lib ..\..\eval.lib ..\..\ibuf.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tscli.c $(LFL)
|
||||
|
||||
isql: ..\btr.lib isql.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\btr.lib ..\..\ib_odbc.lib ..\..\eval.lib ..\..\ibuf.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib isql.c $(LFL)
|
||||
|
||||
tsrecv: ..\btr.lib tsrecv.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\btr.lib ..\..\ibuf.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsrecv.c $(LFL)
|
||||
|
@ -1,483 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for the record manager of MVB.
|
||||
|
||||
(c) 1994 Heikki Tuuri
|
||||
|
||||
Created 1/25/1994 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
#include "rm0phr.h"
|
||||
#include "rm0lgr.h"
|
||||
#include "ut0ut.h"
|
||||
#include "buf0mem.h"
|
||||
#include "rm0ipg.h"
|
||||
#include "../it0it.h"
|
||||
#include "../it0hi.h"
|
||||
#include "../it0ads.h"
|
||||
|
||||
byte buf[100];
|
||||
byte buf2[100];
|
||||
lint lintbuf[2048];
|
||||
|
||||
byte numbuf[6000];
|
||||
byte numlogrecbuf[100];
|
||||
phr_record_t* qs_table[100000];
|
||||
|
||||
lint qs_comp = 0;
|
||||
|
||||
extern
|
||||
void
|
||||
test1(void);
|
||||
|
||||
#ifdef NOT_DEFINED
|
||||
|
||||
void
|
||||
q_sort(lint low, lint up)
|
||||
{
|
||||
phr_record_t* temp, *pivot;
|
||||
lint i, j;
|
||||
|
||||
|
||||
pivot = qs_table[(low + up) / 2];
|
||||
|
||||
i = low;
|
||||
j = up;
|
||||
|
||||
while (i < j) {
|
||||
qs_comp++;
|
||||
if (cmp_phr_compare(qs_table[i], pivot)<= 0) {
|
||||
i++;
|
||||
} else {
|
||||
j--;
|
||||
temp = qs_table[i];
|
||||
qs_table[i] = qs_table[j];
|
||||
qs_table[j] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
if (j == up) {
|
||||
temp = qs_table[(low + up) / 2];
|
||||
qs_table[(low + up) / 2] = qs_table[up - 1];
|
||||
qs_table[up - 1] = temp;
|
||||
j--;
|
||||
}
|
||||
|
||||
|
||||
if (j - low <= 1) {
|
||||
/* do nothing */
|
||||
} else if (j - low == 2) {
|
||||
qs_comp++;
|
||||
if (cmp_phr_compare(qs_table[low],
|
||||
qs_table[low + 1])
|
||||
<= 0) {
|
||||
/* do nothing */
|
||||
} else {
|
||||
temp = qs_table[low];
|
||||
qs_table[low] = qs_table[low + 1];
|
||||
qs_table[low + 1] = temp;
|
||||
}
|
||||
} else {
|
||||
q_sort(low, j);
|
||||
}
|
||||
|
||||
if (up - j <= 1) {
|
||||
/* do nothing */
|
||||
} else if (up - j == 2) {
|
||||
qs_comp++;
|
||||
if (cmp_phr_compare(qs_table[j],
|
||||
qs_table[j + 1])
|
||||
<= 0) {
|
||||
/* do nothing */
|
||||
} else {
|
||||
temp = qs_table[j];
|
||||
qs_table[j] = qs_table[j + 1];
|
||||
qs_table[j + 1] = temp;
|
||||
}
|
||||
} else {
|
||||
q_sort(j, up);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
extern
|
||||
void
|
||||
test1(void)
|
||||
{
|
||||
phr_record_t* physrec;
|
||||
phr_record_t* rec1;
|
||||
phr_record_t* rec2;
|
||||
lgr_record_t* logrec;
|
||||
lgrf_field_t* logfield;
|
||||
lint len;
|
||||
byte* str;
|
||||
lint len2;
|
||||
lint tm;
|
||||
lint oldtm;
|
||||
lint i, j, k, l, m;
|
||||
bool b;
|
||||
it_cur_cursor_t cursor;
|
||||
ipg_cur_cursor_t* page_cursor;
|
||||
ipg_page_t* page;
|
||||
|
||||
byte c4, c3, c2, c1, c0;
|
||||
lint rand, rnd1, rnd2;
|
||||
byte* nb;
|
||||
lgr_record_t* numlogrec;
|
||||
byte* pgbuf;
|
||||
mem_stream_t* stream;
|
||||
lint tree1, tree2, tree3;
|
||||
lint dummy1, dummy2;
|
||||
|
||||
pgbuf = (byte*)lintbuf;
|
||||
|
||||
stream = mem_stream_create(0);
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 1. Speed and basic tests.\n");
|
||||
|
||||
logrec = lgr_create_logical_record(stream, 2);
|
||||
|
||||
nb = numbuf;
|
||||
|
||||
c4 = '0';
|
||||
c3 = '0';
|
||||
for (c2 = '0'; c2 <= '9'; c2++) {
|
||||
for (c1 = '0'; c1 <= '9'; c1++) {
|
||||
for (c0 = '0'; c0 <= '9'; c0++) {
|
||||
*nb = c4; nb++;
|
||||
*nb = c3; nb++;
|
||||
*nb = c2; nb++;
|
||||
*nb = c1; nb++;
|
||||
*nb = c0; nb++;
|
||||
*nb = '\0'; nb++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
numlogrec = lgr_create_logical_record(stream, 2);
|
||||
|
||||
|
||||
tree1 = it_create_index_tree();
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rand = 99900;
|
||||
rnd1 = 67;
|
||||
for (j = 0; j < 1; j++) {
|
||||
for (i = 0 ; i < 100000; i++) {
|
||||
|
||||
rand = (rand + 1) % 100000;
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 0);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 1);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
/*
|
||||
it_insert(tree1, numlogrec);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
it_cur_search_tree_to_nth_level(tree1, 1, numlogrec,
|
||||
IPG_SE_L_GE, &cursor, &dummy1, &dummy2);
|
||||
|
||||
/*
|
||||
it_cur_set_to_first(tree1, &cursor);
|
||||
*/
|
||||
|
||||
it_cur_insert_record(&cursor, numlogrec);
|
||||
|
||||
}
|
||||
}
|
||||
tm = ut_clock();
|
||||
printf("Time for inserting %ld recs = %ld \n", i* j, tm - oldtm);
|
||||
|
||||
/* it_print_tree(tree1, 10);*/
|
||||
hi_print_info();
|
||||
ads_print_info();
|
||||
/*
|
||||
oldtm = ut_clock();
|
||||
|
||||
rand = 11113;
|
||||
for (i = 0; i < 5000; i++) {
|
||||
|
||||
rand = (rand + 57123) % 100000;
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 0);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 1);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
it_cur_search_tree_to_nth_level(tree1, 1, numlogrec,
|
||||
IPG_SE_L_GE, &cursor, &dummy1, &dummy2);
|
||||
|
||||
}
|
||||
tm = ut_clock();
|
||||
printf("Time for searching %ld recs = %ld \n", i, tm - oldtm);
|
||||
*/
|
||||
|
||||
it_cur_set_to_first(tree1, &cursor);
|
||||
|
||||
rec1 = ipg_cur_get_record(it_cur_get_page_cursor(&cursor));
|
||||
|
||||
for (i = 0;; i++) {
|
||||
it_cur_move_to_next(&cursor);
|
||||
if (it_cur_end_of_level(&cursor)) {
|
||||
break;
|
||||
}
|
||||
rec2 = ipg_cur_get_record(it_cur_get_page_cursor(&cursor));
|
||||
ut_a(cmp_phr_compare(rec1, rec2) == -1);
|
||||
rec1 = rec2;
|
||||
}
|
||||
|
||||
printf("tree1 checked for right sorted order!\n");
|
||||
|
||||
#ifdef not_defined
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 1; j++) {
|
||||
rand = 11113;
|
||||
for (i = 0; i < 3000; i++) {
|
||||
|
||||
rand = (rand + 57123) % 100000;
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 0);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 1);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
physrec = hi_search(numlogrec);
|
||||
|
||||
ut_a(physrec);
|
||||
}
|
||||
|
||||
}
|
||||
ut_a(physrec);
|
||||
tm = ut_clock();
|
||||
printf("Time for hi_search %ld recs = %ld \n", i * j,
|
||||
tm - oldtm);
|
||||
|
||||
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 100000; i++) {
|
||||
/* j += lgr_fold(numlogrec, -1, -1);*/
|
||||
/* b += phr_lgr_equal(physrec, numlogrec, -1);*/
|
||||
k += ut_hash_lint(j, HI_TABLE_SIZE);
|
||||
}
|
||||
|
||||
|
||||
/* ut_a(b);*/
|
||||
tm = ut_clock();
|
||||
printf("Time for fold + equal %ld recs %s = %ld \n", i, physrec,
|
||||
tm - oldtm);
|
||||
|
||||
printf("%ld %ld %ld\n", j, b, k);
|
||||
|
||||
hi_print_info();
|
||||
|
||||
tree2 = it_create_index_tree();
|
||||
|
||||
rand = 90000;
|
||||
for (i = 0; i < 300; i++) {
|
||||
|
||||
rand = (rand + 1) % 100000;
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 0);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 1);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
it_cur_search_tree_to_nth_level(tree2, 1, numlogrec,
|
||||
IPG_SE_L_GE, &cursor);
|
||||
|
||||
it_cur_insert_record(&cursor, numlogrec);
|
||||
|
||||
}
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rand = 10000;
|
||||
for (i = 0; i < 3000; i++) {
|
||||
|
||||
rand = (rand + 1) % 100000;
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 0);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 1);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
it_cur_search_tree_to_nth_level(tree2, 1, numlogrec,
|
||||
IPG_SE_L_GE, &cursor);
|
||||
|
||||
it_cur_insert_record(&cursor, numlogrec);
|
||||
|
||||
}
|
||||
tm = ut_clock();
|
||||
printf("Time for inserting sequentially %ld recs = %ld \n",
|
||||
i, tm - oldtm);
|
||||
|
||||
|
||||
/* it_print_tree(tree2, 10); */
|
||||
|
||||
|
||||
tree3 = it_create_index_tree();
|
||||
|
||||
rand = 0;
|
||||
for (i = 0; i < 300; i++) {
|
||||
|
||||
rand = (rand + 1) % 100000;
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 0);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 1);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
it_cur_search_tree_to_nth_level(tree3, 1, numlogrec,
|
||||
IPG_SE_L_GE, &cursor);
|
||||
|
||||
it_cur_insert_record(&cursor, numlogrec);
|
||||
|
||||
}
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rand = 100000;
|
||||
for (i = 0; i < 3000; i++) {
|
||||
|
||||
rand = (rand - 1) % 100000;
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 0);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 1);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
it_cur_search_tree_to_nth_level(tree3, 1, numlogrec,
|
||||
IPG_SE_L_GE, &cursor);
|
||||
|
||||
it_cur_insert_record(&cursor, numlogrec);
|
||||
|
||||
}
|
||||
tm = ut_clock();
|
||||
printf("Time for inserting sequentially downw. %ld recs = %ld \n",
|
||||
i, tm - oldtm);
|
||||
|
||||
|
||||
/* it_print_tree(tree3, 10); */
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef NOT_DEFINED
|
||||
|
||||
/* Test of quicksort */
|
||||
void
|
||||
test2(void)
|
||||
{
|
||||
mem_stream_t* stream;
|
||||
byte* stbuf;
|
||||
lgrf_field_t* logfield;
|
||||
lint tm;
|
||||
lint oldtm;
|
||||
lint i, j, k, l, m;
|
||||
lint rand;
|
||||
lgr_record_t* numlogrec;
|
||||
phr_record_t* ph_rec;
|
||||
|
||||
stream = mem_stream_create(1000);
|
||||
|
||||
numlogrec = lgr_create_logical_record(stream, 2);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rand = 11113;
|
||||
for (i = 0; i < 50000; i++) {
|
||||
stbuf = mem_stream_alloc(stream, 30);
|
||||
|
||||
rand = (rand + 57123) % 100000;
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 0);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
logfield = lgr_get_nth_field(numlogrec, 1);
|
||||
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
|
||||
lgrf_set_len(logfield, 6);
|
||||
|
||||
ph_rec = phr_create_physical_record(stbuf, 30, numlogrec);
|
||||
|
||||
qs_table[i] = ph_rec;
|
||||
|
||||
}
|
||||
tm = ut_clock();
|
||||
printf("Time for inserting %ld recs to mem stream = %ld \n",
|
||||
i, tm - oldtm);
|
||||
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
q_sort(0, 50000);
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Time for quicksort of %ld recs = %ld, comps: %ld \n",
|
||||
i, tm - oldtm, qs_comp);
|
||||
|
||||
|
||||
|
||||
for (i = 1; i < 49999; i++) {
|
||||
ut_a(-1 ==
|
||||
cmp_phr_compare(qs_table[i], qs_table[i+1]
|
||||
));
|
||||
}
|
||||
tm = ut_clock();
|
||||
|
||||
|
||||
oldtm = ut_clock();
|
||||
for (i = 1; i < 50000; i++) {
|
||||
k += cmp_phr_compare(qs_table[i & 0xF],
|
||||
qs_table[5]);
|
||||
}
|
||||
tm = ut_clock();
|
||||
printf("%ld\n", k);
|
||||
|
||||
printf("Time for cmp of %ld ph_recs = %ld \n",
|
||||
i, tm - oldtm);
|
||||
|
||||
mem_stream_free(stream);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
test1();
|
||||
/* test2(); */
|
||||
}
|
||||
|
@ -1,798 +0,0 @@
|
||||
/************************************************************************
|
||||
The test for the index tree
|
||||
|
||||
(c) 1994-1996 Innobase Oy
|
||||
|
||||
Created 2/16/1996 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "sync0sync.h"
|
||||
#include "ut0mem.h"
|
||||
#include "mem0mem.h"
|
||||
#include "data0data.h"
|
||||
#include "data0type.h"
|
||||
#include "dict0dict.h"
|
||||
#include "buf0buf.h"
|
||||
#include "os0file.h"
|
||||
#include "fil0fil.h"
|
||||
#include "fsp0fsp.h"
|
||||
#include "rem0rec.h"
|
||||
#include "rem0cmp.h"
|
||||
#include "mtr0mtr.h"
|
||||
#include "log0log.h"
|
||||
#include "page0page.h"
|
||||
#include "page0cur.h"
|
||||
#include "..\btr0btr.h"
|
||||
#include "..\btr0cur.h"
|
||||
#include "..\btr0pcur.h"
|
||||
|
||||
os_file_t files[1000];
|
||||
|
||||
mutex_t ios_mutex;
|
||||
ulint ios;
|
||||
ulint n[10];
|
||||
|
||||
mutex_t incs_mutex;
|
||||
ulint incs;
|
||||
|
||||
byte bigbuf[1000000];
|
||||
|
||||
#define N_SPACES 1
|
||||
#define N_FILES 2
|
||||
#define FILE_SIZE 1000 /* must be > 512 */
|
||||
#define POOL_SIZE 1000
|
||||
#define COUNTER_OFFSET 1500
|
||||
|
||||
#define LOOP_SIZE 150
|
||||
#define N_THREADS 5
|
||||
|
||||
|
||||
ulint zero = 0;
|
||||
|
||||
buf_block_t* bl_arr[POOL_SIZE];
|
||||
|
||||
/************************************************************************
|
||||
Io-handler thread function. */
|
||||
|
||||
ulint
|
||||
handler_thread(
|
||||
/*===========*/
|
||||
void* arg)
|
||||
{
|
||||
ulint segment;
|
||||
void* mess;
|
||||
ulint i;
|
||||
bool ret;
|
||||
|
||||
segment = *((ulint*)arg);
|
||||
|
||||
printf("Io handler thread %lu starts\n", segment);
|
||||
|
||||
for (i = 0;; i++) {
|
||||
ret = fil_aio_wait(segment, &mess);
|
||||
ut_a(ret);
|
||||
|
||||
buf_page_io_complete((buf_block_t*)mess);
|
||||
|
||||
mutex_enter(&ios_mutex);
|
||||
ios++;
|
||||
mutex_exit(&ios_mutex);
|
||||
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Creates the files for the file system test and inserts them to
|
||||
the file system. */
|
||||
|
||||
void
|
||||
create_files(void)
|
||||
/*==============*/
|
||||
{
|
||||
bool ret;
|
||||
ulint i, k;
|
||||
char name[20];
|
||||
os_thread_t thr[5];
|
||||
os_thread_id_t id[5];
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("Create or open database files\n");
|
||||
|
||||
strcpy(name, "j:\\tsfile00");
|
||||
|
||||
for (k = 0; k < N_SPACES; k++) {
|
||||
for (i = 0; i < N_FILES; i++) {
|
||||
|
||||
name[9] = (char)((ulint)'0' + k);
|
||||
name[10] = (char)((ulint)'0' + i);
|
||||
|
||||
files[i] = os_file_create(name, OS_FILE_CREATE,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
if (ret == FALSE) {
|
||||
ut_a(os_file_get_last_error() ==
|
||||
OS_FILE_ALREADY_EXISTS);
|
||||
|
||||
files[i] = os_file_create(
|
||||
name, OS_FILE_OPEN,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
ut_a(ret);
|
||||
}
|
||||
|
||||
ret = os_file_close(files[i]);
|
||||
ut_a(ret);
|
||||
|
||||
if (i == 0) {
|
||||
fil_space_create(name, k, OS_FILE_TABLESPACE);
|
||||
}
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
fil_node_create(name, FILE_SIZE, k);
|
||||
}
|
||||
}
|
||||
|
||||
ios = 0;
|
||||
|
||||
mutex_create(&ios_mutex);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
n[i] = i;
|
||||
|
||||
thr[i] = os_thread_create(handler_thread, n + i, id + i);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Inits space header of space 0. */
|
||||
|
||||
void
|
||||
init_space(void)
|
||||
/*============*/
|
||||
{
|
||||
mtr_t mtr;
|
||||
|
||||
printf("Init space header\n");
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
fsp_header_init(0, FILE_SIZE * N_FILES, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Test for index page. */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
dtuple_t* tuple;
|
||||
mem_heap_t* heap;
|
||||
ulint rnd = 0;
|
||||
dict_index_t* index;
|
||||
dict_table_t* table;
|
||||
dict_tree_t* tree;
|
||||
mtr_t mtr;
|
||||
byte buf[8];
|
||||
ulint i;
|
||||
ulint tm, oldtm;
|
||||
btr_pcur_t cursor;
|
||||
|
||||
printf("-------------------------------------------------\n");
|
||||
printf("TEST 1. Basic test\n");
|
||||
|
||||
heap = mem_heap_create(0);
|
||||
|
||||
table = dict_mem_table_create("TS_TABLE1", 2);
|
||||
|
||||
dict_mem_table_add_col(table, "COL1", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
|
||||
dict_mem_table_add_col(table, "COL2", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
|
||||
|
||||
dict_table_add_to_cache(table);
|
||||
|
||||
index = dict_mem_index_create("TS_TABLE1", "IND1", 0, 2, 0);
|
||||
|
||||
dict_mem_index_add_field(index, "COL1", 0);
|
||||
dict_mem_index_add_field(index, "COL2", 0);
|
||||
|
||||
dict_index_add_to_cache(index);
|
||||
|
||||
index = dict_index_get("TS_TABLE1", "IND1");
|
||||
ut_a(index);
|
||||
|
||||
tree = dict_index_get_tree(index);
|
||||
|
||||
tuple = dtuple_create(heap, 3);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
btr_root_create(tree, 0, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
dtuple_gen_test_tuple3(tuple, 0, buf);
|
||||
btr_insert(tree, tuple, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
rnd = 90000;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
if (i == 77000) {
|
||||
rnd = rnd % 200000;
|
||||
}
|
||||
|
||||
rnd = (rnd + 15675751) % 200000;
|
||||
|
||||
dtuple_gen_test_tuple3(tuple, rnd, buf);
|
||||
|
||||
btr_insert(tree, tuple, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
rnd = 90000;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
if (i == 50000) {
|
||||
rnd = rnd % 200000;
|
||||
}
|
||||
|
||||
rnd = (rnd + 595659561) % 200000;
|
||||
|
||||
dtuple_gen_test_tuple3(tuple, rnd, buf);
|
||||
|
||||
btr_pcur_open(tree, tuple, PAGE_CUR_GE,
|
||||
BTR_SEARCH_LEAF, &cursor, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
rnd = 0;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
rnd = (rnd + 35608971) % 200000 + 1;
|
||||
|
||||
dtuple_gen_test_tuple3(tuple, rnd, buf);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
/* btr_print_tree(tree, 3); */
|
||||
|
||||
mem_heap_free(heap);
|
||||
}
|
||||
|
||||
|
||||
#ifdef notdefined
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_create(0, 5, &mtr);
|
||||
buf_page_x_lock(block, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
for (i = 0; i < 512; i++) {
|
||||
|
||||
rnd = (rnd + 534671) % 512;
|
||||
|
||||
if (i % 27 == 0) {
|
||||
ut_a(page_validate(page, index));
|
||||
}
|
||||
|
||||
dtuple_gen_test_tuple(tuple, rnd);
|
||||
|
||||
/* dtuple_print(tuple);*/
|
||||
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
|
||||
ut_a(rec);
|
||||
|
||||
rec_validate(rec);
|
||||
/* page_print_list(page, 151); */
|
||||
}
|
||||
|
||||
/* page_print_list(page, 151); */
|
||||
|
||||
ut_a(page_validate(page, index));
|
||||
ut_a(page_get_n_recs(page) == 512);
|
||||
|
||||
for (i = 0; i < 512; i++) {
|
||||
|
||||
rnd = (rnd + 7771) % 512;
|
||||
|
||||
if (i % 27 == 0) {
|
||||
ut_a(page_validate(page, index));
|
||||
}
|
||||
|
||||
dtuple_gen_test_tuple(tuple, rnd);
|
||||
|
||||
/* dtuple_print(tuple);*/
|
||||
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
page_cur_delete_rec(&cursor, &mtr);
|
||||
|
||||
ut_a(rec);
|
||||
|
||||
rec_validate(rec);
|
||||
/* page_print_list(page, 151); */
|
||||
}
|
||||
|
||||
ut_a(page_get_n_recs(page) == 0);
|
||||
|
||||
ut_a(page_validate(page, index));
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
rnd = 311;
|
||||
|
||||
for (i = 0; i < 512; i++) {
|
||||
|
||||
rnd = (rnd + 1) % 512;
|
||||
|
||||
if (i % 27 == 0) {
|
||||
ut_a(page_validate(page, index));
|
||||
}
|
||||
|
||||
dtuple_gen_test_tuple(tuple, rnd);
|
||||
|
||||
/* dtuple_print(tuple);*/
|
||||
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
|
||||
ut_a(rec);
|
||||
|
||||
rec_validate(rec);
|
||||
/* page_print_list(page, 151); */
|
||||
}
|
||||
|
||||
ut_a(page_validate(page, index));
|
||||
ut_a(page_get_n_recs(page) == 512);
|
||||
|
||||
rnd = 217;
|
||||
|
||||
for (i = 0; i < 512; i++) {
|
||||
|
||||
rnd = (rnd + 1) % 512;
|
||||
|
||||
if (i % 27 == 0) {
|
||||
ut_a(page_validate(page, index));
|
||||
}
|
||||
|
||||
dtuple_gen_test_tuple(tuple, rnd);
|
||||
|
||||
/* dtuple_print(tuple);*/
|
||||
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
page_cur_delete_rec(&cursor, &mtr);
|
||||
|
||||
ut_a(rec);
|
||||
|
||||
rec_validate(rec);
|
||||
/* page_print_list(page, 151); */
|
||||
}
|
||||
|
||||
ut_a(page_validate(page, index));
|
||||
ut_a(page_get_n_recs(page) == 0);
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
rnd = 291;
|
||||
|
||||
for (i = 0; i < 512; i++) {
|
||||
|
||||
rnd = (rnd - 1) % 512;
|
||||
|
||||
if (i % 27 == 0) {
|
||||
ut_a(page_validate(page, index));
|
||||
}
|
||||
|
||||
dtuple_gen_test_tuple(tuple, rnd);
|
||||
|
||||
/* dtuple_print(tuple);*/
|
||||
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
|
||||
ut_a(rec);
|
||||
|
||||
rec_validate(rec);
|
||||
/* page_print_list(page, 151); */
|
||||
}
|
||||
|
||||
ut_a(page_validate(page, index));
|
||||
ut_a(page_get_n_recs(page) == 512);
|
||||
|
||||
rnd = 277;
|
||||
|
||||
for (i = 0; i < 512; i++) {
|
||||
|
||||
rnd = (rnd - 1) % 512;
|
||||
|
||||
if (i % 27 == 0) {
|
||||
ut_a(page_validate(page, index));
|
||||
}
|
||||
|
||||
dtuple_gen_test_tuple(tuple, rnd);
|
||||
|
||||
/* dtuple_print(tuple);*/
|
||||
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
page_cur_delete_rec(&cursor, &mtr);
|
||||
|
||||
ut_a(rec);
|
||||
|
||||
rec_validate(rec);
|
||||
/* page_print_list(page, 151); */
|
||||
}
|
||||
|
||||
ut_a(page_validate(page, index));
|
||||
ut_a(page_get_n_recs(page) == 0);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
mem_heap_free(heap);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Test for index page. */
|
||||
|
||||
void
|
||||
test2(void)
|
||||
/*=======*/
|
||||
{
|
||||
page_t* page;
|
||||
dtuple_t* tuple;
|
||||
mem_heap_t* heap;
|
||||
ulint i, j;
|
||||
ulint rnd = 0;
|
||||
rec_t* rec;
|
||||
page_cur_t cursor;
|
||||
dict_index_t* index;
|
||||
dict_table_t* table;
|
||||
buf_block_t* block;
|
||||
buf_frame_t* frame;
|
||||
ulint tm, oldtm;
|
||||
byte buf[8];
|
||||
mtr_t mtr;
|
||||
|
||||
printf("-------------------------------------------------\n");
|
||||
printf("TEST 2. Speed test\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
ut_memcpy(bigbuf, bigbuf + 800, 800);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for %lu mem copys of 800 bytes %lu millisecs\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rnd = 0;
|
||||
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
ut_memcpy(bigbuf + rnd, bigbuf + rnd + 800, 800);
|
||||
rnd += 1600;
|
||||
if (rnd > 995000) {
|
||||
rnd = 0;
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for %lu mem copys of 800 bytes %lu millisecs\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
heap = mem_heap_create(0);
|
||||
|
||||
table = dict_table_create("TS_TABLE2", 2);
|
||||
|
||||
dict_table_add_col(table, "COL1", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
|
||||
dict_table_add_col(table, "COL2", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
|
||||
|
||||
ut_a(0 == dict_table_publish(table));
|
||||
|
||||
index = dict_index_create("TS_TABLE2", "IND2", 0, 2, 0);
|
||||
|
||||
dict_index_add_field(index, "COL1", 0);
|
||||
dict_index_add_field(index, "COL2", 0);
|
||||
|
||||
ut_a(0 == dict_index_publish(index));
|
||||
|
||||
index = dict_index_get("TS_TABLE2", "IND2");
|
||||
ut_a(index);
|
||||
|
||||
tuple = dtuple_create(heap, 2);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rnd = 677;
|
||||
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_create(0, 5, &mtr);
|
||||
buf_page_x_lock(block, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
for (j = 0; j < 250; j++) {
|
||||
rnd = (rnd + 54841) % 1000;
|
||||
dtuple_gen_test_tuple2(tuple, rnd, buf);
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
ut_a(rec);
|
||||
}
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for insertion of %lu recs %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_get(0, 5, &mtr);
|
||||
buf_page_s_lock(block, &mtr);
|
||||
|
||||
page = buf_block_get_frame(block);
|
||||
ut_a(page_validate(page, index));
|
||||
mtr_commit(&mtr);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rnd = 677;
|
||||
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_create(0, 5, &mtr);
|
||||
buf_page_x_lock(block, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
for (j = 0; j < 250; j++) {
|
||||
rnd = (rnd + 54841) % 1000;
|
||||
dtuple_gen_test_tuple2(tuple, rnd, buf);
|
||||
}
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf(
|
||||
"Wall time for %lu empty loops with page create %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_create(0, 5, &mtr);
|
||||
buf_page_x_lock(block, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
rnd = 100;
|
||||
for (j = 0; j < 250; j++) {
|
||||
rnd = (rnd + 1) % 1000;
|
||||
dtuple_gen_test_tuple2(tuple, rnd, buf);
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
ut_a(rec);
|
||||
}
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf(
|
||||
"Wall time for sequential insertion of %lu recs %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_create(0, 5, &mtr);
|
||||
buf_page_x_lock(block, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
rnd = 500;
|
||||
for (j = 0; j < 250; j++) {
|
||||
rnd = (rnd - 1) % 1000;
|
||||
dtuple_gen_test_tuple2(tuple, rnd, buf);
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
ut_a(rec);
|
||||
}
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf(
|
||||
"Wall time for descend. seq. insertion of %lu recs %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_create(0, 5, &mtr);
|
||||
buf_page_x_lock(block, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
rnd = 677;
|
||||
|
||||
for (j = 0; j < 250; j++) {
|
||||
rnd = (rnd + 54841) % 1000;
|
||||
dtuple_gen_test_tuple2(tuple, rnd, buf);
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
ut_a(rec);
|
||||
}
|
||||
|
||||
rnd = 677;
|
||||
for (j = 0; j < 250; j++) {
|
||||
rnd = (rnd + 54841) % 1000;
|
||||
dtuple_gen_test_tuple2(tuple, rnd, buf);
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
page_cur_delete_rec(&cursor, &mtr);
|
||||
}
|
||||
ut_a(page_get_n_recs(page) == 0);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for insert and delete of %lu recs %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_create(0, 5, &mtr);
|
||||
buf_page_x_lock(block, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
rnd = 677;
|
||||
|
||||
for (j = 0; j < 250; j++) {
|
||||
rnd = (rnd + 54841) % 1000;
|
||||
dtuple_gen_test_tuple2(tuple, rnd, buf);
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
ut_a(rec);
|
||||
}
|
||||
ut_a(page_validate(page, index));
|
||||
mtr_print(&mtr);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
rnd = 677;
|
||||
for (j = 0; j < 250; j++) {
|
||||
rnd = (rnd + 54841) % 1000;
|
||||
dtuple_gen_test_tuple2(tuple, rnd, buf);
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for search of %lu recs %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
rnd = 677;
|
||||
for (j = 0; j < 250; j++) {
|
||||
rnd = (rnd + 54841) % 1000;
|
||||
dtuple_gen_test_tuple2(tuple, rnd, buf);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for %lu empty loops %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/********************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
|
||||
sync_init();
|
||||
mem_init();
|
||||
os_aio_init(160, 5);
|
||||
fil_init(25);
|
||||
buf_pool_init(POOL_SIZE, POOL_SIZE);
|
||||
dict_init();
|
||||
fsp_init();
|
||||
log_init();
|
||||
|
||||
create_files();
|
||||
|
||||
init_space();
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
ut_rnd_set_seed(19);
|
||||
|
||||
test1();
|
||||
|
||||
/* mem_print_info(); */
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,802 +0,0 @@
|
||||
/************************************************************************
|
||||
Test for the B-tree
|
||||
|
||||
(c) 1994-1997 Innobase Oy
|
||||
|
||||
Created 2/16/1996 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "os0proc.h"
|
||||
#include "sync0sync.h"
|
||||
#include "ut0mem.h"
|
||||
#include "mem0mem.h"
|
||||
#include "mem0pool.h"
|
||||
#include "data0data.h"
|
||||
#include "data0type.h"
|
||||
#include "dict0dict.h"
|
||||
#include "buf0buf.h"
|
||||
#include "os0file.h"
|
||||
#include "os0thread.h"
|
||||
#include "fil0fil.h"
|
||||
#include "fsp0fsp.h"
|
||||
#include "rem0rec.h"
|
||||
#include "rem0cmp.h"
|
||||
#include "mtr0mtr.h"
|
||||
#include "log0log.h"
|
||||
#include "page0page.h"
|
||||
#include "page0cur.h"
|
||||
#include "trx0trx.h"
|
||||
#include "dict0boot.h"
|
||||
#include "trx0sys.h"
|
||||
#include "dict0crea.h"
|
||||
#include "btr0btr.h"
|
||||
#include "btr0pcur.h"
|
||||
#include "btr0cur.h"
|
||||
#include "btr0sea.h"
|
||||
#include "rem0rec.h"
|
||||
#include "srv0srv.h"
|
||||
#include "que0que.h"
|
||||
#include "com0com.h"
|
||||
#include "usr0sess.h"
|
||||
#include "lock0lock.h"
|
||||
#include "trx0roll.h"
|
||||
#include "trx0purge.h"
|
||||
#include "row0ins.h"
|
||||
#include "row0upd.h"
|
||||
#include "row0row.h"
|
||||
#include "row0del.h"
|
||||
#include "lock0lock.h"
|
||||
#include "ibuf0ibuf.h"
|
||||
|
||||
os_file_t files[1000];
|
||||
|
||||
mutex_t ios_mutex;
|
||||
ulint ios;
|
||||
ulint n[10];
|
||||
|
||||
mutex_t incs_mutex;
|
||||
ulint incs;
|
||||
|
||||
#define N_SPACES 2 /* must be >= 2 */
|
||||
#define N_FILES 1
|
||||
#define FILE_SIZE 8096 /* must be > 512 */
|
||||
#define POOL_SIZE 1024
|
||||
#define IBUF_SIZE 200
|
||||
#define COUNTER_OFFSET 1500
|
||||
|
||||
#define LOOP_SIZE 150
|
||||
#define N_THREADS 5
|
||||
|
||||
#define COUNT 1
|
||||
|
||||
ulint zero = 0;
|
||||
|
||||
buf_block_t* bl_arr[POOL_SIZE];
|
||||
|
||||
ulint dummy = 0;
|
||||
|
||||
byte test_buf[8000];
|
||||
|
||||
/************************************************************************
|
||||
Io-handler thread function. */
|
||||
|
||||
ulint
|
||||
handler_thread(
|
||||
/*===========*/
|
||||
void* arg)
|
||||
{
|
||||
ulint segment;
|
||||
void* mess;
|
||||
ulint i;
|
||||
bool ret;
|
||||
|
||||
segment = *((ulint*)arg);
|
||||
|
||||
printf("Io handler thread %lu starts\n", segment);
|
||||
|
||||
for (i = 0;; i++) {
|
||||
ret = fil_aio_wait(segment, &mess);
|
||||
ut_a(ret);
|
||||
|
||||
buf_page_io_complete((buf_block_t*)mess);
|
||||
|
||||
mutex_enter(&ios_mutex);
|
||||
ios++;
|
||||
mutex_exit(&ios_mutex);
|
||||
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Creates the files for the file system test and inserts them to the file
|
||||
system. */
|
||||
|
||||
void
|
||||
create_files(void)
|
||||
/*==============*/
|
||||
{
|
||||
bool ret;
|
||||
ulint i, k;
|
||||
char name[20];
|
||||
os_thread_t thr[10];
|
||||
os_thread_id_t id[10];
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("Create or open database files\n");
|
||||
|
||||
strcpy(name, "tsfile00");
|
||||
|
||||
for (k = 0; k < N_SPACES; k++) {
|
||||
for (i = 0; i < N_FILES; i++) {
|
||||
|
||||
name[6] = (char)((ulint)'0' + k);
|
||||
name[7] = (char)((ulint)'0' + i);
|
||||
|
||||
files[i] = os_file_create(name, OS_FILE_CREATE,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
if (ret == FALSE) {
|
||||
ut_a(os_file_get_last_error() ==
|
||||
OS_FILE_ALREADY_EXISTS);
|
||||
|
||||
files[i] = os_file_create(
|
||||
name, OS_FILE_OPEN,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
ut_a(ret);
|
||||
} else {
|
||||
if (k == 1) {
|
||||
ut_a(os_file_set_size(files[i],
|
||||
8192 * IBUF_SIZE, 0));
|
||||
} else {
|
||||
ut_a(os_file_set_size(files[i],
|
||||
8192 * FILE_SIZE, 0));
|
||||
}
|
||||
}
|
||||
|
||||
ret = os_file_close(files[i]);
|
||||
ut_a(ret);
|
||||
|
||||
if (i == 0) {
|
||||
fil_space_create(name, k, OS_FILE_TABLESPACE);
|
||||
}
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
fil_node_create(name, FILE_SIZE, k);
|
||||
}
|
||||
}
|
||||
|
||||
ios = 0;
|
||||
|
||||
mutex_create(&ios_mutex);
|
||||
mutex_set_level(&ios_mutex, SYNC_NO_ORDER_CHECK);
|
||||
|
||||
for (i = 0; i < 9; i++) {
|
||||
n[i] = i;
|
||||
|
||||
thr[i] = os_thread_create(handler_thread, n + i, id + i);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Inits space headers of spaces 0 and 1. */
|
||||
|
||||
void
|
||||
init_spaces(void)
|
||||
/*=============*/
|
||||
{
|
||||
mtr_t mtr;
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
fsp_header_init(0, FILE_SIZE * N_FILES, &mtr);
|
||||
fsp_header_init(1, IBUF_SIZE, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Test for table creation. */
|
||||
|
||||
ulint
|
||||
test1(
|
||||
/*==*/
|
||||
void* arg)
|
||||
{
|
||||
sess_t* sess;
|
||||
com_endpoint_t* com_endpoint;
|
||||
mem_heap_t* heap;
|
||||
dict_index_t* index;
|
||||
dict_table_t* table;
|
||||
que_fork_t* fork;
|
||||
que_thr_t* thr;
|
||||
trx_t* trx;
|
||||
|
||||
UT_NOT_USED(arg);
|
||||
|
||||
printf("-------------------------------------------------\n");
|
||||
printf("TEST 1. CREATE TABLE WITH 3 COLUMNS AND WITH 3 INDEXES\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);
|
||||
|
||||
ut_a(trx_start(trx, ULINT_UNDEFINED));
|
||||
|
||||
table = dict_mem_table_create("TS_TABLE1", 0, 3);
|
||||
|
||||
dict_mem_table_add_col(table, "COL1", DATA_VARCHAR,
|
||||
DATA_ENGLISH, 10, 0);
|
||||
dict_mem_table_add_col(table, "COL2", DATA_VARCHAR,
|
||||
DATA_ENGLISH, 10, 0);
|
||||
dict_mem_table_add_col(table, "COL3", DATA_VARCHAR,
|
||||
DATA_ENGLISH, 100, 0);
|
||||
/*------------------------------------*/
|
||||
/* CREATE TABLE */
|
||||
|
||||
fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap);
|
||||
fork->trx = trx;
|
||||
|
||||
thr = que_thr_create(fork, fork, heap);
|
||||
|
||||
thr->child = tab_create_graph_create(fork, thr, table, 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);
|
||||
|
||||
que_run_threads(thr);
|
||||
|
||||
/* dict_table_print_by_name("SYS_TABLES");
|
||||
dict_table_print_by_name("SYS_COLUMNS"); */
|
||||
/*-------------------------------------*/
|
||||
/* CREATE CLUSTERED INDEX */
|
||||
|
||||
index = dict_mem_index_create("TS_TABLE1", "IND1", 0,
|
||||
DICT_UNIQUE | DICT_CLUSTERED, 1);
|
||||
dict_mem_index_add_field(index, "COL1", 0);
|
||||
|
||||
ut_a(mem_heap_validate(index->heap));
|
||||
|
||||
fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap);
|
||||
fork->trx = trx;
|
||||
|
||||
thr = que_thr_create(fork, fork, heap);
|
||||
|
||||
thr->child = ind_create_graph_create(fork, thr, index, 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);
|
||||
|
||||
que_run_threads(thr);
|
||||
|
||||
/* dict_table_print_by_name("SYS_INDEXES");
|
||||
dict_table_print_by_name("SYS_FIELDS"); */
|
||||
|
||||
/*-------------------------------------*/
|
||||
/* CREATE SECONDARY INDEX */
|
||||
|
||||
index = dict_mem_index_create("TS_TABLE1", "IND2", 0, 0, 1);
|
||||
|
||||
dict_mem_index_add_field(index, "COL2", 0);
|
||||
|
||||
ut_a(mem_heap_validate(index->heap));
|
||||
|
||||
fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap);
|
||||
fork->trx = trx;
|
||||
|
||||
thr = que_thr_create(fork, fork, heap);
|
||||
|
||||
thr->child = ind_create_graph_create(fork, thr, index, 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);
|
||||
|
||||
que_run_threads(thr);
|
||||
|
||||
/* dict_table_print_by_name("SYS_INDEXES");
|
||||
dict_table_print_by_name("SYS_FIELDS"); */
|
||||
|
||||
/*-------------------------------------*/
|
||||
/* CREATE ANOTHER SECONDARY INDEX */
|
||||
|
||||
index = dict_mem_index_create("TS_TABLE1", "IND3", 0, 0, 1);
|
||||
|
||||
dict_mem_index_add_field(index, "COL2", 0);
|
||||
|
||||
ut_a(mem_heap_validate(index->heap));
|
||||
|
||||
fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap);
|
||||
fork->trx = trx;
|
||||
|
||||
thr = que_thr_create(fork, fork, heap);
|
||||
|
||||
thr->child = ind_create_graph_create(fork, thr, index, 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);
|
||||
|
||||
que_run_threads(thr);
|
||||
|
||||
#ifdef notdefined
|
||||
/*-------------------------------------*/
|
||||
/* CREATE YET ANOTHER SECONDARY INDEX */
|
||||
|
||||
index = dict_mem_index_create("TS_TABLE1", "IND4", 0, 0, 1);
|
||||
|
||||
dict_mem_index_add_field(index, "COL2", 0);
|
||||
|
||||
ut_a(mem_heap_validate(index->heap));
|
||||
|
||||
fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap);
|
||||
fork->trx = trx;
|
||||
|
||||
thr = que_thr_create(fork, fork, heap);
|
||||
|
||||
thr->child = ind_create_graph_create(fork, thr, index, 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);
|
||||
|
||||
que_run_threads(thr);
|
||||
#endif
|
||||
/* dict_table_print_by_name("SYS_INDEXES");
|
||||
dict_table_print_by_name("SYS_FIELDS"); */
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Another test for inserts. */
|
||||
|
||||
ulint
|
||||
test2_1(
|
||||
/*====*/
|
||||
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;
|
||||
byte buf[100];
|
||||
ins_node_t* node;
|
||||
ulint count = 0;
|
||||
ulint rnd;
|
||||
dtuple_t* row;
|
||||
dict_index_t* index;
|
||||
/* dict_tree_t* tree;
|
||||
dtuple_t* entry;
|
||||
btr_pcur_t pcur;
|
||||
mtr_t mtr; */
|
||||
|
||||
printf("-------------------------------------------------\n");
|
||||
printf("TEST 2.1. MASSIVE ASCENDING 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 = 0;
|
||||
|
||||
log_print();
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < *((ulint*)arg); i++) {
|
||||
|
||||
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 % 5000 == 0) {
|
||||
/* ibuf_print(); */
|
||||
/* buf_print(); */
|
||||
|
||||
/* buf_print_io(); */
|
||||
/*
|
||||
tm = ut_clock();
|
||||
printf("Wall time for %lu inserts %lu milliseconds\n",
|
||||
i, tm - oldtm); */
|
||||
}
|
||||
|
||||
rnd = rnd + 1;
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for %lu inserts %lu milliseconds\n", i, tm - oldtm);
|
||||
|
||||
log_print();
|
||||
|
||||
/* dict_table_print_by_name("TS_TABLE1"); */
|
||||
|
||||
/* ibuf_print(); */
|
||||
|
||||
index = index;
|
||||
|
||||
index = dict_table_get_first_index(table);
|
||||
|
||||
if (zero) {
|
||||
btr_search_index_print_info(index);
|
||||
}
|
||||
|
||||
btr_validate_tree(dict_index_get_tree(index));
|
||||
|
||||
#ifdef notdefined
|
||||
index = dict_table_get_next_index(index);
|
||||
|
||||
if (zero) {
|
||||
btr_search_index_print_info(index);
|
||||
}
|
||||
|
||||
btr_validate_tree(dict_index_get_tree(index));
|
||||
|
||||
index = dict_table_get_next_index(index);
|
||||
|
||||
/* btr_search_index_print_info(index); */
|
||||
|
||||
btr_validate_tree(dict_index_get_tree(index));
|
||||
|
||||
/* dict_table_print_by_name("TS_TABLE1"); */
|
||||
|
||||
/* Check inserted entries */
|
||||
|
||||
btr_search_print_info();
|
||||
|
||||
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, 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);
|
||||
|
||||
printf("Validating tree\n");
|
||||
btr_validate_tree(tree);
|
||||
printf("Validated\n");
|
||||
#endif
|
||||
/*-------------------------------------*/
|
||||
/* ROLLBACK */
|
||||
|
||||
#ifdef notdefined
|
||||
/* btr_validate_tree(tree); */
|
||||
|
||||
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);
|
||||
|
||||
/* dict_table_print_by_name("TS_TABLE1"); */
|
||||
|
||||
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);
|
||||
|
||||
btr_search_print_info();
|
||||
#endif
|
||||
/*-------------------------------------*/
|
||||
/* 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);
|
||||
/*-------------------------------------*/
|
||||
|
||||
count++;
|
||||
/* btr_validate_tree(tree); */
|
||||
|
||||
if (count < 1) {
|
||||
goto loop;
|
||||
}
|
||||
|
||||
mem_heap_free(heap);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
os_thread_id_t id[10];
|
||||
ulint n1000[10];
|
||||
ulint i;
|
||||
ulint n5000 = 500;
|
||||
ulint n2;
|
||||
|
||||
/* buf_debug_prints = TRUE; */
|
||||
log_do_write = TRUE;
|
||||
|
||||
srv_boot("initfile");
|
||||
os_aio_init(576, 9, 100);
|
||||
fil_init(25);
|
||||
buf_pool_init(POOL_SIZE, POOL_SIZE);
|
||||
fsp_init();
|
||||
log_init();
|
||||
lock_sys_create(1024);
|
||||
|
||||
create_files();
|
||||
|
||||
init_spaces();
|
||||
|
||||
sess_sys_init_at_db_start();
|
||||
|
||||
trx_sys_create();
|
||||
|
||||
dict_create();
|
||||
|
||||
/* os_thread_sleep(500000); */
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
ut_rnd_set_seed(19);
|
||||
|
||||
test1(NULL);
|
||||
|
||||
/* for (i = 0; i < 2; i++) {
|
||||
|
||||
n1000[i] = i;
|
||||
id[i] = id[i];
|
||||
|
||||
os_thread_create(test10mt, n1000 + i, id + i);
|
||||
}
|
||||
*/
|
||||
i = 4;
|
||||
|
||||
n1000[i] = i;
|
||||
id[i] = id[i];
|
||||
|
||||
/* os_thread_create(test10_4, n1000 + i, id + i); */
|
||||
|
||||
i = 5;
|
||||
|
||||
/* test10mt(&i);
|
||||
|
||||
i = 6;
|
||||
|
||||
test10mt(&i);
|
||||
|
||||
trx_purge();
|
||||
printf("%lu pages purged\n", purge_sys->n_pages_handled);
|
||||
|
||||
dict_table_print_by_name("TS_TABLE1"); */
|
||||
|
||||
/* os_thread_create(test_measure_cont, &n3, id + 0); */
|
||||
|
||||
/* mem_print_info(); */
|
||||
|
||||
/* dict_table_print_by_name("TS_TABLE1"); */
|
||||
|
||||
log_flush_up_to(ut_dulint_zero);
|
||||
|
||||
os_thread_sleep(500000);
|
||||
|
||||
n2 = 10000;
|
||||
|
||||
test2_1(&n2);
|
||||
|
||||
/* test9A(&n2);
|
||||
test9(&n2); */
|
||||
|
||||
/* test6(&n2); */
|
||||
|
||||
/* test2(&n2); */
|
||||
|
||||
/* test2_2(&n2); */
|
||||
|
||||
/* mem_print_info(); */
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
|
||||
n1000[i] = 1000 + 10 * i;
|
||||
id[i] = id[i];
|
||||
|
||||
/* os_thread_create(test2mt, n1000 + i, id + i);
|
||||
os_thread_create(test2_1mt, n1000 + i, id + i);
|
||||
os_thread_create(test2_2mt, n1000 + i, id + i); */
|
||||
}
|
||||
|
||||
n2 = 2000;
|
||||
|
||||
/* test2mt(&n2); */
|
||||
|
||||
/* buf_print();
|
||||
ibuf_print();
|
||||
rw_lock_list_print_info();
|
||||
mutex_list_print_info();
|
||||
|
||||
dict_table_print_by_name("TS_TABLE1"); */
|
||||
|
||||
/* mem_print_info(); */
|
||||
|
||||
n2 = 1000;
|
||||
|
||||
/* test4_1();
|
||||
test4_2();
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
n1000[i] = i;
|
||||
id[i] = id[i];
|
||||
os_thread_create(test4mt, n1000 + i, id + i);
|
||||
}
|
||||
|
||||
n2 = 4;
|
||||
test4mt(&n2);
|
||||
test4mt(&n2);
|
||||
test4_2();
|
||||
lock_print_info(); */
|
||||
|
||||
/* test7(&n2); */
|
||||
|
||||
/* os_thread_sleep(25000000); */
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,397 +0,0 @@
|
||||
/************************************************************************
|
||||
Test for the server
|
||||
|
||||
(c) 1996-1997 Innobase Oy
|
||||
|
||||
Created 2/16/1996 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "os0proc.h"
|
||||
#include "sync0sync.h"
|
||||
#include "ut0mem.h"
|
||||
#include "mem0mem.h"
|
||||
#include "mem0pool.h"
|
||||
#include "data0data.h"
|
||||
#include "data0type.h"
|
||||
#include "dict0dict.h"
|
||||
#include "buf0buf.h"
|
||||
#include "buf0flu.h"
|
||||
#include "os0file.h"
|
||||
#include "os0thread.h"
|
||||
#include "fil0fil.h"
|
||||
#include "fsp0fsp.h"
|
||||
#include "rem0rec.h"
|
||||
#include "rem0cmp.h"
|
||||
#include "mtr0mtr.h"
|
||||
#include "log0log.h"
|
||||
#include "log0recv.h"
|
||||
#include "page0page.h"
|
||||
#include "page0cur.h"
|
||||
#include "trx0trx.h"
|
||||
#include "dict0boot.h"
|
||||
#include "trx0sys.h"
|
||||
#include "dict0crea.h"
|
||||
#include "btr0btr.h"
|
||||
#include "btr0pcur.h"
|
||||
#include "btr0cur.h"
|
||||
#include "btr0sea.h"
|
||||
#include "rem0rec.h"
|
||||
#include "srv0srv.h"
|
||||
#include "que0que.h"
|
||||
#include "com0com.h"
|
||||
#include "usr0sess.h"
|
||||
#include "lock0lock.h"
|
||||
#include "trx0roll.h"
|
||||
#include "trx0purge.h"
|
||||
#include "row0ins.h"
|
||||
#include "row0sel.h"
|
||||
#include "row0upd.h"
|
||||
#include "row0row.h"
|
||||
#include "lock0lock.h"
|
||||
#include "ibuf0ibuf.h"
|
||||
#include "pars0pars.h"
|
||||
#include "btr0sea.h"
|
||||
|
||||
bool measure_cont = FALSE;
|
||||
|
||||
os_file_t files[1000];
|
||||
|
||||
mutex_t ios_mutex;
|
||||
ulint ios;
|
||||
ulint n[10];
|
||||
|
||||
mutex_t incs_mutex;
|
||||
ulint incs;
|
||||
|
||||
byte rnd_buf[67000];
|
||||
|
||||
|
||||
/************************************************************************
|
||||
Io-handler thread function. */
|
||||
|
||||
ulint
|
||||
handler_thread(
|
||||
/*===========*/
|
||||
void* arg)
|
||||
{
|
||||
ulint segment;
|
||||
ulint i;
|
||||
|
||||
segment = *((ulint*)arg);
|
||||
|
||||
printf("Io handler thread %lu starts\n", segment);
|
||||
|
||||
for (i = 0;; i++) {
|
||||
fil_aio_wait(segment);
|
||||
|
||||
mutex_enter(&ios_mutex);
|
||||
ios++;
|
||||
mutex_exit(&ios_mutex);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Creates or opens the log files. */
|
||||
|
||||
void
|
||||
create_log_files(void)
|
||||
/*==================*/
|
||||
{
|
||||
bool ret;
|
||||
ulint i, k;
|
||||
char name[20];
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("Create or open log files\n");
|
||||
|
||||
strcpy(name, "logfile00");
|
||||
|
||||
for (k = 0; k < srv_n_log_groups; k++) {
|
||||
|
||||
for (i = 0; i < srv_n_log_files; i++) {
|
||||
|
||||
name[6] = (char)((ulint)'0' + k);
|
||||
name[7] = (char)((ulint)'0' + i);
|
||||
|
||||
files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_AIO,
|
||||
&ret);
|
||||
if (ret == FALSE) {
|
||||
ut_a(os_file_get_last_error() ==
|
||||
OS_FILE_ALREADY_EXISTS);
|
||||
|
||||
files[i] = os_file_create(
|
||||
name, OS_FILE_OPEN, OS_FILE_AIO, &ret);
|
||||
ut_a(ret);
|
||||
} else {
|
||||
ut_a(os_file_set_size(files[i],
|
||||
8192 * srv_log_file_size, 0));
|
||||
}
|
||||
|
||||
ret = os_file_close(files[i]);
|
||||
ut_a(ret);
|
||||
|
||||
if (i == 0) {
|
||||
fil_space_create(name, k + 100, FIL_LOG);
|
||||
}
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
fil_node_create(name, srv_log_file_size, k + 100);
|
||||
}
|
||||
|
||||
fil_space_create(name, k + 200, FIL_LOG);
|
||||
|
||||
log_group_init(k, srv_n_log_files,
|
||||
srv_log_file_size * UNIV_PAGE_SIZE,
|
||||
k + 100, k + 200);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Creates the files for the file system test and inserts them to the file
|
||||
system. */
|
||||
|
||||
void
|
||||
create_files(void)
|
||||
/*==============*/
|
||||
{
|
||||
bool ret;
|
||||
ulint i, k;
|
||||
char name[20];
|
||||
os_thread_t thr[10];
|
||||
os_thread_id_t id[10];
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("Create or open database files\n");
|
||||
|
||||
strcpy(name, "tsfile00");
|
||||
|
||||
for (k = 0; k < 2 * srv_n_spaces; k += 2) {
|
||||
for (i = 0; i < srv_n_files; i++) {
|
||||
|
||||
name[6] = (char)((ulint)'0' + k);
|
||||
name[7] = (char)((ulint)'0' + i);
|
||||
|
||||
files[i] = os_file_create(name, OS_FILE_CREATE,
|
||||
OS_FILE_NORMAL, &ret);
|
||||
if (ret == FALSE) {
|
||||
ut_a(os_file_get_last_error() ==
|
||||
OS_FILE_ALREADY_EXISTS);
|
||||
|
||||
files[i] = os_file_create(
|
||||
name, OS_FILE_OPEN, OS_FILE_NORMAL, &ret);
|
||||
ut_a(ret);
|
||||
} else {
|
||||
ut_a(os_file_set_size(files[i],
|
||||
UNIV_PAGE_SIZE * srv_file_size, 0));
|
||||
/* Initialize the file contents to a random value */
|
||||
/*
|
||||
for (j = 0; j < srv_file_size; j++) {
|
||||
|
||||
for (c = 0; c < UNIV_PAGE_SIZE; c++) {
|
||||
|
||||
rnd_buf[c] = 0xFF;
|
||||
}
|
||||
|
||||
os_file_write(files[i], rnd_buf,
|
||||
UNIV_PAGE_SIZE * j, 0,
|
||||
UNIV_PAGE_SIZE);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
ret = os_file_close(files[i]);
|
||||
ut_a(ret);
|
||||
|
||||
if (i == 0) {
|
||||
fil_space_create(name, k, FIL_TABLESPACE);
|
||||
}
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
fil_node_create(name, srv_file_size, k);
|
||||
}
|
||||
}
|
||||
|
||||
ios = 0;
|
||||
|
||||
mutex_create(&ios_mutex);
|
||||
mutex_set_level(&ios_mutex, SYNC_NO_ORDER_CHECK);
|
||||
|
||||
/* Create i/o-handler threads: */
|
||||
|
||||
for (i = 0; i < 9; i++) {
|
||||
n[i] = i;
|
||||
|
||||
thr[i] = os_thread_create(handler_thread, n + i, id + i);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Inits space header of space. */
|
||||
|
||||
void
|
||||
init_spaces(void)
|
||||
/*=============*/
|
||||
{
|
||||
mtr_t mtr;
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
fsp_header_init(0, srv_file_size * srv_n_files, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
This thread is used to measure contention of latches. */
|
||||
|
||||
ulint
|
||||
test_measure_cont(
|
||||
/*==============*/
|
||||
void* arg)
|
||||
{
|
||||
ulint i, j, k;
|
||||
ulint count[8];
|
||||
ulint lcount[8];
|
||||
ulint lscount;
|
||||
ulint lkcount;
|
||||
ulint pcount, kcount, scount;
|
||||
|
||||
UT_NOT_USED(arg);
|
||||
|
||||
printf("Starting contention measurement\n");
|
||||
|
||||
for (i = 0; i < 1000; i++) {
|
||||
|
||||
for (k = 0; k < 8; k++) {
|
||||
count[k] = 0;
|
||||
lcount[k] = 0;
|
||||
}
|
||||
|
||||
pcount = 0;
|
||||
kcount = 0;
|
||||
scount = 0;
|
||||
lscount = 0;
|
||||
lkcount = 0;
|
||||
|
||||
for (j = 0; j < 100; j++) {
|
||||
|
||||
if (srv_measure_by_spin) {
|
||||
ut_delay(ut_rnd_interval(0, 20000));
|
||||
} else {
|
||||
os_thread_sleep(20000);
|
||||
}
|
||||
|
||||
if (kernel_mutex.lock_word) {
|
||||
kcount++;
|
||||
}
|
||||
|
||||
if (lock_kernel_reserved) {
|
||||
lkcount++;
|
||||
}
|
||||
|
||||
if (buf_pool->mutex.lock_word) {
|
||||
pcount++;
|
||||
}
|
||||
|
||||
if (btr_search_mutex.lock_word) {
|
||||
scount++;
|
||||
}
|
||||
|
||||
for (k = 0; k < 8; k++) {
|
||||
|
||||
if (btr_search_sys->
|
||||
hash_index->mutexes[k].lock_word) {
|
||||
|
||||
count[k]++;
|
||||
}
|
||||
}
|
||||
|
||||
for (k = 0; k < 2; k++) {
|
||||
|
||||
if (lock_sys->rec_hash->mutexes[k].lock_word) {
|
||||
|
||||
lcount[k]++;
|
||||
}
|
||||
}
|
||||
|
||||
if (kernel_mutex.lock_word
|
||||
|| lock_sys->rec_hash->mutexes[0].lock_word
|
||||
|| lock_sys->rec_hash->mutexes[1].lock_word) {
|
||||
|
||||
lscount++;
|
||||
}
|
||||
}
|
||||
|
||||
printf(
|
||||
"Mutex res. p %lu, k %lu %lu, %lu %lu %lu s %lu, %lu %lu %lu %lu %lu %lu %lu %lu of %lu\n",
|
||||
pcount, kcount, lkcount, lcount[0], lcount[1], lscount, scount,
|
||||
count[0], count[1], count[2], count[3],
|
||||
count[4], count[5], count[6], count[7], j);
|
||||
|
||||
sync_print_wait_info();
|
||||
|
||||
printf("N log i/os %lu, n non sea %lu, n sea succ %lu\n",
|
||||
log_sys->n_log_ios, btr_cur_n_non_sea,
|
||||
btr_search_n_succ);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
os_thread_id_t thread_id;
|
||||
|
||||
log_do_write = TRUE;
|
||||
/* yydebug = TRUE; */
|
||||
|
||||
srv_boot("srv_init");
|
||||
|
||||
os_aio_init(576, 9, 100);
|
||||
|
||||
fil_init(25);
|
||||
|
||||
buf_pool_init(srv_pool_size, srv_pool_size);
|
||||
|
||||
fsp_init();
|
||||
log_init();
|
||||
|
||||
lock_sys_create(srv_lock_table_size);
|
||||
|
||||
create_files();
|
||||
create_log_files();
|
||||
|
||||
init_spaces();
|
||||
|
||||
sess_sys_init_at_db_start();
|
||||
|
||||
trx_sys_create();
|
||||
|
||||
dict_create();
|
||||
|
||||
log_make_checkpoint_at(ut_dulint_max);
|
||||
|
||||
if (srv_measure_contention) {
|
||||
os_thread_create(&test_measure_cont, NULL, &thread_id);
|
||||
}
|
||||
|
||||
if (!srv_log_archive_on) {
|
||||
|
||||
ut_a(DB_SUCCESS == log_archive_noarchivelog());
|
||||
}
|
||||
|
||||
srv_master_thread();
|
||||
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
|
||||
os_process_exit(0);
|
||||
}
|
@ -1,535 +0,0 @@
|
||||
/************************************************************************
|
||||
Test for the server
|
||||
|
||||
(c) 1996-1997 Innobase Oy
|
||||
|
||||
Created 2/16/1996 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "os0proc.h"
|
||||
#include "sync0sync.h"
|
||||
#include "ut0mem.h"
|
||||
#include "mem0mem.h"
|
||||
#include "mem0pool.h"
|
||||
#include "data0data.h"
|
||||
#include "data0type.h"
|
||||
#include "dict0dict.h"
|
||||
#include "buf0buf.h"
|
||||
#include "buf0flu.h"
|
||||
#include "os0file.h"
|
||||
#include "os0thread.h"
|
||||
#include "fil0fil.h"
|
||||
#include "fsp0fsp.h"
|
||||
#include "rem0rec.h"
|
||||
#include "rem0cmp.h"
|
||||
#include "mtr0mtr.h"
|
||||
#include "log0log.h"
|
||||
#include "log0recv.h"
|
||||
#include "page0page.h"
|
||||
#include "page0cur.h"
|
||||
#include "trx0trx.h"
|
||||
#include "dict0boot.h"
|
||||
#include "trx0sys.h"
|
||||
#include "dict0crea.h"
|
||||
#include "btr0btr.h"
|
||||
#include "btr0pcur.h"
|
||||
#include "btr0cur.h"
|
||||
#include "btr0sea.h"
|
||||
#include "rem0rec.h"
|
||||
#include "srv0srv.h"
|
||||
#include "que0que.h"
|
||||
#include "com0com.h"
|
||||
#include "usr0sess.h"
|
||||
#include "lock0lock.h"
|
||||
#include "trx0roll.h"
|
||||
#include "trx0purge.h"
|
||||
#include "row0ins.h"
|
||||
#include "row0sel.h"
|
||||
#include "row0upd.h"
|
||||
#include "row0row.h"
|
||||
#include "lock0lock.h"
|
||||
#include "ibuf0ibuf.h"
|
||||
#include "pars0pars.h"
|
||||
#include "btr0sea.h"
|
||||
|
||||
bool measure_cont = FALSE;
|
||||
|
||||
os_file_t files[1000];
|
||||
|
||||
mutex_t ios_mutex;
|
||||
ulint ios;
|
||||
ulint n[10];
|
||||
|
||||
mutex_t incs_mutex;
|
||||
ulint incs;
|
||||
|
||||
byte rnd_buf[67000];
|
||||
|
||||
ulint glob_var1 = 0;
|
||||
ulint glob_var2 = 0;
|
||||
|
||||
mutex_t mutex2;
|
||||
|
||||
mutex_t test_mutex1;
|
||||
mutex_t test_mutex2;
|
||||
|
||||
mutex_t* volatile mutexes;
|
||||
|
||||
bool always_false = FALSE;
|
||||
|
||||
ulint* test_array;
|
||||
|
||||
/************************************************************************
|
||||
Io-handler thread function. */
|
||||
|
||||
ulint
|
||||
handler_thread(
|
||||
/*===========*/
|
||||
void* arg)
|
||||
{
|
||||
ulint segment;
|
||||
ulint i;
|
||||
|
||||
segment = *((ulint*)arg);
|
||||
|
||||
printf("Io handler thread %lu starts\n", segment);
|
||||
|
||||
for (i = 0;; i++) {
|
||||
fil_aio_wait(segment);
|
||||
|
||||
mutex_enter(&ios_mutex);
|
||||
ios++;
|
||||
mutex_exit(&ios_mutex);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Creates or opens the log files. */
|
||||
|
||||
void
|
||||
create_log_files(void)
|
||||
/*==================*/
|
||||
{
|
||||
bool ret;
|
||||
ulint i, k;
|
||||
char name[20];
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("Create or open log files\n");
|
||||
|
||||
strcpy(name, "logfile00");
|
||||
|
||||
for (k = 0; k < srv_n_log_groups; k++) {
|
||||
|
||||
for (i = 0; i < srv_n_log_files; i++) {
|
||||
|
||||
name[6] = (char)((ulint)'0' + k);
|
||||
name[7] = (char)((ulint)'0' + i);
|
||||
|
||||
files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_AIO,
|
||||
&ret);
|
||||
if (ret == FALSE) {
|
||||
ut_a(os_file_get_last_error() ==
|
||||
OS_FILE_ALREADY_EXISTS);
|
||||
|
||||
files[i] = os_file_create(
|
||||
name, OS_FILE_OPEN, OS_FILE_AIO, &ret);
|
||||
ut_a(ret);
|
||||
} else {
|
||||
ut_a(os_file_set_size(files[i],
|
||||
8192 * srv_log_file_size, 0));
|
||||
}
|
||||
|
||||
ret = os_file_close(files[i]);
|
||||
ut_a(ret);
|
||||
|
||||
if (i == 0) {
|
||||
fil_space_create(name, k + 100, FIL_LOG);
|
||||
}
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
fil_node_create(name, srv_log_file_size, k + 100);
|
||||
}
|
||||
|
||||
fil_space_create(name, k + 200, FIL_LOG);
|
||||
|
||||
log_group_init(k, srv_n_log_files,
|
||||
srv_log_file_size * UNIV_PAGE_SIZE,
|
||||
k + 100, k + 200);
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Creates the files for the file system test and inserts them to the file
|
||||
system. */
|
||||
|
||||
void
|
||||
create_files(void)
|
||||
/*==============*/
|
||||
{
|
||||
bool ret;
|
||||
ulint i, k;
|
||||
char name[20];
|
||||
os_thread_t thr[10];
|
||||
os_thread_id_t id[10];
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("Create or open database files\n");
|
||||
|
||||
strcpy(name, "tsfile00");
|
||||
|
||||
for (k = 0; k < 2 * srv_n_spaces; k += 2) {
|
||||
for (i = 0; i < srv_n_files; i++) {
|
||||
|
||||
name[6] = (char)((ulint)'0' + k);
|
||||
name[7] = (char)((ulint)'0' + i);
|
||||
|
||||
files[i] = os_file_create(name, OS_FILE_CREATE,
|
||||
OS_FILE_NORMAL, &ret);
|
||||
if (ret == FALSE) {
|
||||
ut_a(os_file_get_last_error() ==
|
||||
OS_FILE_ALREADY_EXISTS);
|
||||
|
||||
files[i] = os_file_create(
|
||||
name, OS_FILE_OPEN, OS_FILE_NORMAL, &ret);
|
||||
ut_a(ret);
|
||||
} else {
|
||||
ut_a(os_file_set_size(files[i],
|
||||
UNIV_PAGE_SIZE * srv_file_size, 0));
|
||||
/* Initialize the file contents to a random value */
|
||||
/*
|
||||
for (j = 0; j < srv_file_size; j++) {
|
||||
|
||||
for (c = 0; c < UNIV_PAGE_SIZE; c++) {
|
||||
|
||||
rnd_buf[c] = 0xFF;
|
||||
}
|
||||
|
||||
os_file_write(files[i], rnd_buf,
|
||||
UNIV_PAGE_SIZE * j, 0,
|
||||
UNIV_PAGE_SIZE);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
ret = os_file_close(files[i]);
|
||||
ut_a(ret);
|
||||
|
||||
if (i == 0) {
|
||||
fil_space_create(name, k, FIL_TABLESPACE);
|
||||
}
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
fil_node_create(name, srv_file_size, k);
|
||||
}
|
||||
}
|
||||
|
||||
ios = 0;
|
||||
|
||||
mutex_create(&ios_mutex);
|
||||
mutex_set_level(&ios_mutex, SYNC_NO_ORDER_CHECK);
|
||||
|
||||
/* Create i/o-handler threads: */
|
||||
|
||||
for (i = 0; i < 9; i++) {
|
||||
n[i] = i;
|
||||
|
||||
thr[i] = os_thread_create(handler_thread, n + i, id + i);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Inits space header of space. */
|
||||
|
||||
void
|
||||
init_spaces(void)
|
||||
/*=============*/
|
||||
{
|
||||
mtr_t mtr;
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
fsp_header_init(0, srv_file_size * srv_n_files, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
This thread is used to measure contention of latches. */
|
||||
|
||||
ulint
|
||||
test_measure_cont(
|
||||
/*==============*/
|
||||
void* arg)
|
||||
{
|
||||
ulint i, j;
|
||||
ulint pcount, kcount, s_scount, s_xcount, s_mcount, lcount;
|
||||
ulint t1count;
|
||||
ulint t2count;
|
||||
|
||||
UT_NOT_USED(arg);
|
||||
|
||||
printf("Starting contention measurement\n");
|
||||
|
||||
for (i = 0; i < 1000; i++) {
|
||||
|
||||
pcount = 0;
|
||||
kcount = 0;
|
||||
s_scount = 0;
|
||||
s_xcount = 0;
|
||||
s_mcount = 0;
|
||||
lcount = 0;
|
||||
t1count = 0;
|
||||
t2count = 0;
|
||||
|
||||
for (j = 0; j < 100; j++) {
|
||||
|
||||
if (srv_measure_by_spin) {
|
||||
ut_delay(ut_rnd_interval(0, 20000));
|
||||
} else {
|
||||
os_thread_sleep(20000);
|
||||
}
|
||||
|
||||
if (kernel_mutex.lock_word) {
|
||||
kcount++;
|
||||
}
|
||||
|
||||
if (buf_pool->mutex.lock_word) {
|
||||
pcount++;
|
||||
}
|
||||
|
||||
if (log_sys->mutex.lock_word) {
|
||||
lcount++;
|
||||
}
|
||||
|
||||
if (btr_search_latch.reader_count) {
|
||||
s_scount++;
|
||||
}
|
||||
|
||||
if (btr_search_latch.writer != RW_LOCK_NOT_LOCKED) {
|
||||
s_xcount++;
|
||||
}
|
||||
|
||||
if (btr_search_latch.mutex.lock_word) {
|
||||
s_mcount++;
|
||||
}
|
||||
|
||||
if (test_mutex1.lock_word) {
|
||||
t1count++;
|
||||
}
|
||||
|
||||
if (test_mutex2.lock_word) {
|
||||
t2count++;
|
||||
}
|
||||
}
|
||||
|
||||
printf(
|
||||
"Mutex res. l %lu, p %lu, k %lu s x %lu s s %lu s mut %lu of %lu\n",
|
||||
lcount, pcount, kcount, s_xcount, s_scount, s_mcount, j);
|
||||
|
||||
sync_print_wait_info();
|
||||
|
||||
printf(
|
||||
"log i/o %lu n non sea %lu n succ %lu n h fail %lu\n",
|
||||
log_sys->n_log_ios, btr_cur_n_non_sea,
|
||||
btr_search_n_succ, btr_search_n_hash_fail);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
This thread is used to test contention of latches. */
|
||||
|
||||
ulint
|
||||
test_sync(
|
||||
/*======*/
|
||||
void* arg)
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
ulint i, j;
|
||||
ulint sum;
|
||||
ulint rnd = ut_rnd_gen_ulint();
|
||||
ulint mut_ind;
|
||||
byte* ptr;
|
||||
|
||||
UT_NOT_USED(arg);
|
||||
|
||||
printf("Starting mutex reservation test\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
sum = 0;
|
||||
rnd = 87354941;
|
||||
|
||||
for (i = 0; i < srv_test_n_loops; i++) {
|
||||
|
||||
for (j = 0; j < srv_test_n_free_rnds; j++) {
|
||||
rnd += 423087123;
|
||||
|
||||
sum += test_array[rnd % (256 * srv_test_array_size)];
|
||||
}
|
||||
|
||||
rnd += 43605677;
|
||||
|
||||
mut_ind = rnd % srv_test_n_mutexes;
|
||||
|
||||
mutex_enter(mutexes + mut_ind);
|
||||
|
||||
for (j = 0; j < srv_test_n_reserved_rnds; j++) {
|
||||
rnd += 423087121;
|
||||
|
||||
sum += test_array[rnd % (256 * srv_test_array_size)];
|
||||
}
|
||||
|
||||
mutex_exit(mutexes + mut_ind);
|
||||
|
||||
if (srv_test_cache_evict) {
|
||||
ptr = (byte*)(mutexes + mut_ind);
|
||||
|
||||
for (j = 0; j < 4; j++) {
|
||||
ptr += 256 * 1024;
|
||||
sum += *((ulint*)ptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (always_false) {
|
||||
printf("%lu", sum);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall time for res. test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
os_thread_id_t thread_ids[1000];
|
||||
ulint tm, oldtm;
|
||||
ulint rnd;
|
||||
ulint i, sum;
|
||||
byte* ptr;
|
||||
/* mutex_t mutex; */
|
||||
|
||||
log_do_write = TRUE;
|
||||
/* yydebug = TRUE; */
|
||||
|
||||
srv_boot("srv_init");
|
||||
|
||||
os_aio_init(576, 9, 100);
|
||||
|
||||
fil_init(25);
|
||||
|
||||
buf_pool_init(srv_pool_size, srv_pool_size);
|
||||
|
||||
fsp_init();
|
||||
log_init();
|
||||
|
||||
lock_sys_create(srv_lock_table_size);
|
||||
|
||||
create_files();
|
||||
create_log_files();
|
||||
|
||||
init_spaces();
|
||||
|
||||
sess_sys_init_at_db_start();
|
||||
|
||||
trx_sys_create();
|
||||
|
||||
dict_create();
|
||||
|
||||
log_make_checkpoint_at(ut_dulint_max);
|
||||
|
||||
printf("Hotspot semaphore addresses k %lx, p %lx, l %lx, s %lx\n",
|
||||
&kernel_mutex, &(buf_pool->mutex),
|
||||
&(log_sys->mutex), &btr_search_latch);
|
||||
|
||||
if (srv_measure_contention) {
|
||||
os_thread_create(&test_measure_cont, NULL, thread_ids + 999);
|
||||
}
|
||||
|
||||
if (!srv_log_archive_on) {
|
||||
|
||||
ut_a(DB_SUCCESS == log_archive_noarchivelog());
|
||||
}
|
||||
|
||||
/*
|
||||
mutex_create(&mutex);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 2000000; i++) {
|
||||
|
||||
mutex_enter(&mutex);
|
||||
|
||||
mutex_exit(&mutex);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for %lu mutex enter %lu milliseconds\n",
|
||||
i, tm - oldtm);
|
||||
*/
|
||||
if (srv_test_sync) {
|
||||
if (srv_test_nocache) {
|
||||
mutexes = os_mem_alloc_nocache(srv_test_n_mutexes
|
||||
* sizeof(mutex_t));
|
||||
} else {
|
||||
mutexes = mem_alloc(srv_test_n_mutexes
|
||||
* sizeof(mutex_t));
|
||||
}
|
||||
|
||||
sum = 0;
|
||||
|
||||
rnd = 492314896;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 4000000; i++) {
|
||||
|
||||
rnd += 85967944;
|
||||
|
||||
ptr = ((byte*)(mutexes)) + (rnd % (srv_test_n_mutexes
|
||||
* sizeof(mutex_t)));
|
||||
sum += *((ulint*)ptr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf(
|
||||
"Wall clock time for %lu random access %lu milliseconds\n",
|
||||
i, tm - oldtm);
|
||||
if (always_false) {
|
||||
printf("%lu", sum);
|
||||
}
|
||||
|
||||
test_array = mem_alloc(4 * 256 * srv_test_array_size);
|
||||
|
||||
for (i = 0; i < srv_test_n_mutexes; i++) {
|
||||
|
||||
mutex_create(mutexes + i);
|
||||
}
|
||||
|
||||
for (i = 0; i < srv_test_n_threads; i++) {
|
||||
os_thread_create(&test_sync, NULL, thread_ids + i);
|
||||
}
|
||||
}
|
||||
|
||||
srv_master_thread(NULL);
|
||||
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
|
||||
os_process_exit(0);
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
|
||||
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
doall: tsbuf
|
||||
|
||||
tsbuf: ..\buf.lib tsbuf.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\buf.lib ..\..\btr.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsbuf.c $(LFL)
|
||||
|
||||
tsos: ..\buf.lib tsos.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\buf.lib ..\..\mach.lib ..\..\fil.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsos.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,885 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for the file system and buffer manager
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 11/16/1995 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "string.h"
|
||||
|
||||
#include "os0thread.h"
|
||||
#include "os0file.h"
|
||||
#include "ut0ut.h"
|
||||
#include "ut0byte.h"
|
||||
#include "sync0sync.h"
|
||||
#include "mem0mem.h"
|
||||
#include "fil0fil.h"
|
||||
#include "mtr0mtr.h"
|
||||
#include "mtr0log.h"
|
||||
#include "log0log.h"
|
||||
#include "mach0data.h"
|
||||
#include "..\buf0buf.h"
|
||||
#include "..\buf0flu.h"
|
||||
#include "..\buf0lru.h"
|
||||
|
||||
os_file_t files[1000];
|
||||
|
||||
mutex_t ios_mutex;
|
||||
ulint ios;
|
||||
ulint n[10];
|
||||
|
||||
mutex_t incs_mutex;
|
||||
ulint incs;
|
||||
|
||||
#define N_SPACES 1
|
||||
#define N_FILES 1
|
||||
#define FILE_SIZE 4000
|
||||
#define POOL_SIZE 1000
|
||||
#define COUNTER_OFFSET 1500
|
||||
|
||||
#define LOOP_SIZE 150
|
||||
#define N_THREADS 5
|
||||
|
||||
|
||||
ulint zero = 0;
|
||||
|
||||
buf_frame_t* bl_arr[POOL_SIZE];
|
||||
|
||||
/************************************************************************
|
||||
Io-handler thread function. */
|
||||
|
||||
ulint
|
||||
handler_thread(
|
||||
/*===========*/
|
||||
void* arg)
|
||||
{
|
||||
ulint segment;
|
||||
void* mess;
|
||||
ulint i;
|
||||
bool ret;
|
||||
|
||||
segment = *((ulint*)arg);
|
||||
|
||||
printf("Io handler thread %lu starts\n", segment);
|
||||
|
||||
for (i = 0;; i++) {
|
||||
ret = fil_aio_wait(segment, &mess);
|
||||
ut_a(ret);
|
||||
|
||||
buf_page_io_complete((buf_block_t*)mess);
|
||||
|
||||
mutex_enter(&ios_mutex);
|
||||
ios++;
|
||||
mutex_exit(&ios_mutex);
|
||||
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
This thread reports the status of sync system. */
|
||||
|
||||
ulint
|
||||
info_thread(
|
||||
/*========*/
|
||||
void* arg)
|
||||
{
|
||||
ulint segment;
|
||||
|
||||
segment = *((ulint*)arg);
|
||||
|
||||
for (;;) {
|
||||
sync_print();
|
||||
os_aio_print();
|
||||
printf("Debug stop threads == %lu\n", ut_dbg_stop_threads);
|
||||
os_thread_sleep(30000000);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Creates the files for the file system test and inserts them to
|
||||
the file system. */
|
||||
|
||||
void
|
||||
create_files(void)
|
||||
/*==============*/
|
||||
{
|
||||
bool ret;
|
||||
ulint i, k;
|
||||
char name[20];
|
||||
os_thread_t thr[5];
|
||||
os_thread_id_t id[5];
|
||||
ulint err;
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("Create or open database files\n");
|
||||
|
||||
strcpy(name, "tsfile00");
|
||||
|
||||
for (k = 0; k < N_SPACES; k++) {
|
||||
for (i = 0; i < N_FILES; i++) {
|
||||
|
||||
name[9] = (char)((ulint)'0' + k);
|
||||
name[10] = (char)((ulint)'0' + i);
|
||||
|
||||
files[i] = os_file_create(name, OS_FILE_CREATE,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
if (ret == FALSE) {
|
||||
err = os_file_get_last_error();
|
||||
if (err != OS_FILE_ALREADY_EXISTS) {
|
||||
printf("OS error %lu in file creation\n", err);
|
||||
ut_error;
|
||||
}
|
||||
|
||||
files[i] = os_file_create(
|
||||
name, OS_FILE_OPEN,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
ut_a(ret);
|
||||
}
|
||||
|
||||
ret = os_file_close(files[i]);
|
||||
ut_a(ret);
|
||||
|
||||
if (i == 0) {
|
||||
fil_space_create(name, k, OS_FILE_TABLESPACE);
|
||||
}
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
fil_node_create(name, FILE_SIZE, k);
|
||||
}
|
||||
}
|
||||
|
||||
ios = 0;
|
||||
|
||||
mutex_create(&ios_mutex);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
n[i] = i;
|
||||
|
||||
thr[i] = os_thread_create(handler_thread, n + i, id + i);
|
||||
}
|
||||
/*
|
||||
n[9] = 9;
|
||||
os_thread_create(info_thread, n + 9, id);
|
||||
*/
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Creates the test database files. */
|
||||
|
||||
void
|
||||
create_db(void)
|
||||
/*===========*/
|
||||
{
|
||||
ulint i;
|
||||
byte* frame;
|
||||
ulint j;
|
||||
ulint tm, oldtm;
|
||||
mtr_t mtr;
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("Write database pages\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < N_SPACES; i++) {
|
||||
for (j = 0; j < FILE_SIZE * N_FILES; j++) {
|
||||
mtr_start(&mtr);
|
||||
mtr_set_log_mode(&mtr, MTR_LOG_NONE);
|
||||
|
||||
frame = buf_page_create(i, j, &mtr);
|
||||
buf_page_get(i, j, RW_X_LATCH, &mtr);
|
||||
|
||||
if (j > FILE_SIZE * N_FILES - 64 * 2 - 1) {
|
||||
mlog_write_ulint(frame + FIL_PAGE_PREV, j - 5,
|
||||
MLOG_4BYTES, &mtr);
|
||||
mlog_write_ulint(frame + FIL_PAGE_NEXT, j - 7,
|
||||
MLOG_4BYTES, &mtr);
|
||||
} else {
|
||||
mlog_write_ulint(frame + FIL_PAGE_PREV, j - 1,
|
||||
MLOG_4BYTES, &mtr);
|
||||
mlog_write_ulint(frame + FIL_PAGE_NEXT, j + 1,
|
||||
MLOG_4BYTES, &mtr);
|
||||
}
|
||||
|
||||
mlog_write_ulint(frame + FIL_PAGE_OFFSET, j,
|
||||
MLOG_4BYTES, &mtr);
|
||||
mlog_write_ulint(frame + FIL_PAGE_SPACE, i,
|
||||
MLOG_4BYTES, &mtr);
|
||||
mlog_write_ulint(frame + COUNTER_OFFSET, 0,
|
||||
MLOG_4BYTES, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("TEST 1 A. Test of page creation when page resides in buffer\n");
|
||||
for (i = 0; i < N_SPACES; i++) {
|
||||
for (j = FILE_SIZE * N_FILES - 200;
|
||||
j < FILE_SIZE * N_FILES; j++) {
|
||||
mtr_start(&mtr);
|
||||
mtr_set_log_mode(&mtr, MTR_LOG_NONE);
|
||||
|
||||
frame = buf_page_create(i, j, &mtr);
|
||||
buf_page_get(i, j, RW_X_LATCH, &mtr);
|
||||
|
||||
mlog_write_ulint(frame + FIL_PAGE_PREV,
|
||||
j - 1, MLOG_4BYTES, &mtr);
|
||||
|
||||
mlog_write_ulint(frame + FIL_PAGE_NEXT,
|
||||
j + 1, MLOG_4BYTES, &mtr);
|
||||
|
||||
mlog_write_ulint(frame + FIL_PAGE_OFFSET, j,
|
||||
MLOG_4BYTES, &mtr);
|
||||
mlog_write_ulint(frame + FIL_PAGE_SPACE, i,
|
||||
MLOG_4BYTES, &mtr);
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
}
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("TEST 1 B. Flush pages\n");
|
||||
|
||||
buf_flush_batch(BUF_FLUSH_LIST, POOL_SIZE / 2);
|
||||
buf_validate();
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("TEST 1 C. Allocate POOL_SIZE blocks to flush pages\n");
|
||||
|
||||
buf_validate();
|
||||
/* Flush the pool of dirty pages */
|
||||
for (i = 0; i < POOL_SIZE; i++) {
|
||||
|
||||
bl_arr[i] = buf_frame_alloc();
|
||||
}
|
||||
buf_validate();
|
||||
buf_LRU_print();
|
||||
|
||||
for (i = 0; i < POOL_SIZE; i++) {
|
||||
|
||||
buf_frame_free(bl_arr[i]);
|
||||
}
|
||||
|
||||
buf_validate();
|
||||
ut_a(buf_all_freed());
|
||||
|
||||
mtr_start(&mtr);
|
||||
frame = buf_page_get(0, 313, RW_S_LATCH, &mtr);
|
||||
#ifdef UNIV_ASYNC_IO
|
||||
ut_a(buf_page_io_query(buf_block_align(frame)) == TRUE);
|
||||
#endif
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Reads the test database files. */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j, k, c;
|
||||
byte* frame;
|
||||
ulint tm, oldtm;
|
||||
mtr_t mtr;
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("TEST 1 D. Read linearly database files\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (k = 0; k < 1; k++) {
|
||||
for (i = 0; i < N_SPACES; i++) {
|
||||
for (j = 0; j < N_FILES * FILE_SIZE; j++) {
|
||||
mtr_start(&mtr);
|
||||
|
||||
frame = buf_page_get(i, j, RW_S_LATCH, &mtr);
|
||||
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET,
|
||||
MLOG_4BYTES, &mtr)
|
||||
== j);
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_SPACE,
|
||||
MLOG_4BYTES, &mtr)
|
||||
== i);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for %lu pages %lu milliseconds\n",
|
||||
k * i * j, tm - oldtm);
|
||||
buf_validate();
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("TEST 1 E. Read linearly downward database files\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
c = 0;
|
||||
|
||||
for (k = 0; k < 1; k++) {
|
||||
for (i = 0; i < N_SPACES; i++) {
|
||||
for (j = ut_min(1000, FILE_SIZE - 1); j > 0; j--) {
|
||||
mtr_start(&mtr);
|
||||
|
||||
frame = buf_page_get(i, j, RW_S_LATCH, &mtr);
|
||||
c++;
|
||||
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET,
|
||||
MLOG_4BYTES, &mtr)
|
||||
== j);
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_SPACE,
|
||||
MLOG_4BYTES, &mtr)
|
||||
== i);
|
||||
|
||||
|
||||
ut_a(buf_page_io_query(buf_block_align(frame))
|
||||
== FALSE);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for %lu pages %lu milliseconds\n",
|
||||
c, tm - oldtm);
|
||||
buf_validate();
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Reads the test database files. */
|
||||
|
||||
void
|
||||
test2(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j, k;
|
||||
byte* frame;
|
||||
ulint tm, oldtm;
|
||||
mtr_t mtr;
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("TEST 2. Read randomly database files\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (k = 0; k < 100; k++) {
|
||||
i = ut_rnd_gen_ulint() % N_SPACES;
|
||||
j = ut_rnd_gen_ulint() % (N_FILES * FILE_SIZE);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
frame = buf_page_get(i, j, RW_S_LATCH, &mtr);
|
||||
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET,
|
||||
MLOG_4BYTES, &mtr)
|
||||
== j);
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_SPACE,
|
||||
MLOG_4BYTES, &mtr)
|
||||
== i);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for random %lu read %lu milliseconds\n",
|
||||
k, tm - oldtm);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Reads the test database files. */
|
||||
|
||||
void
|
||||
test3(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j, k;
|
||||
byte* frame;
|
||||
ulint tm, oldtm;
|
||||
ulint rnd;
|
||||
mtr_t mtr;
|
||||
|
||||
if (FILE_SIZE < POOL_SIZE + 3050 + ut_dbg_zero) {
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Flush the pool of high-offset pages\n");
|
||||
|
||||
/* Flush the pool of high-offset pages */
|
||||
for (i = 0; i < POOL_SIZE; i++) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
frame = buf_page_get(0, i, RW_S_LATCH, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
buf_validate();
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("TEST 3. Read randomly database pages, no read-ahead\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rnd = 123;
|
||||
|
||||
for (k = 0; k < 400; k++) {
|
||||
rnd += 23477;
|
||||
|
||||
i = 0;
|
||||
j = POOL_SIZE + 10 + rnd % 3000;
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
frame = buf_page_get(i, j, RW_S_LATCH, &mtr);
|
||||
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET,
|
||||
MLOG_4BYTES, &mtr)
|
||||
== j);
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_SPACE,
|
||||
MLOG_4BYTES, &mtr)
|
||||
== i);
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf(
|
||||
"Wall clock time for %lu random no read-ahead %lu milliseconds\n",
|
||||
k, tm - oldtm);
|
||||
|
||||
buf_validate();
|
||||
printf("Flush the pool of high-offset pages\n");
|
||||
/* Flush the pool of high-offset pages */
|
||||
for (i = 0; i < POOL_SIZE; i++) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
frame = buf_page_get(0, i, RW_S_LATCH, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
buf_validate();
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("TEST 3 B. Read randomly database pages, random read-ahead\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rnd = 123;
|
||||
for (k = 0; k < 400; k++) {
|
||||
rnd += 23477;
|
||||
|
||||
i = 0;
|
||||
j = POOL_SIZE + 10 + rnd % 400;
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
frame = buf_page_get(i, j, RW_S_LATCH, &mtr);
|
||||
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET,
|
||||
MLOG_4BYTES, &mtr)
|
||||
== j);
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_SPACE,
|
||||
MLOG_4BYTES, &mtr)
|
||||
== i);
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf(
|
||||
"Wall clock time for %lu random read-ahead %lu milliseconds\n",
|
||||
k, tm - oldtm);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Tests speed of CPU algorithms. */
|
||||
|
||||
void
|
||||
test4(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j;
|
||||
ulint tm, oldtm;
|
||||
mtr_t mtr;
|
||||
buf_frame_t* frame;
|
||||
|
||||
os_thread_sleep(2000000);
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("TEST 4. Speed of CPU algorithms\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 1000; j++) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
for (i = 0; i < 20; i++) {
|
||||
|
||||
frame = buf_page_get(0, i, RW_S_LATCH, &mtr);
|
||||
}
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for %lu page get-release %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
buf_validate();
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 10000; i++) {
|
||||
frame = buf_frame_alloc();
|
||||
buf_frame_free(frame);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for %lu block alloc-free %lu milliseconds\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
ha_print_info(buf_pool->page_hash);
|
||||
buf_print();
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Tests various points of code. */
|
||||
|
||||
void
|
||||
test5(void)
|
||||
/*=======*/
|
||||
{
|
||||
buf_frame_t* frame;
|
||||
fil_addr_t addr;
|
||||
ulint space;
|
||||
mtr_t mtr;
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("TEST 5. Various tests \n");
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
frame = buf_page_get(0, 313, RW_S_LATCH, &mtr);
|
||||
|
||||
ut_a(buf_frame_get_space_id(frame) == 0);
|
||||
ut_a(buf_frame_get_page_no(frame) == 313);
|
||||
|
||||
ut_a(buf_frame_align(frame + UNIV_PAGE_SIZE - 1) == frame);
|
||||
ut_a(buf_frame_align(frame) == frame);
|
||||
|
||||
ut_a(buf_block_align(frame + UNIV_PAGE_SIZE - 1) ==
|
||||
buf_block_align(frame));
|
||||
|
||||
buf_ptr_get_fsp_addr(frame + UNIV_PAGE_SIZE - 1, &space, &addr);
|
||||
|
||||
ut_a(addr.page == 313)
|
||||
ut_a(addr.boffset == UNIV_PAGE_SIZE - 1);
|
||||
ut_a(space == 0);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Random test thread function. */
|
||||
|
||||
ulint
|
||||
random_thread(
|
||||
/*===========*/
|
||||
void* arg)
|
||||
{
|
||||
ulint n;
|
||||
ulint i, j, r, t, p, sp, count;
|
||||
ulint s;
|
||||
buf_frame_t* arr[POOL_SIZE / N_THREADS];
|
||||
buf_frame_t* frame;
|
||||
mtr_t mtr;
|
||||
mtr_t mtr2;
|
||||
|
||||
n = *((ulint*)arg);
|
||||
|
||||
printf("Random test thread %lu starts\n", os_thread_get_curr_id());
|
||||
|
||||
for (i = 0; i < 30; i++) {
|
||||
t = ut_rnd_gen_ulint() % 10;
|
||||
r = ut_rnd_gen_ulint() % 100;
|
||||
s = ut_rnd_gen_ulint() % (POOL_SIZE / N_THREADS);
|
||||
p = ut_rnd_gen_ulint();
|
||||
sp = ut_rnd_gen_ulint() % N_SPACES;
|
||||
|
||||
if (i % 100 == 0) {
|
||||
printf("Thr %lu tst %lu starts\n", os_thread_get_curr_id(), t);
|
||||
}
|
||||
ut_a(buf_validate());
|
||||
|
||||
mtr_start(&mtr);
|
||||
if (t == 6) {
|
||||
/* Allocate free blocks */
|
||||
for (j = 0; j < s; j++) {
|
||||
arr[j] = buf_frame_alloc();
|
||||
ut_a(arr[j]);
|
||||
}
|
||||
for (j = 0; j < s; j++) {
|
||||
buf_frame_free(arr[j]);
|
||||
}
|
||||
} else if (t == 9) {
|
||||
/* buf_flush_batch(BUF_FLUSH_LIST, 30); */
|
||||
|
||||
} else if (t == 7) {
|
||||
/* x-lock many blocks */
|
||||
for (j = 0; j < s; j++) {
|
||||
arr[j] = buf_page_get(sp, (p + j)
|
||||
% (N_FILES * FILE_SIZE),
|
||||
RW_X_LATCH,
|
||||
&mtr);
|
||||
ut_a(arr[j]);
|
||||
if (j > 0) {
|
||||
ut_a(arr[j] != arr[j - 1]);
|
||||
}
|
||||
}
|
||||
ut_a(buf_validate());
|
||||
} else if (t == 8) {
|
||||
/* s-lock many blocks */
|
||||
for (j = 0; j < s; j++) {
|
||||
arr[j] = buf_page_get(sp, (p + j)
|
||||
% (N_FILES * FILE_SIZE),
|
||||
RW_S_LATCH,
|
||||
&mtr);
|
||||
ut_a(arr[j]);
|
||||
if (j > 0) {
|
||||
ut_a(arr[j] != arr[j - 1]);
|
||||
}
|
||||
}
|
||||
} else if (t <= 2) {
|
||||
for (j = 0; j < r; j++) {
|
||||
/* Read pages */
|
||||
mtr_start(&mtr2);
|
||||
frame = buf_page_get(sp,
|
||||
p % (N_FILES * FILE_SIZE),
|
||||
RW_S_LATCH, &mtr2);
|
||||
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET,
|
||||
MLOG_4BYTES, &mtr2)
|
||||
== p % (N_FILES * FILE_SIZE));
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_SPACE,
|
||||
MLOG_4BYTES, &mtr2)
|
||||
== sp);
|
||||
mtr_commit(&mtr2);
|
||||
if (t == 0) {
|
||||
p++; /* upward */
|
||||
} else if (t == 1) {
|
||||
p--; /* downward */
|
||||
} else if (t == 2) {
|
||||
p = ut_rnd_gen_ulint(); /* randomly */
|
||||
}
|
||||
}
|
||||
} else if (t <= 5) {
|
||||
for (j = 0; j < r; j++) {
|
||||
/* Write pages */
|
||||
mtr_start(&mtr2);
|
||||
frame = buf_page_get(sp, p % (N_FILES * FILE_SIZE),
|
||||
RW_X_LATCH, &mtr2);
|
||||
count = 1 + mtr_read_ulint(frame + COUNTER_OFFSET,
|
||||
MLOG_4BYTES, &mtr2);
|
||||
mutex_enter(&incs_mutex);
|
||||
incs++;
|
||||
mutex_exit(&incs_mutex);
|
||||
mlog_write_ulint(frame + COUNTER_OFFSET, count,
|
||||
MLOG_4BYTES, &mtr2);
|
||||
mtr_commit(&mtr2);
|
||||
if (t == 3) {
|
||||
p++; /* upward */
|
||||
} else if (t == 4) {
|
||||
p--; /* downward */
|
||||
} else if (t == 5) {
|
||||
p = ut_rnd_gen_ulint(); /* randomly */
|
||||
}
|
||||
}
|
||||
} /* if t = */
|
||||
|
||||
mtr_commit(&mtr);
|
||||
/* printf("Thr %lu tst %lu ends ", os_thread_get_curr_id(), t); */
|
||||
ut_a(buf_validate());
|
||||
} /* for i */
|
||||
printf("\nRandom test thread %lu exits\n", os_thread_get_curr_id());
|
||||
return(0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Random test thread function which reports the rw-lock list. */
|
||||
|
||||
ulint
|
||||
rw_list_thread(
|
||||
/*===========*/
|
||||
void* arg)
|
||||
{
|
||||
ulint n;
|
||||
ulint i;
|
||||
|
||||
n = *((ulint*)arg);
|
||||
|
||||
printf("\nRw list test thread %lu starts\n", os_thread_get_curr_id());
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
os_thread_sleep(3000000);
|
||||
rw_lock_list_print_info();
|
||||
buf_validate();
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Performs random operations on the buffer with several threads. */
|
||||
|
||||
void
|
||||
test6(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j;
|
||||
os_thread_t thr[N_THREADS + 1];
|
||||
os_thread_id_t id[N_THREADS + 1];
|
||||
ulint n[N_THREADS + 1];
|
||||
ulint count = 0;
|
||||
buf_frame_t* frame;
|
||||
mtr_t mtr;
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("TEST 6. Random multi-thread test on the buffer \n");
|
||||
|
||||
incs = 0;
|
||||
mutex_create(&incs_mutex);
|
||||
|
||||
for (i = 0; i < N_THREADS; i++) {
|
||||
n[i] = i;
|
||||
|
||||
thr[i] = os_thread_create(random_thread, n + i, id + i);
|
||||
}
|
||||
/*
|
||||
n[N_THREADS] = N_THREADS;
|
||||
|
||||
thr[N_THREADS] = os_thread_create(rw_list_thread, n + N_THREADS,
|
||||
id + N_THREADS);
|
||||
*/
|
||||
for (i = 0; i < N_THREADS; i++) {
|
||||
os_thread_wait(thr[i]);
|
||||
}
|
||||
|
||||
/* os_thread_wait(thr[N_THREADS]); */
|
||||
|
||||
for (i = 0; i < N_SPACES; i++) {
|
||||
for (j = 0; j < N_FILES * FILE_SIZE; j++) {
|
||||
mtr_start(&mtr);
|
||||
|
||||
frame = buf_page_get(i, j, RW_S_LATCH, &mtr);
|
||||
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET,
|
||||
MLOG_4BYTES, &mtr)
|
||||
== j);
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_SPACE,
|
||||
MLOG_4BYTES, &mtr)
|
||||
== i);
|
||||
|
||||
count += mtr_read_ulint(frame + COUNTER_OFFSET,
|
||||
MLOG_4BYTES, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
}
|
||||
|
||||
printf("Count %lu incs %lu\n", count, incs);
|
||||
ut_a(count == incs);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Frees the spaces in the file system. */
|
||||
|
||||
void
|
||||
free_system(void)
|
||||
/*=============*/
|
||||
{
|
||||
ulint i;
|
||||
|
||||
for (i = 0; i < N_SPACES; i++) {
|
||||
fil_space_free(i);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
|
||||
/* buf_debug_prints = TRUE; */
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
os_aio_init(160, 5);
|
||||
sync_init();
|
||||
mem_init(1500000);
|
||||
fil_init(26); /* Allow 25 open files at a time */
|
||||
buf_pool_init(POOL_SIZE, POOL_SIZE);
|
||||
log_init();
|
||||
|
||||
buf_validate();
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
create_files();
|
||||
|
||||
create_db();
|
||||
|
||||
buf_validate();
|
||||
|
||||
test1();
|
||||
buf_validate();
|
||||
|
||||
test2();
|
||||
buf_validate();
|
||||
|
||||
test3();
|
||||
buf_validate();
|
||||
|
||||
test4();
|
||||
|
||||
test5();
|
||||
|
||||
buf_validate();
|
||||
|
||||
test6();
|
||||
|
||||
buf_validate();
|
||||
|
||||
buf_print();
|
||||
|
||||
buf_flush_batch(BUF_FLUSH_LIST, POOL_SIZE + 1);
|
||||
buf_print();
|
||||
buf_validate();
|
||||
|
||||
os_thread_sleep(1000000);
|
||||
|
||||
buf_print();
|
||||
buf_all_freed();
|
||||
|
||||
free_system();
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,185 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for the operating system interface
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 9/27/1995 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
#include "../os0thread.h"
|
||||
#include "../os0shm.h"
|
||||
#include "../os0proc.h"
|
||||
#include "../os0sync.h"
|
||||
#include "../os0file.h"
|
||||
#include "ut0ut.h"
|
||||
#include "sync0sync.h"
|
||||
#include "mem0mem.h"
|
||||
|
||||
ulint last_thr = 1;
|
||||
|
||||
byte global_buf[1000000];
|
||||
|
||||
os_file_t file;
|
||||
os_file_t file2;
|
||||
|
||||
os_event_t gl_ready;
|
||||
|
||||
mutex_t ios_mutex;
|
||||
ulint ios;
|
||||
|
||||
/************************************************************************
|
||||
Io-handler thread function. */
|
||||
|
||||
ulint
|
||||
handler_thread(
|
||||
/*===========*/
|
||||
void* arg)
|
||||
{
|
||||
ulint segment;
|
||||
void* mess;
|
||||
ulint i;
|
||||
bool ret;
|
||||
|
||||
segment = *((ulint*)arg);
|
||||
|
||||
printf("Thread %lu starts\n", segment);
|
||||
|
||||
for (i = 0;; i++) {
|
||||
ret = os_aio_wait(segment, &mess);
|
||||
|
||||
mutex_enter(&ios_mutex);
|
||||
ios++;
|
||||
mutex_exit(&ios_mutex);
|
||||
|
||||
ut_a(ret);
|
||||
/* printf("Message for thread %lu %lu\n", segment,
|
||||
(ulint)mess); */
|
||||
if ((ulint)mess == 3333) {
|
||||
os_event_set(gl_ready);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Test of io-handler threads */
|
||||
|
||||
void
|
||||
test4(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i;
|
||||
bool ret;
|
||||
void* buf;
|
||||
ulint rnd;
|
||||
ulint tm, oldtm;
|
||||
|
||||
os_thread_t thr[5];
|
||||
os_thread_id_t id[5];
|
||||
ulint n[5];
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("OS-TEST 4. Test of asynchronous file io\n");
|
||||
|
||||
/* Align the buffer for file io */
|
||||
|
||||
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
|
||||
|
||||
gl_ready = os_event_create(NULL);
|
||||
ios = 0;
|
||||
|
||||
sync_init();
|
||||
mem_init();
|
||||
|
||||
mutex_create(&ios_mutex);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
n[i] = i;
|
||||
|
||||
thr[i] = os_thread_create(handler_thread, n + i, id + i);
|
||||
}
|
||||
|
||||
rnd = 0;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 4096; i++) {
|
||||
ret = os_aio_read(file, (byte*)buf + 8192 * (rnd % 100),
|
||||
8192 * (rnd % 4096), 0,
|
||||
8192, (void*)i);
|
||||
ut_a(ret);
|
||||
rnd += 1;
|
||||
}
|
||||
|
||||
ret = os_aio_read(file, buf, 8192 * (rnd % 1024), 0, 8192,
|
||||
(void*)3333);
|
||||
ut_a(ret);
|
||||
|
||||
ut_a(!os_aio_all_slots_free());
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("All ios queued! N ios: %lu\n", ios);
|
||||
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
os_event_wait(gl_ready);
|
||||
|
||||
tm = ut_clock();
|
||||
printf("N ios: %lu\n", ios);
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
os_thread_sleep(2000000);
|
||||
|
||||
printf("N ios: %lu\n", ios);
|
||||
|
||||
ut_a(os_aio_all_slots_free());
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Initializes the asyncronous io system for tests. */
|
||||
|
||||
void
|
||||
init_aio(void)
|
||||
/*==========*/
|
||||
{
|
||||
bool ret;
|
||||
void* buf;
|
||||
|
||||
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
|
||||
|
||||
os_aio_init(160, 5);
|
||||
file = os_file_create("j:\\tsfile4", OS_FILE_CREATE, OS_FILE_TABLESPACE,
|
||||
&ret);
|
||||
|
||||
if (ret == FALSE) {
|
||||
ut_a(os_file_get_last_error() == OS_FILE_ALREADY_EXISTS);
|
||||
|
||||
file = os_file_create("j:\\tsfile4", OS_FILE_OPEN,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
ut_a(ret);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
init_aio();
|
||||
|
||||
test4();
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
|
||||
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
doall: tscom tscli
|
||||
|
||||
tscom: ..\com.lib tscom.c makefile
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\com.lib ..\..\ut.lib ..\..\mem.lib ..\..\sync.lib ..\..\os.lib tscom.c $(LFL)
|
||||
|
||||
tscli: ..\com.lib tscli.c makefile
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\com.lib ..\..\ut.lib ..\..\mem.lib ..\..\sync.lib ..\..\os.lib tscli.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,96 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for communication
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 9/26/1995 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "../com0com.h"
|
||||
#include "../com0shm.h"
|
||||
#include "ut0ut.h"
|
||||
#include "mem0mem.h"
|
||||
#include "os0thread.h"
|
||||
#include "sync0ipm.h"
|
||||
#include "sync0sync.h"
|
||||
|
||||
byte buf[10000];
|
||||
char addr[150];
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
com_endpoint_t* ep;
|
||||
ulint ret;
|
||||
ulint size;
|
||||
ulint len;
|
||||
ulint addr_len;
|
||||
ulint i;
|
||||
|
||||
ep = com_endpoint_create(COM_SHM);
|
||||
|
||||
ut_a(ep);
|
||||
|
||||
size = 8192;
|
||||
|
||||
ret = com_endpoint_set_option(ep, COM_OPT_MAX_DGRAM_SIZE,
|
||||
(byte*)&size, 0);
|
||||
|
||||
ut_a(ret == 0);
|
||||
|
||||
ret = com_bind(ep, "CLI", 3);
|
||||
|
||||
ut_a(ret == 0);
|
||||
|
||||
printf("Client endpoint created!\n");
|
||||
|
||||
for (i = 0; i < 10000; i++) {
|
||||
|
||||
ret = com_sendto(ep, (byte*)"Hello from client!\n", 18, "SRV", 3);
|
||||
|
||||
ut_a(ret == 0);
|
||||
|
||||
ret = com_recvfrom(ep, buf, 10000, &len, addr, 150, &addr_len);
|
||||
|
||||
ut_a(ret == 0);
|
||||
|
||||
buf[len] = '\0';
|
||||
addr[addr_len] = '\0';
|
||||
/*
|
||||
printf(
|
||||
"Message of len %lu\n%s \nreceived from address %s of len %lu\n",
|
||||
len, buf, addr, addr_len);
|
||||
*/
|
||||
}
|
||||
|
||||
ret = com_endpoint_free(ep);
|
||||
|
||||
ut_ad(ret == 0);
|
||||
|
||||
|
||||
printf("Count of extra system calls in com_shm %lu\n",
|
||||
com_shm_system_call_count);
|
||||
printf("Count of extra system calls in ip_mutex %lu\n",
|
||||
ip_mutex_system_call_count);
|
||||
}
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
|
||||
sync_init();
|
||||
mem_init();
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
test1();
|
||||
|
||||
ut_ad(mem_all_freed());
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %ld milliseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,94 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for communication
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 9/26/1995 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "../com0com.h"
|
||||
#include "../com0shm.h"
|
||||
#include "ut0ut.h"
|
||||
#include "mem0mem.h"
|
||||
#include "os0thread.h"
|
||||
#include "sync0ipm.h"
|
||||
#include "sync0sync.h"
|
||||
|
||||
byte buf[10000];
|
||||
char addr[150];
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
com_endpoint_t* ep;
|
||||
ulint ret;
|
||||
ulint size;
|
||||
ulint len;
|
||||
ulint addr_len;
|
||||
ulint i;
|
||||
|
||||
ep = com_endpoint_create(COM_SHM);
|
||||
|
||||
ut_a(ep);
|
||||
|
||||
size = 8192;
|
||||
|
||||
ret = com_endpoint_set_option(ep, COM_OPT_MAX_DGRAM_SIZE,
|
||||
(byte*)&size, 0);
|
||||
|
||||
ut_a(ret == 0);
|
||||
|
||||
ret = com_bind(ep, "SRV", 3);
|
||||
|
||||
ut_a(ret == 0);
|
||||
|
||||
printf("Server endpoint created!\n");
|
||||
|
||||
for (i = 0; i < 50000; i++) {
|
||||
|
||||
ret = com_recvfrom(ep, buf, 10000, &len, addr, 150, &addr_len);
|
||||
|
||||
ut_a(ret == 0);
|
||||
|
||||
buf[len] = '\0';
|
||||
addr[addr_len] = '\0';
|
||||
/*
|
||||
printf(
|
||||
"Message of len %lu\n%s \nreceived from address %s of len %lu\n",
|
||||
len, buf, addr, addr_len);
|
||||
*/
|
||||
ret = com_sendto(ep, (byte*)"Hello from server!\n", 18, "CLI", 3);
|
||||
|
||||
ut_a(ret == 0);
|
||||
}
|
||||
|
||||
ret = com_endpoint_free(ep);
|
||||
|
||||
ut_ad(ret == 0);
|
||||
|
||||
printf("Count of extra system calls in com_shm %lu\n",
|
||||
com_shm_system_call_count);
|
||||
printf("Count of extra system calls in ip_mutex %lu\n",
|
||||
ip_mutex_system_call_count);
|
||||
}
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
|
||||
sync_init();
|
||||
mem_init();
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
test1();
|
||||
|
||||
ut_ad(mem_all_freed());
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %ld milliseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
|
||||
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tsdict: ..\dict.lib tsdict.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\dict.lib ..\..\data.lib ..\..\buf.lib ..\..\mach.lib ..\..\fil.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsdict.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,73 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for the data dictionary
|
||||
|
||||
(c) 1996 Innobase Oy
|
||||
|
||||
Created 1/13/1996 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "sync0sync.h"
|
||||
#include "mem0mem.h"
|
||||
#include "buf0buf.h"
|
||||
#include "data0type.h"
|
||||
#include "..\dict0dict.h"
|
||||
|
||||
/************************************************************************
|
||||
Basic test of data dictionary. */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
dict_table_t* table;
|
||||
dict_index_t* index;
|
||||
|
||||
table = dict_table_create("TS_TABLE1", 3);
|
||||
|
||||
dict_table_add_col(table, "COL1", DATA_INT, 3, 4, 5);
|
||||
dict_table_add_col(table, "COL2", DATA_INT, 3, 4, 5);
|
||||
dict_table_add_col(table, "COL3", DATA_INT, 3, 4, 5);
|
||||
|
||||
ut_a(0 == dict_table_publish(table));
|
||||
|
||||
index = dict_index_create("TS_TABLE1", "IND1",
|
||||
DICT_UNIQUE | DICT_CLUSTERED | DICT_MIX, 2, 1);
|
||||
|
||||
dict_index_add_field(index, "COL2", DICT_DESCEND);
|
||||
dict_index_add_field(index, "COL1", 0);
|
||||
|
||||
ut_a(0 == dict_index_publish(index));
|
||||
|
||||
dict_table_print(table);
|
||||
|
||||
dict_table_free(table);
|
||||
|
||||
ut_a(dict_all_freed());
|
||||
|
||||
dict_free_all();
|
||||
|
||||
ut_a(dict_all_freed());
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
sync_init();
|
||||
mem_init();
|
||||
buf_pool_init(100, 100);
|
||||
dict_init();
|
||||
|
||||
test1();
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tsdyn: ..\dyn.lib tsdyn.c makefile
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\dyn.lib ..\..\mem.lib ..\..\ut.lib ..\..\mach.lib ..\..\sync.lib ..\..\os.lib tsdyn.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,57 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for dynamic array
|
||||
|
||||
(c) 1996 Innobase Oy
|
||||
|
||||
Created 2/5/1996 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "../dyn0dyn.h"
|
||||
#include "sync0sync.h"
|
||||
#include "mem0mem.h"
|
||||
|
||||
/****************************************************************
|
||||
Basic test. */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
dyn_array_t dyn;
|
||||
ulint i;
|
||||
ulint* ulint_ptr;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 1. Basic test\n");
|
||||
|
||||
dyn_array_create(&dyn);
|
||||
|
||||
for (i = 0; i < 1000; i++) {
|
||||
ulint_ptr = dyn_array_push(&dyn, sizeof(ulint));
|
||||
*ulint_ptr = i;
|
||||
}
|
||||
|
||||
ut_a(dyn_array_get_n_elements(&dyn) == 1000);
|
||||
|
||||
for (i = 0; i < 1000; i++) {
|
||||
ulint_ptr = dyn_array_get_nth_element(&dyn, i, sizeof(ulint));
|
||||
ut_a(*ulint_ptr == i);
|
||||
}
|
||||
|
||||
dyn_array_free(&dyn);
|
||||
}
|
||||
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
sync_init();
|
||||
mem_init();
|
||||
|
||||
test1();
|
||||
|
||||
ut_ad(sync_all_freed());
|
||||
|
||||
ut_ad(mem_all_freed());
|
||||
|
||||
printf("TEST SUCCESSFULLY COMPLETED!\n");
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
|
||||
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tsfil: ..\fil.lib tsfil.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\fil.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsfil.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,329 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for the file system
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 10/29/1995 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "os0thread.h"
|
||||
#include "os0file.h"
|
||||
#include "ut0ut.h"
|
||||
#include "sync0sync.h"
|
||||
#include "mem0mem.h"
|
||||
#include "..\fil0fil.h"
|
||||
|
||||
ulint last_thr = 1;
|
||||
|
||||
byte global_buf[10000000];
|
||||
byte global_buf2[20000];
|
||||
|
||||
os_file_t files[1000];
|
||||
|
||||
os_event_t gl_ready;
|
||||
|
||||
mutex_t ios_mutex;
|
||||
ulint ios;
|
||||
|
||||
/*********************************************************************
|
||||
Test for synchronous file io. */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j;
|
||||
void* mess;
|
||||
bool ret;
|
||||
void* buf;
|
||||
ulint rnd, rnd3;
|
||||
ulint tm, oldtm;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("FIL-TEST 1. Test of synchronous file io\n");
|
||||
|
||||
/* Align the buffer for file io */
|
||||
|
||||
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
|
||||
|
||||
rnd = ut_time();
|
||||
rnd3 = ut_time();
|
||||
|
||||
rnd = rnd * 3416133;
|
||||
rnd3 = rnd3 * 6576681;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 300; j++) {
|
||||
for (i = 0; i < (rnd3 % 15); i++) {
|
||||
fil_read((rnd % 1000) / 100, rnd % 100, 0, 8192, buf, NULL);
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
ret = fil_aio_wait(0, &mess);
|
||||
ut_a(ret);
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
ut_a(*((ulint*)buf) == rnd % 1000);
|
||||
|
||||
rnd += 1;
|
||||
}
|
||||
rnd = rnd + 3416133;
|
||||
rnd3 = rnd3 + 6576681;
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for synchr. io %lu milliseconds\n",
|
||||
tm - oldtm);
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Io-handler thread function. */
|
||||
|
||||
ulint
|
||||
handler_thread(
|
||||
/*===========*/
|
||||
void* arg)
|
||||
{
|
||||
ulint segment;
|
||||
void* mess;
|
||||
void* buf;
|
||||
ulint i;
|
||||
bool ret;
|
||||
|
||||
segment = *((ulint*)arg);
|
||||
|
||||
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
|
||||
|
||||
printf("Thread %lu starts\n", segment);
|
||||
|
||||
for (i = 0;; i++) {
|
||||
ret = fil_aio_wait(segment, &mess);
|
||||
ut_a(ret);
|
||||
|
||||
if ((ulint)mess == 3333) {
|
||||
os_event_set(gl_ready);
|
||||
} else {
|
||||
ut_a((ulint)mess ==
|
||||
*((ulint*)((byte*)buf + 8192 * (ulint)mess)));
|
||||
}
|
||||
|
||||
mutex_enter(&ios_mutex);
|
||||
ios++;
|
||||
mutex_exit(&ios_mutex);
|
||||
|
||||
ut_a(ret);
|
||||
/* printf("Message for thread %lu %lu\n", segment,
|
||||
(ulint)mess); */
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Test of io-handler threads */
|
||||
|
||||
void
|
||||
test2(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i;
|
||||
ulint j;
|
||||
void* buf;
|
||||
ulint rnd, rnd3;
|
||||
ulint tm, oldtm;
|
||||
os_thread_t thr[5];
|
||||
os_thread_id_t id[5];
|
||||
ulint n[5];
|
||||
|
||||
/* Align the buffer for file io */
|
||||
|
||||
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
|
||||
|
||||
gl_ready = os_event_create(NULL);
|
||||
ios = 0;
|
||||
|
||||
mutex_create(&ios_mutex);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
n[i] = i;
|
||||
|
||||
thr[i] = os_thread_create(handler_thread, n + i, id + i);
|
||||
}
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("FIL-TEST 2. Test of asynchronous file io\n");
|
||||
|
||||
rnd = ut_time();
|
||||
rnd3 = ut_time();
|
||||
|
||||
rnd = rnd * 3416133;
|
||||
rnd3 = rnd3 * 6576681;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 300; j++) {
|
||||
for (i = 0; i < (rnd3 % 15); i++) {
|
||||
fil_read((rnd % 1000) / 100, rnd % 100, 0, 8192,
|
||||
(void*)((byte*)buf + 8192 * (rnd % 1000)),
|
||||
(void*)(rnd % 1000));
|
||||
|
||||
rnd += 1;
|
||||
}
|
||||
ut_a(fil_validate());
|
||||
rnd = rnd + 3416133;
|
||||
rnd3 = rnd3 + 6576681;
|
||||
}
|
||||
|
||||
ut_a(!os_aio_all_slots_free());
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for asynchr. io %lu milliseconds\n",
|
||||
tm - oldtm);
|
||||
|
||||
fil_read(5, 25, 0, 8192,
|
||||
(void*)((byte*)buf + 8192 * 1000),
|
||||
(void*)3333);
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
printf("All ios queued! N ios: %lu\n", ios);
|
||||
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
os_event_wait(gl_ready);
|
||||
|
||||
tm = ut_clock();
|
||||
printf("N ios: %lu\n", ios);
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
os_thread_sleep(2000000);
|
||||
|
||||
printf("N ios: %lu\n", ios);
|
||||
|
||||
ut_a(fil_validate());
|
||||
ut_a(os_aio_all_slots_free());
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Creates the files for the file system test and inserts them to
|
||||
the file system. */
|
||||
|
||||
void
|
||||
create_files(void)
|
||||
/*==============*/
|
||||
{
|
||||
bool ret;
|
||||
ulint i, j, k, n;
|
||||
void* buf;
|
||||
void* mess;
|
||||
char name[10];
|
||||
|
||||
buf = (void*)(((ulint)global_buf2 + 6300) & (~0xFFF));
|
||||
|
||||
name[0] = 't';
|
||||
name[1] = 's';
|
||||
name[2] = 'f';
|
||||
name[3] = 'i';
|
||||
name[4] = 'l';
|
||||
name[5] = 'e';
|
||||
name[8] = '\0';
|
||||
|
||||
for (k = 0; k < 10; k++) {
|
||||
for (i = 0; i < 20; i++) {
|
||||
|
||||
name[6] = (char)(k + (ulint)'a');
|
||||
name[7] = (char)(i + (ulint)'a');
|
||||
|
||||
files[i] = os_file_create(name, OS_FILE_CREATE,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
if (ret == FALSE) {
|
||||
ut_a(os_file_get_last_error() ==
|
||||
OS_FILE_ALREADY_EXISTS);
|
||||
|
||||
files[i] = os_file_create(name, OS_FILE_OPEN,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
ut_a(ret);
|
||||
} else {
|
||||
|
||||
for (j = 0; j < 5; j++) {
|
||||
for (n = 0; n < 8192 / sizeof(ulint); n++) {
|
||||
*((ulint*)buf + n) =
|
||||
k * 100 + i * 5 + j;
|
||||
}
|
||||
|
||||
ret = os_aio_write(files[i], buf, 8192 * j,
|
||||
0, 8192, NULL);
|
||||
ut_a(ret);
|
||||
|
||||
ret = os_aio_wait(0, &mess);
|
||||
|
||||
ut_a(ret);
|
||||
ut_a(mess == NULL);
|
||||
}
|
||||
}
|
||||
|
||||
ret = os_file_close(files[i]);
|
||||
ut_a(ret);
|
||||
|
||||
if (i == 0) {
|
||||
fil_space_create("noname", k, OS_FILE_TABLESPACE);
|
||||
}
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
fil_node_create(name, 5, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Frees the spaces in the file system. */
|
||||
|
||||
void
|
||||
free_system(void)
|
||||
/*=============*/
|
||||
{
|
||||
ulint i;
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
fil_space_free(i);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
os_aio_init(160, 5);
|
||||
sync_init();
|
||||
mem_init();
|
||||
fil_init(2); /* Allow only 2 open files at a time */
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
create_files();
|
||||
|
||||
test1();
|
||||
|
||||
test2();
|
||||
|
||||
free_system();
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,891 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for the file system and buffer manager
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 11/16/1995 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "string.h"
|
||||
|
||||
#include "os0thread.h"
|
||||
#include "os0file.h"
|
||||
#include "ut0ut.h"
|
||||
#include "ut0byte.h"
|
||||
#include "sync0sync.h"
|
||||
#include "mem0mem.h"
|
||||
#include "fil0fil.h"
|
||||
#include "..\buf0buf.h"
|
||||
#include "..\buf0buf.h1"
|
||||
#include "..\buf0buf.h2"
|
||||
#include "..\buf0flu.h"
|
||||
#include "..\buf0lru.h"
|
||||
#include "mtr0buf.h"
|
||||
#include "mtr0log.h"
|
||||
#include "fsp0fsp.h"
|
||||
#include "log0log.h"
|
||||
|
||||
os_file_t files[1000];
|
||||
|
||||
mutex_t ios_mutex;
|
||||
ulint ios;
|
||||
ulint n[5];
|
||||
|
||||
|
||||
/************************************************************************
|
||||
Io-handler thread function. */
|
||||
|
||||
ulint
|
||||
handler_thread(
|
||||
/*===========*/
|
||||
void* arg)
|
||||
{
|
||||
ulint segment;
|
||||
void* mess;
|
||||
ulint i;
|
||||
bool ret;
|
||||
|
||||
segment = *((ulint*)arg);
|
||||
|
||||
printf("Thread %lu starts\n", segment);
|
||||
|
||||
for (i = 0;; i++) {
|
||||
ret = fil_aio_wait(segment, &mess);
|
||||
ut_a(ret);
|
||||
|
||||
buf_page_io_complete((buf_block_t*)mess);
|
||||
|
||||
mutex_enter(&ios_mutex);
|
||||
ios++;
|
||||
mutex_exit(&ios_mutex);
|
||||
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Creates the test database files. */
|
||||
|
||||
void
|
||||
create_db(void)
|
||||
/*===========*/
|
||||
{
|
||||
ulint i;
|
||||
buf_block_t* block;
|
||||
byte* frame;
|
||||
ulint j;
|
||||
ulint tm, oldtm;
|
||||
mtr_t mtr;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 1; i++) {
|
||||
for (j = 0; j < 4096; j++) {
|
||||
mtr_start(&mtr);
|
||||
if (j == 0) {
|
||||
fsp_header_init(i, 4096, &mtr);
|
||||
|
||||
block = mtr_page_get(i, j, NULL, &mtr);
|
||||
} else {
|
||||
block = mtr_page_create(i, j, &mtr);
|
||||
}
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
mtr_page_x_lock(block, &mtr);
|
||||
|
||||
mlog_write_ulint(frame + FIL_PAGE_PREV,
|
||||
j - 1, MLOG_4BYTES, &mtr);
|
||||
|
||||
mlog_write_ulint(frame + FIL_PAGE_NEXT,
|
||||
j + 1, MLOG_4BYTES, &mtr);
|
||||
|
||||
mlog_write_ulint(frame + FIL_PAGE_OFFSET,
|
||||
j, MLOG_4BYTES, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
/* Flush the pool of dirty pages by reading low-offset pages */
|
||||
for (i = 0; i < 1000; i++) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
block = mtr_page_get(0, i, NULL, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
mtr_page_s_lock(block, &mtr);
|
||||
|
||||
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET, MLOG_4BYTES,
|
||||
&mtr) == i);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
os_thread_sleep(1000000);
|
||||
|
||||
ut_a(buf_all_freed());
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Creates the files for the file system test and inserts them to
|
||||
the file system. */
|
||||
|
||||
void
|
||||
create_files(void)
|
||||
/*==============*/
|
||||
{
|
||||
bool ret;
|
||||
ulint i, k;
|
||||
char name[20];
|
||||
os_thread_t thr[5];
|
||||
os_thread_id_t id[5];
|
||||
|
||||
strcpy(name, "j:\\tsfile1");
|
||||
|
||||
for (k = 0; k < 1; k++) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
|
||||
name[9] = (char)((ulint)'0' + i);
|
||||
|
||||
files[i] = os_file_create(name, OS_FILE_CREATE,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
if (ret == FALSE) {
|
||||
ut_a(os_file_get_last_error() ==
|
||||
OS_FILE_ALREADY_EXISTS);
|
||||
|
||||
files[i] = os_file_create(
|
||||
name, OS_FILE_OPEN,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
ut_a(ret);
|
||||
}
|
||||
|
||||
ret = os_file_set_size(files[i], 4096 * 8192, 0);
|
||||
ut_a(ret);
|
||||
|
||||
ret = os_file_close(files[i]);
|
||||
ut_a(ret);
|
||||
|
||||
if (i == 0) {
|
||||
fil_space_create("noname", k, OS_FILE_TABLESPACE);
|
||||
}
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
fil_node_create(name, 4096, k);
|
||||
}
|
||||
}
|
||||
|
||||
ios = 0;
|
||||
|
||||
mutex_create(&ios_mutex);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
n[i] = i;
|
||||
|
||||
thr[i] = os_thread_create(handler_thread, n + i, id + i);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Reads the test database files. */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j, k;
|
||||
buf_block_t* block;
|
||||
byte* frame;
|
||||
ulint tm, oldtm;
|
||||
|
||||
buf_flush_batch(BUF_FLUSH_LIST, 1000);
|
||||
|
||||
os_thread_sleep(1000000);
|
||||
|
||||
buf_all_freed();
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (k = 0; k < 1; k++) {
|
||||
for (i = 0; i < 1; i++) {
|
||||
for (j = 0; j < 409; j++) {
|
||||
block = buf_page_get(i, j, NULL);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
buf_page_s_lock(block);
|
||||
|
||||
ut_a(*((ulint*)(frame + 16)) == j);
|
||||
|
||||
buf_page_s_unlock(block);
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Reads the test database files. */
|
||||
|
||||
void
|
||||
test2(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j, k, rnd;
|
||||
buf_block_t* block;
|
||||
byte* frame;
|
||||
ulint tm, oldtm;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rnd = 123;
|
||||
|
||||
for (k = 0; k < 100; k++) {
|
||||
rnd += 23651;
|
||||
rnd = rnd % 4096;
|
||||
|
||||
i = rnd / 4096;
|
||||
j = rnd % 2048;
|
||||
|
||||
block = buf_page_get(i, j, NULL);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
buf_page_s_lock(block);
|
||||
|
||||
ut_a(*((ulint*)(frame + 16)) == j);
|
||||
|
||||
buf_page_s_unlock(block);
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for random read %lu milliseconds\n",
|
||||
tm - oldtm);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Reads the test database files. */
|
||||
|
||||
void
|
||||
test4(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j, k, rnd;
|
||||
buf_block_t* block;
|
||||
byte* frame;
|
||||
ulint tm, oldtm;
|
||||
|
||||
/* Flush the pool of high-offset pages */
|
||||
for (i = 0; i < 1000; i++) {
|
||||
|
||||
block = buf_page_get(0, i, NULL);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
buf_page_s_lock(block);
|
||||
|
||||
ut_a(*((ulint*)(frame + 16)) == i);
|
||||
|
||||
buf_page_s_unlock(block);
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
|
||||
printf("Test starts\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rnd = 123;
|
||||
|
||||
for (k = 0; k < 400; k++) {
|
||||
|
||||
rnd += 4357;
|
||||
|
||||
i = 0;
|
||||
j = 1001 + rnd % 3000;
|
||||
|
||||
block = buf_page_get(i, j, NULL);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
buf_page_s_lock(block);
|
||||
|
||||
ut_a(*((ulint*)(frame + 16)) == j);
|
||||
|
||||
buf_page_s_unlock(block);
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf(
|
||||
"Wall clock time for %lu random no read-ahead %lu milliseconds\n",
|
||||
k, tm - oldtm);
|
||||
|
||||
/* Flush the pool of high-offset pages */
|
||||
for (i = 0; i < 1000; i++) {
|
||||
|
||||
block = buf_page_get(0, i, NULL);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
buf_page_s_lock(block);
|
||||
|
||||
ut_a(*((ulint*)(frame + 16)) == i);
|
||||
|
||||
buf_page_s_unlock(block);
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
|
||||
printf("Test starts\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rnd = 123;
|
||||
|
||||
for (k = 0; k < 400; k++) {
|
||||
|
||||
rnd += 4357;
|
||||
|
||||
i = 0;
|
||||
j = 1001 + rnd % 400;
|
||||
|
||||
block = buf_page_get(i, j, NULL);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
buf_page_s_lock(block);
|
||||
|
||||
ut_a(*((ulint*)(frame + 16)) == j);
|
||||
|
||||
buf_page_s_unlock(block);
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf(
|
||||
"Wall clock time for %lu random read-ahead %lu milliseconds\n",
|
||||
k, tm - oldtm);
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Tests speed of CPU algorithms. */
|
||||
|
||||
void
|
||||
test3(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j;
|
||||
buf_block_t* block;
|
||||
ulint tm, oldtm;
|
||||
|
||||
for (i = 0; i < 400; i++) {
|
||||
|
||||
block = buf_page_get(0, i, NULL);
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
|
||||
os_thread_sleep(2000000);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 500; j++) {
|
||||
for (i = 0; i < 200; i++) {
|
||||
|
||||
block = buf_page_get(0, i, NULL);
|
||||
|
||||
/*
|
||||
buf_page_s_lock(block);
|
||||
|
||||
buf_page_s_unlock(block);
|
||||
*/
|
||||
|
||||
buf_page_release(block);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for %lu page get-release %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 500; j++) {
|
||||
for (i = 0; i < 200; i++) {
|
||||
|
||||
buf_page_get(0, i, NULL);
|
||||
/*
|
||||
buf_page_s_lock(block);
|
||||
|
||||
buf_page_s_unlock(block);
|
||||
*/
|
||||
buf_page_release(block);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for %lu block get-release %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 100000; i++) {
|
||||
block = buf_block_alloc();
|
||||
buf_block_free(block);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for %lu block alloc-free %lu milliseconds\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
ha_print_info(buf_pool->page_hash);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Frees the spaces in the file system. */
|
||||
|
||||
void
|
||||
free_system(void)
|
||||
/*=============*/
|
||||
{
|
||||
ulint i;
|
||||
|
||||
for (i = 0; i < 1; i++) {
|
||||
fil_space_free(i);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Test for file space management. */
|
||||
|
||||
void
|
||||
test5(void)
|
||||
/*=======*/
|
||||
{
|
||||
mtr_t mtr;
|
||||
ulint seg_page;
|
||||
ulint new_page;
|
||||
ulint seg_page2;
|
||||
ulint new_page2;
|
||||
buf_block_t* block;
|
||||
bool finished;
|
||||
ulint i;
|
||||
ulint reserved;
|
||||
ulint used;
|
||||
ulint tm, oldtm;
|
||||
|
||||
os_thread_sleep(1000000);
|
||||
|
||||
buf_validate();
|
||||
|
||||
buf_print();
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
seg_page = fseg_create(0, 0, 1000, 555, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
os_thread_sleep(1000000);
|
||||
buf_validate();
|
||||
printf("Segment created: header page %lu\n", seg_page);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page, NULL, &mtr);
|
||||
|
||||
new_page = fseg_alloc_free_page(buf_block_get_frame(block) + 1000,
|
||||
2, FSP_UP, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
buf_validate();
|
||||
buf_print();
|
||||
printf("Segment page allocated %lu\n", new_page);
|
||||
|
||||
finished = FALSE;
|
||||
|
||||
while (!finished) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page, NULL, &mtr);
|
||||
|
||||
finished = fseg_free_step(
|
||||
buf_block_get_frame(block) + 1000, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
/***********************************************/
|
||||
os_thread_sleep(1000000);
|
||||
buf_validate();
|
||||
buf_print();
|
||||
mtr_start(&mtr);
|
||||
|
||||
seg_page = fseg_create(0, 0, 1000, 557, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
ut_a(seg_page == 1);
|
||||
|
||||
printf("Segment created: header page %lu\n", seg_page);
|
||||
|
||||
new_page = seg_page;
|
||||
for (i = 0; i < 1023; i++) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page, NULL, &mtr);
|
||||
|
||||
new_page = fseg_alloc_free_page(
|
||||
buf_block_get_frame(block) + 1000,
|
||||
new_page + 1, FSP_UP, &mtr);
|
||||
if (i < FSP_EXTENT_SIZE - 1) {
|
||||
ut_a(new_page == 2 + i);
|
||||
} else {
|
||||
ut_a(new_page == i + FSP_EXTENT_SIZE + 1);
|
||||
}
|
||||
|
||||
printf("%lu %lu; ", i, new_page);
|
||||
if (i % 10 == 0) {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
buf_print();
|
||||
buf_validate();
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page, NULL, &mtr);
|
||||
|
||||
mtr_page_s_lock(block, &mtr);
|
||||
|
||||
reserved = fseg_n_reserved_pages(buf_block_get_frame(block) + 1000,
|
||||
&used, &mtr);
|
||||
|
||||
ut_a(used == 1024);
|
||||
ut_a(reserved >= 1024);
|
||||
|
||||
printf("Pages used in segment %lu reserved by segment %lu \n",
|
||||
used, reserved);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
finished = FALSE;
|
||||
|
||||
while (!finished) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page, NULL, &mtr);
|
||||
|
||||
finished = fseg_free_step(
|
||||
buf_block_get_frame(block) + 1000, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
buf_print();
|
||||
buf_validate();
|
||||
|
||||
/***********************************************/
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
seg_page = fseg_create(0, 0, 1000, 557, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
ut_a(seg_page == 1);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
seg_page2 = fseg_create(0, 0, 1000, 558, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
ut_a(seg_page2 == 2);
|
||||
|
||||
new_page = seg_page;
|
||||
new_page2 = seg_page2;
|
||||
|
||||
for (;;) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page, NULL, &mtr);
|
||||
|
||||
new_page = fseg_alloc_free_page(
|
||||
buf_block_get_frame(block) + 1000,
|
||||
new_page + 1, FSP_UP, &mtr);
|
||||
|
||||
printf("1:%lu %lu; ", i, new_page);
|
||||
if (i % 10 == 0) {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
new_page = fseg_alloc_free_page(
|
||||
buf_block_get_frame(block) + 1000,
|
||||
new_page + 1, FSP_UP, &mtr);
|
||||
|
||||
printf("1:%lu %lu; ", i, new_page);
|
||||
if (i % 10 == 0) {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page2, NULL, &mtr);
|
||||
|
||||
new_page2 = fseg_alloc_free_page(
|
||||
buf_block_get_frame(block) + 1000,
|
||||
new_page2 + 1, FSP_UP, &mtr);
|
||||
|
||||
printf("2:%lu %lu; ", i, new_page2);
|
||||
if (i % 10 == 0) {
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
if (new_page2 == FIL_NULL) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page, NULL, &mtr);
|
||||
|
||||
mtr_page_s_lock(block, &mtr);
|
||||
|
||||
reserved = fseg_n_reserved_pages(buf_block_get_frame(block) + 1000,
|
||||
&used, &mtr);
|
||||
|
||||
printf("Pages used in segment 1 %lu, reserved by segment %lu \n",
|
||||
used, reserved);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page2, NULL, &mtr);
|
||||
|
||||
mtr_page_s_lock(block, &mtr);
|
||||
|
||||
reserved = fseg_n_reserved_pages(buf_block_get_frame(block) + 1000,
|
||||
&used, &mtr);
|
||||
|
||||
printf("Pages used in segment 2 %lu, reserved by segment %lu \n",
|
||||
used, reserved);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
for (;;) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page, NULL, &mtr);
|
||||
|
||||
fseg_free_step(
|
||||
buf_block_get_frame(block) + 1000, &mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page2, NULL, &mtr);
|
||||
|
||||
finished = fseg_free_step(
|
||||
buf_block_get_frame(block) + 1000, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
if (finished) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
seg_page2 = fseg_create(0, 0, 1000, 558, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
i = 0;
|
||||
for (;;) {
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page2, NULL, &mtr);
|
||||
|
||||
new_page2 = fseg_alloc_free_page(
|
||||
buf_block_get_frame(block) + 1000,
|
||||
557, FSP_DOWN, &mtr);
|
||||
|
||||
printf("%lu %lu; ", i, new_page2);
|
||||
mtr_commit(&mtr);
|
||||
|
||||
if (new_page2 == FIL_NULL) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page, NULL, &mtr);
|
||||
|
||||
finished = fseg_free_step(
|
||||
buf_block_get_frame(block) + 1000, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
if (finished) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page2, NULL, &mtr);
|
||||
|
||||
finished = fseg_free_step(
|
||||
buf_block_get_frame(block) + 1000, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
if (finished) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***************************************/
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 1000; i++) {
|
||||
mtr_start(&mtr);
|
||||
|
||||
seg_page = fseg_create(0, 0, 1000, 555, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page, NULL, &mtr);
|
||||
|
||||
new_page = fseg_alloc_free_page(buf_block_get_frame(block) + 1000,
|
||||
2, FSP_UP, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
finished = FALSE;
|
||||
|
||||
while (!finished) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = mtr_page_get(0, seg_page, NULL, &mtr);
|
||||
|
||||
finished = fseg_free_step(
|
||||
buf_block_get_frame(block) + 1000, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for %lu seg crea+free %lu millisecs\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
buf_validate();
|
||||
|
||||
buf_flush_batch(BUF_FLUSH_LIST, 500);
|
||||
|
||||
os_thread_sleep(1000000);
|
||||
|
||||
buf_all_freed();
|
||||
}
|
||||
|
||||
|
||||
/************************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
ulint n;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
os_aio_init(160, 5);
|
||||
sync_init();
|
||||
mem_init();
|
||||
fil_init(26); /* Allow 25 open files at a time */
|
||||
buf_pool_init(1000, 1000);
|
||||
log_init();
|
||||
|
||||
buf_validate();
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
create_files();
|
||||
|
||||
create_db();
|
||||
|
||||
buf_validate();
|
||||
|
||||
test5();
|
||||
/*
|
||||
test1();
|
||||
|
||||
test3();
|
||||
|
||||
test4();
|
||||
|
||||
test2();
|
||||
*/
|
||||
buf_validate();
|
||||
|
||||
n = buf_flush_batch(BUF_FLUSH_LIST, 500);
|
||||
|
||||
os_thread_sleep(1000000);
|
||||
|
||||
buf_all_freed();
|
||||
|
||||
free_system();
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
|
||||
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tsfsp: ..\fsp.lib tsfsp.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\..\btr.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsfsp.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,12 +0,0 @@
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tsha: ..\ha.lib tsha.c makefile
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\..\btr.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsha.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,120 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for hash table
|
||||
|
||||
(c) 1994, 1995 Innobase Oy
|
||||
|
||||
Created 1/25/1994 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "ut0ut.h"
|
||||
#include "ha0ha.h"
|
||||
#include "mem0mem.h"
|
||||
#include "sync0sync.h"
|
||||
|
||||
ulint ulint_array[200000];
|
||||
|
||||
void
|
||||
test1(void)
|
||||
{
|
||||
hash_table_t* table1;
|
||||
ulint i;
|
||||
ulint n313 = 313;
|
||||
ulint n414 = 414;
|
||||
|
||||
printf("------------------------------------------------\n");
|
||||
printf("TEST 1. BASIC TEST\n");
|
||||
|
||||
table1 = ha_create(50000);
|
||||
|
||||
ha_insert_for_fold(table1, 313, &n313);
|
||||
|
||||
ha_insert_for_fold(table1, 313, &n414);
|
||||
|
||||
ut_a(ha_validate(table1));
|
||||
|
||||
ha_delete(table1, 313, &n313);
|
||||
ha_delete(table1, 313, &n414);
|
||||
|
||||
ut_a(ha_validate(table1));
|
||||
|
||||
printf("------------------------------------------------\n");
|
||||
printf("TEST 2. TEST OF MASSIVE INSERTS AND DELETES\n");
|
||||
|
||||
table1 = ha_create(10000);
|
||||
|
||||
for (i = 0; i < 200000; i++) {
|
||||
ulint_array[i] = i;
|
||||
}
|
||||
|
||||
for (i = 0; i < 50000; i++) {
|
||||
ha_insert_for_fold(table1, i * 7, ulint_array + i);
|
||||
}
|
||||
|
||||
ut_a(ha_validate(table1));
|
||||
|
||||
for (i = 0; i < 50000; i++) {
|
||||
ha_delete(table1, i * 7, ulint_array + i);
|
||||
}
|
||||
|
||||
ut_a(ha_validate(table1));
|
||||
}
|
||||
|
||||
void
|
||||
test2(void)
|
||||
{
|
||||
hash_table_t* table1;
|
||||
ulint i;
|
||||
ulint oldtm, tm;
|
||||
ha_node_t* node;
|
||||
|
||||
printf("------------------------------------------------\n");
|
||||
printf("TEST 3. SPEED TEST\n");
|
||||
|
||||
table1 = ha_create(300000);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 200000; i++) {
|
||||
ha_insert_for_fold(table1, i * 27877, ulint_array + i);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for %lu inserts %lu millisecs\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 200000; i++) {
|
||||
node = ha_search(table1, i * 27877);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for %lu searches %lu millisecs\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 200000; i++) {
|
||||
ha_delete(table1, i * 27877, ulint_array + i);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for %lu deletes %lu millisecs\n",
|
||||
i, tm - oldtm);
|
||||
}
|
||||
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
sync_init();
|
||||
mem_init(1000000);
|
||||
|
||||
test1();
|
||||
|
||||
test2();
|
||||
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,164 +0,0 @@
|
||||
/***************************************************************************
|
||||
Version control for database, common definitions, and include files
|
||||
|
||||
(c) 1994 - 2000 Innobase Oy
|
||||
|
||||
Created 1/20/1994 Heikki Tuuri
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef univ_i
|
||||
#define univ_i
|
||||
|
||||
#define UNIV_INTEL
|
||||
#define UNIV_PENTIUM
|
||||
/* If UNIV_WINNT is not defined, we assume Windows 95 */
|
||||
|
||||
#define UNIV_WINNT
|
||||
#define UNIV_WINNT4
|
||||
#define __NT__
|
||||
|
||||
#define UNIV_VISUALC
|
||||
|
||||
#define __WIN__
|
||||
#define _WIN32_WINNT 0x0400
|
||||
|
||||
/* DEBUG VERSION CONTROL
|
||||
===================== */
|
||||
/* Make a non-inline debug version */
|
||||
/*
|
||||
#define UNIV_DEBUG
|
||||
#define UNIV_MEM_DEBUG
|
||||
#define UNIV_SYNC_DEBUG
|
||||
#define UNIV_SEARCH_DEBUG
|
||||
|
||||
#define UNIV_IBUF_DEBUG
|
||||
|
||||
#define UNIV_SEARCH_PERF_STAT
|
||||
#define UNIV_SYNC_PERF_STAT
|
||||
*/
|
||||
#define UNIV_LIGHT_MEM_DEBUG
|
||||
|
||||
#define YYDEBUG 1
|
||||
/*
|
||||
#define UNIV_SQL_DEBUG
|
||||
#define UNIV_LOG_DEBUG
|
||||
*/
|
||||
/* the above option prevents forcing of log to disk
|
||||
at a buffer page write: it should be tested with this
|
||||
option off; also some ibuf tests are suppressed */
|
||||
/*
|
||||
#define UNIV_BASIC_LOG_DEBUG
|
||||
*/
|
||||
/* the above option enables basic recovery debugging:
|
||||
new allocated file pages are reset */
|
||||
|
||||
/* The debug version is slower, thus we may change the length of test loops
|
||||
depending on the UNIV_DBC parameter */
|
||||
#ifdef UNIV_DEBUG
|
||||
#define UNIV_DBC 1
|
||||
#else
|
||||
#define UNIV_DBC 100
|
||||
#endif
|
||||
|
||||
#ifndef UNIV_DEBUG
|
||||
/* Definition for inline version */
|
||||
|
||||
#ifdef UNIV_VISUALC
|
||||
#define UNIV_INLINE __inline
|
||||
#elif defined(UNIV_GNUC)
|
||||
#define UNIV_INLINE extern __inline__
|
||||
#endif
|
||||
|
||||
#else
|
||||
/* If we want to compile a noninlined version we use the following macro
|
||||
definitions: */
|
||||
|
||||
#define UNIV_NONINL
|
||||
#define UNIV_INLINE
|
||||
|
||||
#endif /* UNIV_DEBUG */
|
||||
/* If the compiler does not know inline specifier, we use: */
|
||||
/*
|
||||
#define UNIV_INLINE static
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
MACHINE VERSION CONTROL
|
||||
=======================
|
||||
*/
|
||||
|
||||
#ifdef UNIV_PENTIUM
|
||||
|
||||
/* In a 32-bit computer word size is 4 */
|
||||
#define UNIV_WORD_SIZE 4
|
||||
|
||||
/* The following alignment is used in memory allocations in memory heap
|
||||
management to ensure correct alignment for doubles etc. */
|
||||
#define UNIV_MEM_ALIGNMENT 8
|
||||
|
||||
/* The following alignment is used in aligning lints etc. */
|
||||
#define UNIV_WORD_ALIGNMENT UNIV_WORD_SIZE
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
DATABASE VERSION CONTROL
|
||||
========================
|
||||
*/
|
||||
|
||||
/* The universal page size of the database */
|
||||
#define UNIV_PAGE_SIZE (2 * 8192)/* NOTE! Currently, this has to be a
|
||||
power of 2 and divisible by
|
||||
UNIV_MEM_ALIGNMENT */
|
||||
|
||||
/* Do non-buffered io in buffer pool read/write operations */
|
||||
#define UNIV_NON_BUFFERED_IO
|
||||
|
||||
/* Maximum number of parallel threads in a parallelized operation */
|
||||
#define UNIV_MAX_PARALLELISM 32
|
||||
|
||||
/*
|
||||
UNIVERSAL TYPE DEFINITIONS
|
||||
==========================
|
||||
*/
|
||||
|
||||
|
||||
typedef unsigned char byte;
|
||||
|
||||
/* An other basic type we use is unsigned long integer which is intended to be
|
||||
equal to the word size of the machine. */
|
||||
|
||||
typedef unsigned long int ulint;
|
||||
|
||||
typedef long int lint;
|
||||
|
||||
/* The following type should be at least a 64-bit floating point number */
|
||||
typedef double utfloat;
|
||||
|
||||
/* The 'undefined' value for a ulint */
|
||||
#define ULINT_UNDEFINED ((ulint)(-1))
|
||||
|
||||
/* The undefined 32-bit unsigned integer */
|
||||
#define ULINT32_UNDEFINED 0xFFFFFFFF
|
||||
|
||||
/* Maximum value for a ulint */
|
||||
#define ULINT_MAX ((ulint)(-2))
|
||||
|
||||
|
||||
/* Definition of the boolean type */
|
||||
typedef ulint bool;
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
/* The following number as the length of a logical field means that the field
|
||||
has the SQL NULL as its value. */
|
||||
#define UNIV_SQL_NULL ULINT_UNDEFINED
|
||||
|
||||
#include <stdio.h>
|
||||
#include "ut0dbg.h"
|
||||
#include "ut0ut.h"
|
||||
#include "db0err.h"
|
||||
|
||||
#endif
|
@ -1,181 +0,0 @@
|
||||
/***************************************************************************
|
||||
Version control for database, common definitions, and include files
|
||||
|
||||
(c) 1994 - 1996 Innobase Oy
|
||||
|
||||
Created 1/20/1994 Heikki Tuuri
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef univ_i
|
||||
#define univ_i
|
||||
|
||||
#define UNIV_INTEL
|
||||
#define UNIV_PENTIUM
|
||||
/* If UNIV_WINNT is not defined, we assume Windows 95 */
|
||||
|
||||
#define UNIV_WINNT
|
||||
#define UNIV_WINNT4
|
||||
|
||||
#define UNIV_VISUALC
|
||||
|
||||
/* DEBUG VERSION CONTROL
|
||||
===================== */
|
||||
/* Make a profiler version where mutex_fence does not use CPUID and therefore
|
||||
is not totally safe. The sync-library must be recompiled before profiling. */
|
||||
/*
|
||||
#define UNIV_PROFILE
|
||||
*/
|
||||
/* When the following flag is defined, also mutex lock word reset to 0
|
||||
in mutex_exit is performed using a serializing instruction, which does not
|
||||
allow speculative reads be performed before memory writes */
|
||||
/*
|
||||
#define SYNC_SERIALIZE_MUTEX_RESET
|
||||
*/
|
||||
/* Make a non-inline debug version */
|
||||
|
||||
#define UNIV_DEBUG
|
||||
#define UNIV_MEM_DEBUG
|
||||
#define UNIV_SYNC_DEBUG
|
||||
#define UNIV_SEARCH_DEBUG
|
||||
|
||||
#define UNIV_IBUF_DEBUG
|
||||
|
||||
#define UNIV_SEARCH_PERF_STAT
|
||||
#define UNIV_SYNC_PERF_STAT
|
||||
|
||||
|
||||
#define UNIV_LIGHT_MEM_DEBUG
|
||||
|
||||
#define YYDEBUG 1
|
||||
/*
|
||||
#define UNIV_SQL_DEBUG
|
||||
#define UNIV_LOG_DEBUG
|
||||
*/
|
||||
/* the above option prevents forcing of log to disk
|
||||
at a buffer page write: it should be tested with this
|
||||
option off; also some ibuf tests are suppressed */
|
||||
/*
|
||||
#define UNIV_BASIC_LOG_DEBUG
|
||||
*/
|
||||
/* the above option enables basic recovery debugging:
|
||||
new allocated file pages are reset */
|
||||
|
||||
/* The debug version is slower, thus we may change the length of test loops
|
||||
depending on the UNIV_DBC parameter */
|
||||
#ifdef UNIV_DEBUG
|
||||
#define UNIV_DBC 1
|
||||
#else
|
||||
#define UNIV_DBC 100
|
||||
#endif
|
||||
|
||||
#ifndef UNIV_DEBUG
|
||||
/* Definition for inline version */
|
||||
|
||||
#ifdef UNIV_VISUALC
|
||||
#define UNIV_INLINE __inline
|
||||
#elif defined(UNIV_GNUC)
|
||||
#define UNIV_INLINE extern __inline__
|
||||
#endif
|
||||
|
||||
#else
|
||||
/* If we want to compile a noninlined version we use the following macro
|
||||
definitions: */
|
||||
|
||||
#define UNIV_NONINL
|
||||
#define UNIV_INLINE
|
||||
|
||||
#endif /* UNIV_DEBUG */
|
||||
/* If the compiler does not know inline specifier, we use: */
|
||||
/*
|
||||
#define UNIV_INLINE static
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
MACHINE VERSION CONTROL
|
||||
=======================
|
||||
*/
|
||||
|
||||
#ifdef UNIV_PENTIUM
|
||||
|
||||
/* In a 32-bit computer word size is 4 */
|
||||
#define UNIV_WORD_SIZE 4
|
||||
|
||||
/* The following alignment is used in memory allocations in memory heap
|
||||
management to ensure correct alignment for doubles etc. */
|
||||
#define UNIV_MEM_ALIGNMENT 8
|
||||
|
||||
/* The following alignment is used in aligning lints etc. */
|
||||
#define UNIV_WORD_ALIGNMENT UNIV_WORD_SIZE
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
DATABASE VERSION CONTROL
|
||||
========================
|
||||
*/
|
||||
|
||||
/* The universal page size of the database */
|
||||
#define UNIV_PAGE_SIZE 8192 /* NOTE! Currently, this has to be a
|
||||
power of 2 and divisible by
|
||||
UNIV_MEM_ALIGNMENT */
|
||||
/* 2-based logarithm of UNIV_PAGE_SIZE */
|
||||
#define UNIV_PAGE_SIZE_SHIFT 13
|
||||
|
||||
/* Do asynchronous io in buffer pool read/write operations */
|
||||
#ifdef UNIV_WINNT
|
||||
#define UNIV_ASYNC_IO
|
||||
#endif
|
||||
|
||||
/* Do non-buffered io in buffer pool read/write operations */
|
||||
#define UNIV_NON_BUFFERED_IO
|
||||
|
||||
/* Maximum number of parallel threads in a parallelized operation */
|
||||
#define UNIV_MAX_PARALLELISM 32
|
||||
|
||||
/*
|
||||
UNIVERSAL TYPE DEFINITIONS
|
||||
==========================
|
||||
*/
|
||||
|
||||
/*
|
||||
typedef unsigned char byte;
|
||||
*/
|
||||
|
||||
/* An other basic type we use is unsigned long integer which is intended to be
|
||||
equal to the word size of the machine. */
|
||||
|
||||
typedef unsigned long int ulint;
|
||||
|
||||
typedef long int lint;
|
||||
|
||||
/* The following type should be at least a 64-bit floating point number */
|
||||
typedef double utfloat;
|
||||
|
||||
/* The 'undefined' value for a ulint */
|
||||
#define ULINT_UNDEFINED ((ulint)(-1))
|
||||
|
||||
/* The undefined 32-bit unsigned integer */
|
||||
#define ULINT32_UNDEFINED 0xFFFFFFFF
|
||||
|
||||
/* Maximum value for a ulint */
|
||||
#define ULINT_MAX ((ulint)(-2))
|
||||
|
||||
/* Definition of the boolean type */
|
||||
#ifndef bool
|
||||
typedef ulint bool;
|
||||
#endif
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
/* The following number as the length of a logical field means that the field
|
||||
has the SQL NULL as its value. */
|
||||
#define UNIV_SQL_NULL ULINT_UNDEFINED
|
||||
|
||||
#include <stdio.h>
|
||||
#include "ut0dbg.h"
|
||||
#include "ut0ut.h"
|
||||
#include "db0err.h"
|
||||
|
||||
#endif
|
@ -1,12 +0,0 @@
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tsmach: ..\mach.lib tsmach.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\mach.lib ..\..\ut.lib ..\..\os.lib tsmach.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,158 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for the machine-dependent utilities
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 11/28/1995 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "../mach0data.h"
|
||||
|
||||
byte arr[4000000];
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
Test for ulint write and read. */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint a, i, j;
|
||||
ulint tm, oldtm;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 1. Speed test of ulint read and write \n");
|
||||
|
||||
a = 0;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 100; j++) {
|
||||
for (i = 0; i < 10000; i++) {
|
||||
|
||||
a += mach_read_from_4(arr + i * 4);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for read of %lu ulints %lu millisecs\n",
|
||||
j * i, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 100; j++) {
|
||||
for (i = 0; i < 10000; i++) {
|
||||
|
||||
a += mach_read(arr + i * 4);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for read of %lu ulints %lu millisecs\n",
|
||||
j * i, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 100; j++) {
|
||||
for (i = 0; i < 10000; i++) {
|
||||
|
||||
a += mach_read_from_4(arr + i * 4 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for read of %lu ulints %lu millisecs\n",
|
||||
j * i, tm - oldtm);
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 100; j++) {
|
||||
for (i = 0; i < 10000; i++) {
|
||||
|
||||
a += mach_read(arr + i * 4 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for read of %lu ulints %lu millisecs\n",
|
||||
j * i, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 1000000; i++) {
|
||||
|
||||
a += mach_read_from_4(arr + i * 4);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for read of %lu ulints %lu millisecs\n",
|
||||
i, tm - oldtm);
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 1000000; i++) {
|
||||
|
||||
a += mach_read(arr + i * 4);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for read of %lu ulints %lu millisecs\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 100; j++) {
|
||||
for (i = 0; i < 10000; i++) {
|
||||
|
||||
a += mach_read_from_2(arr + i * 2);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for read of %lu 16-bit ints %lu millisecs\n",
|
||||
j * i, tm - oldtm);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Test for ulint write and read. */
|
||||
|
||||
void
|
||||
test2(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint a[2];
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 2. Correctness test of ulint read and write \n");
|
||||
|
||||
mach_write_to_4((byte*)&a, 737237727);
|
||||
|
||||
ut_a(737237727 == mach_read_from_4((byte*)&a));
|
||||
|
||||
mach_write_to_2((byte*)&a, 7372);
|
||||
|
||||
ut_a(7372 == mach_read_from_2((byte*)&a));
|
||||
|
||||
mach_write_to_1((byte*)&a, 27);
|
||||
|
||||
ut_a(27 == mach_read_from_1((byte*)&a));
|
||||
|
||||
mach_write((byte*)&a, 737237727);
|
||||
|
||||
ut_a(737237727 == mach_read((byte*)&a));
|
||||
}
|
||||
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
|
||||
printf("TEST SUCCESSFULLY COMPLETED!\n");
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tsmem: ..\mem.lib tsmem.c makefile
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\mem.lib ..\..\btr.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\os.lib tsmem.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,497 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for the memory management of Innobase
|
||||
|
||||
(c) 1994, 1995 Innobase Oy
|
||||
|
||||
Created 6/10/1994 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "../mem0mem.h"
|
||||
#include "sync0sync.h"
|
||||
#include "ut0rnd.h"
|
||||
|
||||
mem_heap_t* heap_arr[1200];
|
||||
|
||||
byte* buf_arr[10000];
|
||||
ulint rnd_arr[10000];
|
||||
|
||||
|
||||
#ifdef UNIV_DEBUG
|
||||
/*********************************************************************
|
||||
Debug version test. */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
mem_heap_t* heap_1, *heap_2;
|
||||
byte* buf_1, *buf_2, *buf_3;
|
||||
byte check;
|
||||
bool error;
|
||||
ulint i;
|
||||
ulint j;
|
||||
ulint sum;
|
||||
ulint user_size;
|
||||
ulint phys_size, phys_size_1, phys_size_2;
|
||||
ulint n_blocks;
|
||||
ulint p;
|
||||
byte block[1024];
|
||||
byte* top_1, *top_2;
|
||||
|
||||
/* For this test to work the memory alignment must be
|
||||
even (presumably a reasonable assumption) */
|
||||
ut_a(0 == (UNIV_MEM_ALIGNMENT & 1));
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 1. Basic test \n");
|
||||
|
||||
heap_1 = mem_heap_create(0);
|
||||
|
||||
buf_1 = mem_heap_alloc(heap_1, 11);
|
||||
|
||||
heap_2 = mem_heap_create(0);
|
||||
|
||||
buf_2 = mem_heap_alloc(heap_1, 15);
|
||||
|
||||
/* Test that the field is properly initialized */
|
||||
for (i = 0; i < 11; i++) {
|
||||
ut_a((*(buf_1 + i) == 0xBA) || (*(buf_1 + i) == 0xBE));
|
||||
}
|
||||
|
||||
check = *(buf_1 + 11);
|
||||
|
||||
mem_validate();
|
||||
|
||||
/* Make an advertent error in the heap */
|
||||
(*(buf_1 + 11))++;
|
||||
|
||||
error = mem_validate_no_assert();
|
||||
|
||||
ut_a(error);
|
||||
|
||||
/* Fix the error in heap before freeing */
|
||||
*(buf_1 + 11) = check;
|
||||
|
||||
mem_print_info();
|
||||
|
||||
/* Free the top buffer buf_2 */
|
||||
mem_heap_free_top(heap_1, 15);
|
||||
|
||||
/* Test that the field is properly erased */
|
||||
for (i = 0; i < 15; i++) {
|
||||
ut_a((*(buf_2 + i) == 0xDE) || (*(buf_2 + i) == 0xAD));
|
||||
}
|
||||
|
||||
/* Test that a new buffer is allocated from the same position
|
||||
as buf_2 */
|
||||
buf_3 = mem_heap_alloc(heap_1, 15);
|
||||
|
||||
ut_a(buf_3 == buf_2);
|
||||
|
||||
mem_heap_free(heap_1);
|
||||
|
||||
/* Test that the field is properly erased */
|
||||
for (i = 0; i < 11; i++) {
|
||||
ut_a((*(buf_1 + i) == 0xDE) || (*(buf_1 + i) == 0xAD));
|
||||
}
|
||||
|
||||
mem_validate();
|
||||
|
||||
mem_print_info();
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 2. Test of massive allocation and freeing\n");
|
||||
|
||||
sum = 0;
|
||||
for (i = 0; i < 10000; i++) {
|
||||
|
||||
j = ut_rnd_gen_ulint() % 16 + 15;
|
||||
|
||||
sum = sum + j;
|
||||
|
||||
buf_1 = mem_heap_alloc(heap_2, j);
|
||||
rnd_arr[i] = j;
|
||||
|
||||
buf_arr[i] = buf_1;
|
||||
|
||||
ut_a(buf_1 == mem_heap_get_top(heap_2, j));
|
||||
}
|
||||
|
||||
mem_heap_validate_or_print(heap_2, NULL, FALSE, &error, &user_size,
|
||||
&phys_size_1,
|
||||
&n_blocks);
|
||||
|
||||
ut_a(!error);
|
||||
ut_a(user_size == sum);
|
||||
|
||||
(*(buf_1 - 1))++;
|
||||
|
||||
ut_a(mem_validate_no_assert());
|
||||
|
||||
(*(buf_1 - 1))--;
|
||||
|
||||
mem_print_info();
|
||||
|
||||
|
||||
for (p = 10000; p > 0 ; p--) {
|
||||
|
||||
j = rnd_arr[p - 1];
|
||||
|
||||
ut_a(buf_arr[p - 1] == mem_heap_get_top(heap_2, j));
|
||||
mem_heap_free_top(heap_2, j);
|
||||
}
|
||||
|
||||
mem_print_info();
|
||||
|
||||
mem_heap_free(heap_2);
|
||||
|
||||
mem_print_info();
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 3. More tests on the validating \n");
|
||||
|
||||
heap_1 = mem_heap_create(UNIV_MEM_ALIGNMENT * 20);
|
||||
|
||||
buf_1 = mem_heap_alloc(heap_1, UNIV_MEM_ALIGNMENT * 20);
|
||||
|
||||
mem_heap_validate_or_print(heap_1, NULL, FALSE, &error, &user_size,
|
||||
&phys_size_1,
|
||||
&n_blocks);
|
||||
|
||||
ut_a((ulint)(buf_1 - (byte*)heap_1) == (MEM_BLOCK_HEADER_SIZE
|
||||
+ MEM_FIELD_HEADER_SIZE));
|
||||
|
||||
mem_validate();
|
||||
|
||||
mem_print_info();
|
||||
|
||||
ut_a(user_size == UNIV_MEM_ALIGNMENT * 20);
|
||||
ut_a(phys_size_1 == (ulint)(ut_calc_align(MEM_FIELD_HEADER_SIZE
|
||||
+ UNIV_MEM_ALIGNMENT * 20
|
||||
+ MEM_FIELD_TRAILER_SIZE,
|
||||
UNIV_MEM_ALIGNMENT)
|
||||
+ MEM_BLOCK_HEADER_SIZE));
|
||||
|
||||
ut_a(n_blocks == 1);
|
||||
|
||||
buf_2 = mem_heap_alloc(heap_1, UNIV_MEM_ALIGNMENT * 3 - 1);
|
||||
|
||||
mem_heap_validate_or_print(heap_1, NULL, FALSE, &error,
|
||||
&user_size, &phys_size_2,
|
||||
&n_blocks);
|
||||
|
||||
printf("Physical size of the heap %ld\n", phys_size_2);
|
||||
|
||||
ut_a(!error);
|
||||
ut_a(user_size == UNIV_MEM_ALIGNMENT * 23 - 1);
|
||||
ut_a(phys_size_2 == (ulint) (phys_size_1
|
||||
+ ut_calc_align(MEM_FIELD_HEADER_SIZE
|
||||
+ phys_size_1 * 2
|
||||
+ MEM_FIELD_TRAILER_SIZE,
|
||||
UNIV_MEM_ALIGNMENT)
|
||||
+ MEM_BLOCK_HEADER_SIZE));
|
||||
|
||||
ut_a(n_blocks == 2);
|
||||
|
||||
buf_3 = mem_heap_alloc(heap_1, UNIV_MEM_ALIGNMENT * 3 + 5);
|
||||
|
||||
ut_a((ulint)(buf_3 - buf_2) == ut_calc_align(
|
||||
(UNIV_MEM_ALIGNMENT * 3
|
||||
+ MEM_FIELD_TRAILER_SIZE),
|
||||
UNIV_MEM_ALIGNMENT)
|
||||
+ MEM_FIELD_HEADER_SIZE);
|
||||
|
||||
|
||||
ut_memcpy(buf_3, buf_2, UNIV_MEM_ALIGNMENT * 3);
|
||||
|
||||
mem_heap_validate_or_print(heap_1, NULL, FALSE, &error,
|
||||
&user_size, &phys_size,
|
||||
&n_blocks);
|
||||
|
||||
ut_a(!error);
|
||||
ut_a(user_size == UNIV_MEM_ALIGNMENT * 26 + 4);
|
||||
ut_a(phys_size == phys_size_2);
|
||||
ut_a(n_blocks == 2);
|
||||
|
||||
|
||||
/* Make an advertent error to buf_3 */
|
||||
|
||||
(*(buf_3 - 1))++;
|
||||
|
||||
mem_heap_validate_or_print(heap_1, NULL, FALSE, &error,
|
||||
&user_size, &phys_size,
|
||||
&n_blocks);
|
||||
|
||||
ut_a(error);
|
||||
ut_a(user_size == 0);
|
||||
ut_a(phys_size == 0);
|
||||
ut_a(n_blocks == 0);
|
||||
|
||||
/* Fix the error and make another */
|
||||
|
||||
(*(buf_3 - 1))--;
|
||||
(*(buf_3 + UNIV_MEM_ALIGNMENT * 3 + 5))++;
|
||||
|
||||
mem_heap_validate_or_print(heap_1, NULL, FALSE, &error,
|
||||
&user_size, &phys_size,
|
||||
&n_blocks);
|
||||
|
||||
ut_a(error);
|
||||
|
||||
(*(buf_3 + UNIV_MEM_ALIGNMENT * 3 + 5))--;
|
||||
|
||||
buf_1 = mem_heap_alloc(heap_1, UNIV_MEM_ALIGNMENT + 4);
|
||||
|
||||
ut_a((ulint)(buf_1 - buf_3) == ut_calc_align(UNIV_MEM_ALIGNMENT * 3 + 5
|
||||
+ MEM_FIELD_TRAILER_SIZE ,
|
||||
UNIV_MEM_ALIGNMENT)
|
||||
+ MEM_FIELD_HEADER_SIZE);
|
||||
|
||||
|
||||
mem_heap_validate_or_print(heap_1, NULL, FALSE, &error,
|
||||
&user_size, &phys_size,
|
||||
&n_blocks);
|
||||
|
||||
ut_a(!error);
|
||||
ut_a(user_size == UNIV_MEM_ALIGNMENT * 27 + 8);
|
||||
ut_a(phys_size == phys_size_2);
|
||||
ut_a(n_blocks == 2);
|
||||
|
||||
|
||||
mem_print_info();
|
||||
|
||||
mem_heap_free(heap_1);
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 4. Test of massive allocation \n");
|
||||
printf("of heaps to test the hash table\n");
|
||||
|
||||
for (i = 0; i < 500; i++) {
|
||||
heap_arr[i] = mem_heap_create(i);
|
||||
buf_2 = mem_heap_alloc(heap_arr[i], 2 * i);
|
||||
}
|
||||
|
||||
mem_validate();
|
||||
|
||||
for (i = 0; i < 500; i++) {
|
||||
mem_heap_free(heap_arr[i]);
|
||||
}
|
||||
|
||||
mem_validate();
|
||||
|
||||
mem_print_info();
|
||||
|
||||
/* Validating a freed heap should generate an error */
|
||||
|
||||
mem_heap_validate_or_print(heap_1, NULL, FALSE, &error,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
ut_a(error);
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 5. Test of mem_alloc and mem_free \n");
|
||||
|
||||
buf_1 = mem_alloc(11100);
|
||||
buf_2 = mem_alloc(23);
|
||||
|
||||
ut_memcpy(buf_2, buf_1, 23);
|
||||
|
||||
mem_validate();
|
||||
|
||||
mem_print_info();
|
||||
|
||||
mem_free(buf_1);
|
||||
mem_free(buf_2);
|
||||
|
||||
mem_validate();
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 6. Test of mem_heap_print \n");
|
||||
|
||||
heap_1 = mem_heap_create(0);
|
||||
|
||||
buf_1 = mem_heap_alloc(heap_1, 7);
|
||||
|
||||
ut_memcpy(buf_1, "Pascal", 7);
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
buf_1 = mem_heap_alloc(heap_1, 6);
|
||||
ut_memcpy(buf_1, "Cobol", 6);
|
||||
}
|
||||
|
||||
printf("A heap with 1 Pascal and 10 Cobol's\n");
|
||||
mem_heap_print(heap_1);
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
mem_heap_free_top(heap_1, 6);
|
||||
}
|
||||
|
||||
printf("A heap with 1 Pascal and 0 Cobol's\n");
|
||||
mem_heap_print(heap_1);
|
||||
|
||||
ut_a(mem_all_freed() == FALSE);
|
||||
|
||||
mem_heap_free(heap_1);
|
||||
|
||||
ut_a(mem_all_freed() == TRUE);
|
||||
|
||||
mem_print_info();
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 7. Test of mem_heap_fast_create \n");
|
||||
|
||||
heap_1 = mem_heap_fast_create(1024, block);
|
||||
|
||||
buf_1 = mem_heap_alloc(heap_1, 7);
|
||||
|
||||
ut_memcpy(buf_1, "Pascal", 7);
|
||||
|
||||
for (i = 0; i < 1000; i++) {
|
||||
buf_1 = mem_heap_alloc(heap_1, 6);
|
||||
ut_memcpy(buf_1, "Cobol", 6);
|
||||
}
|
||||
|
||||
for (i = 0; i < 1000; i++) {
|
||||
mem_heap_free_top(heap_1, 6);
|
||||
}
|
||||
|
||||
ut_a(mem_all_freed() == FALSE);
|
||||
|
||||
mem_heap_free(heap_1);
|
||||
|
||||
ut_a(mem_all_freed() == TRUE);
|
||||
|
||||
mem_print_info();
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 8. Test of heap top freeing \n");
|
||||
|
||||
heap_1 = mem_heap_fast_create(1024, block);
|
||||
|
||||
top_1 = mem_heap_get_heap_top(heap_1);
|
||||
|
||||
buf_1 = mem_heap_alloc(heap_1, 7);
|
||||
|
||||
ut_memcpy(buf_1, "Pascal", 7);
|
||||
|
||||
for (i = 0; i < 500; i++) {
|
||||
buf_1 = mem_heap_alloc(heap_1, 6);
|
||||
ut_memcpy(buf_1, "Cobol", 6);
|
||||
}
|
||||
|
||||
top_2 = mem_heap_get_heap_top(heap_1);
|
||||
|
||||
for (i = 0; i < 500; i++) {
|
||||
buf_1 = mem_heap_alloc(heap_1, 6);
|
||||
ut_memcpy(buf_1, "Cobol", 6);
|
||||
}
|
||||
|
||||
mem_heap_free_heap_top(heap_1, top_2);
|
||||
|
||||
mem_heap_free_heap_top(heap_1, top_1);
|
||||
|
||||
ut_a(mem_all_freed() == FALSE);
|
||||
|
||||
for (i = 0; i < 500; i++) {
|
||||
buf_1 = mem_heap_alloc(heap_1, 6);
|
||||
ut_memcpy(buf_1, "Cobol", 6);
|
||||
|
||||
}
|
||||
|
||||
mem_heap_empty(heap_1);
|
||||
|
||||
for (i = 0; i < 500; i++) {
|
||||
buf_1 = mem_heap_alloc(heap_1, 6);
|
||||
ut_memcpy(buf_1, "Cobol", 6);
|
||||
|
||||
}
|
||||
|
||||
mem_heap_free(heap_1);
|
||||
|
||||
ut_a(mem_all_freed() == TRUE);
|
||||
|
||||
mem_print_info();
|
||||
|
||||
}
|
||||
#endif /* UNIV_DEBUG */
|
||||
|
||||
/****************************************************************
|
||||
Allocation speed test. */
|
||||
|
||||
void
|
||||
test2(void)
|
||||
/*=======*/
|
||||
{
|
||||
mem_heap_t* heap;
|
||||
ulint tm, oldtm;
|
||||
ulint i;
|
||||
byte* buf;
|
||||
byte block[512];
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST B1. Test of speed \n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 10000 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
heap = mem_heap_create(500);
|
||||
mem_heap_free(heap);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Time for %ld heap create-free pairs %ld millisecs.\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 10000 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
heap = mem_heap_fast_create(512, block);
|
||||
mem_heap_free(heap);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Time for %ld heap fast-create-free pairs %ld millisecs.\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
|
||||
heap = mem_heap_create(500);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 10000 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
buf = mem_heap_alloc(heap, 50);
|
||||
mem_heap_free_top(heap, 50);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Time for %ld heap alloc-free-top pairs %ld millisecs.\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
mem_heap_free(heap);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
sync_init();
|
||||
mem_init(2500000);
|
||||
|
||||
#ifdef UNIV_DEBUG
|
||||
|
||||
test1();
|
||||
|
||||
#endif
|
||||
|
||||
test2();
|
||||
|
||||
ut_ad(sync_all_freed());
|
||||
|
||||
ut_ad(mem_all_freed());
|
||||
|
||||
printf("TEST SUCCESSFULLY COMPLETED!\n");
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
|
||||
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tsmtr: ..\mtr.lib tsmtr.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\mtr.lib ..\..\dyn.lib ..\..\log.lib ..\..\mach.lib ..\..\buf.lib ..\..\fil.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsmtr.c $(LFL)
|
||||
|
@ -1,531 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for the file system and buffer manager
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 11/16/1995 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "os0thread.h"
|
||||
#include "os0file.h"
|
||||
#include "ut0ut.h"
|
||||
#include "sync0sync.h"
|
||||
#include "mem0mem.h"
|
||||
#include "fil0fil.h"
|
||||
#include "..\buf0buf.h"
|
||||
#include "..\buf0flu.h"
|
||||
#include "..\buf0lru.h"
|
||||
|
||||
os_file_t files[1000];
|
||||
|
||||
mutex_t ios_mutex;
|
||||
ulint ios;
|
||||
ulint n[5];
|
||||
|
||||
|
||||
/************************************************************************
|
||||
Io-handler thread function. */
|
||||
|
||||
ulint
|
||||
handler_thread(
|
||||
/*===========*/
|
||||
void* arg)
|
||||
{
|
||||
ulint segment;
|
||||
void* mess;
|
||||
ulint i;
|
||||
bool ret;
|
||||
|
||||
segment = *((ulint*)arg);
|
||||
|
||||
printf("Thread %lu starts\n", segment);
|
||||
|
||||
for (i = 0;; i++) {
|
||||
ret = fil_aio_wait(segment, &mess);
|
||||
ut_a(ret);
|
||||
|
||||
buf_page_io_complete((buf_block_t*)mess);
|
||||
|
||||
mutex_enter(&ios_mutex);
|
||||
ios++;
|
||||
mutex_exit(&ios_mutex);
|
||||
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Creates the test database files. */
|
||||
|
||||
void
|
||||
create_db(void)
|
||||
/*===========*/
|
||||
{
|
||||
ulint i;
|
||||
buf_block_t* block;
|
||||
byte* frame;
|
||||
ulint j;
|
||||
ulint tm, oldtm;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 1; i++) {
|
||||
for (j = 0; j < 4096; j++) {
|
||||
block = buf_page_create(i, j);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
rw_lock_x_lock(buf_page_get_lock(block));
|
||||
|
||||
if (j > 0) {
|
||||
fil_page_set_prev(frame, j - 1);
|
||||
} else {
|
||||
fil_page_set_prev(frame, 0);
|
||||
}
|
||||
|
||||
if (j < 4095) {
|
||||
fil_page_set_next(frame, j + 1);
|
||||
} else {
|
||||
fil_page_set_next(frame, 0);
|
||||
}
|
||||
|
||||
*((ulint*)(frame + 16)) = j;
|
||||
|
||||
buf_page_note_modification(block);
|
||||
|
||||
rw_lock_x_unlock(buf_page_get_lock(block));
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
/* buf_LRU_print(); */
|
||||
|
||||
/* Flush the pool of dirty pages by reading low-offset pages */
|
||||
for (i = 0; i < 1000; i++) {
|
||||
|
||||
block = buf_page_get(0, i, NULL);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
rw_lock_s_lock(buf_page_get_lock(block));
|
||||
|
||||
ut_a(*((ulint*)(frame + 16)) == i);
|
||||
|
||||
rw_lock_s_unlock(buf_page_get_lock(block));
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
|
||||
/* buf_LRU_print(); */
|
||||
|
||||
os_thread_sleep(1000000);
|
||||
|
||||
ut_a(buf_all_freed());
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Creates the files for the file system test and inserts them to
|
||||
the file system. */
|
||||
|
||||
void
|
||||
create_files(void)
|
||||
/*==============*/
|
||||
{
|
||||
bool ret;
|
||||
ulint i, k;
|
||||
char name[10];
|
||||
os_thread_t thr[5];
|
||||
os_thread_id_t id[5];
|
||||
|
||||
name[0] = 't';
|
||||
name[1] = 's';
|
||||
name[2] = 'f';
|
||||
name[3] = 'i';
|
||||
name[4] = 'l';
|
||||
name[5] = 'e';
|
||||
name[8] = '\0';
|
||||
|
||||
for (k = 0; k < 1; k++) {
|
||||
for (i = 0; i < 1; i++) {
|
||||
|
||||
name[6] = (char)(k + (ulint)'a');
|
||||
name[7] = (char)(i + (ulint)'a');
|
||||
|
||||
files[i] = os_file_create("j:\\tsfile4", OS_FILE_CREATE,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
if (ret == FALSE) {
|
||||
ut_a(os_file_get_last_error() ==
|
||||
OS_FILE_ALREADY_EXISTS);
|
||||
|
||||
files[i] = os_file_create(
|
||||
"j:\\tsfile4", OS_FILE_OPEN,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
ut_a(ret);
|
||||
}
|
||||
|
||||
ret = os_file_set_size(files[i], 4096 * 8192, 0);
|
||||
ut_a(ret);
|
||||
|
||||
ret = os_file_close(files[i]);
|
||||
ut_a(ret);
|
||||
|
||||
if (i == 0) {
|
||||
fil_space_create("noname", k, OS_FILE_TABLESPACE);
|
||||
}
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
fil_node_create("j:\\tsfile4", 4096, k);
|
||||
}
|
||||
}
|
||||
|
||||
ios = 0;
|
||||
|
||||
mutex_create(&ios_mutex);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
n[i] = i;
|
||||
|
||||
thr[i] = os_thread_create(handler_thread, n + i, id + i);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Reads the test database files. */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j, k;
|
||||
buf_block_t* block;
|
||||
byte* frame;
|
||||
ulint tm, oldtm;
|
||||
|
||||
buf_flush_batch(BUF_FLUSH_LIST, 1000);
|
||||
|
||||
os_thread_sleep(1000000);
|
||||
|
||||
buf_all_freed();
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (k = 0; k < 1; k++) {
|
||||
for (i = 0; i < 1; i++) {
|
||||
for (j = 0; j < 409; j++) {
|
||||
block = buf_page_get(i, j, NULL);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
rw_lock_s_lock(buf_page_get_lock(block));
|
||||
|
||||
ut_a(*((ulint*)(frame + 16)) == j);
|
||||
|
||||
rw_lock_s_unlock(buf_page_get_lock(block));
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Reads the test database files. */
|
||||
|
||||
void
|
||||
test2(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j, k, rnd;
|
||||
buf_block_t* block;
|
||||
byte* frame;
|
||||
ulint tm, oldtm;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rnd = 123;
|
||||
|
||||
for (k = 0; k < 100; k++) {
|
||||
rnd += 23651;
|
||||
rnd = rnd % 4096;
|
||||
|
||||
i = rnd / 4096;
|
||||
j = rnd % 2048;
|
||||
|
||||
block = buf_page_get(i, j, NULL);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
rw_lock_s_lock(buf_page_get_lock(block));
|
||||
|
||||
ut_a(*((ulint*)(frame + 16)) == j);
|
||||
|
||||
rw_lock_s_unlock(buf_page_get_lock(block));
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for random read %lu milliseconds\n",
|
||||
tm - oldtm);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Reads the test database files. */
|
||||
|
||||
void
|
||||
test4(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j, k, rnd;
|
||||
buf_block_t* block;
|
||||
byte* frame;
|
||||
ulint tm, oldtm;
|
||||
|
||||
/* Flush the pool of high-offset pages */
|
||||
for (i = 0; i < 1000; i++) {
|
||||
|
||||
block = buf_page_get(0, i, NULL);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
rw_lock_s_lock(buf_page_get_lock(block));
|
||||
|
||||
ut_a(*((ulint*)(frame + 16)) == i);
|
||||
|
||||
rw_lock_s_unlock(buf_page_get_lock(block));
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
|
||||
printf("Test starts\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rnd = 123;
|
||||
|
||||
for (k = 0; k < 400; k++) {
|
||||
|
||||
rnd += 4357;
|
||||
|
||||
i = 0;
|
||||
j = 1001 + rnd % 3000;
|
||||
|
||||
block = buf_page_get(i, j, NULL);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
rw_lock_s_lock(buf_page_get_lock(block));
|
||||
|
||||
ut_a(*((ulint*)(frame + 16)) == j);
|
||||
|
||||
rw_lock_s_unlock(buf_page_get_lock(block));
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf(
|
||||
"Wall clock time for %lu random no read-ahead %lu milliseconds\n",
|
||||
k, tm - oldtm);
|
||||
|
||||
/* Flush the pool of high-offset pages */
|
||||
for (i = 0; i < 1000; i++) {
|
||||
|
||||
block = buf_page_get(0, i, NULL);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
rw_lock_s_lock(buf_page_get_lock(block));
|
||||
|
||||
ut_a(*((ulint*)(frame + 16)) == i);
|
||||
|
||||
rw_lock_s_unlock(buf_page_get_lock(block));
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
|
||||
printf("Test starts\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rnd = 123;
|
||||
|
||||
for (k = 0; k < 400; k++) {
|
||||
|
||||
rnd += 4357;
|
||||
|
||||
i = 0;
|
||||
j = 1001 + rnd % 400;
|
||||
|
||||
block = buf_page_get(i, j, NULL);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
rw_lock_s_lock(buf_page_get_lock(block));
|
||||
|
||||
ut_a(*((ulint*)(frame + 16)) == j);
|
||||
|
||||
rw_lock_s_unlock(buf_page_get_lock(block));
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf(
|
||||
"Wall clock time for %lu random read-ahead %lu milliseconds\n",
|
||||
k, tm - oldtm);
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Tests speed of CPU algorithms. */
|
||||
|
||||
void
|
||||
test3(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j;
|
||||
buf_block_t* block;
|
||||
ulint tm, oldtm;
|
||||
|
||||
for (i = 0; i < 400; i++) {
|
||||
|
||||
block = buf_page_get(0, i, NULL);
|
||||
|
||||
buf_page_release(block);
|
||||
}
|
||||
|
||||
os_thread_sleep(2000000);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 500; j++) {
|
||||
for (i = 0; i < 200; i++) {
|
||||
|
||||
block = buf_page_get(0, i, NULL);
|
||||
|
||||
/*
|
||||
rw_lock_s_lock(buf_page_get_lock(block));
|
||||
|
||||
rw_lock_s_unlock(buf_page_get_lock(block));
|
||||
*/
|
||||
|
||||
buf_page_release(block);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for %lu page get-release %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 500; j++) {
|
||||
for (i = 0; i < 200; i++) {
|
||||
|
||||
buf_block_get(block);
|
||||
/*
|
||||
rw_lock_s_lock(buf_page_get_lock(block));
|
||||
|
||||
rw_lock_s_unlock(buf_page_get_lock(block));
|
||||
*/
|
||||
buf_page_release(block);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for %lu block get-release %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 100000; i++) {
|
||||
block = buf_block_alloc();
|
||||
buf_block_free(block);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for %lu block alloc-free %lu milliseconds\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
ha_print_info(buf_pool->page_hash);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Frees the spaces in the file system. */
|
||||
|
||||
void
|
||||
free_system(void)
|
||||
/*=============*/
|
||||
{
|
||||
ulint i;
|
||||
|
||||
for (i = 0; i < 1; i++) {
|
||||
fil_space_free(i);
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
ulint n;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
os_aio_init(160, 5);
|
||||
sync_init();
|
||||
mem_init();
|
||||
fil_init(26); /* Allow 25 open files at a time */
|
||||
buf_pool_init(1000, 1000);
|
||||
|
||||
buf_validate();
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
create_files();
|
||||
|
||||
create_db();
|
||||
|
||||
buf_validate();
|
||||
|
||||
test1();
|
||||
|
||||
test3();
|
||||
|
||||
test4();
|
||||
|
||||
test2();
|
||||
|
||||
buf_validate();
|
||||
|
||||
n = buf_flush_batch(BUF_FLUSH_LIST, 500);
|
||||
|
||||
os_thread_sleep(1000000);
|
||||
|
||||
buf_all_freed();
|
||||
|
||||
free_system();
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,158 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for the mini-transaction utilities
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 11/26/1995 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "sync0sync.h"
|
||||
#include "sync0rw.h"
|
||||
#include "mem0mem.h"
|
||||
#include "log0log.h"
|
||||
#include "..\mtr0mtr.h"
|
||||
#include "..\mtr0log.h"
|
||||
|
||||
rw_lock_t rwl[MTR_BUF_MEMO_SIZE];
|
||||
|
||||
/*********************************************************************
|
||||
Test for mtr buffer */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i;
|
||||
mtr_t mtr;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("MTR-TEST 1. Test of mtr buffer\n");
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
for (i = 0; i < MTR_BUF_MEMO_SIZE; i++) {
|
||||
rw_lock_create(rwl + i);
|
||||
}
|
||||
|
||||
for (i = 0; i < MTR_BUF_MEMO_SIZE; i++) {
|
||||
rw_lock_s_lock(rwl + i);
|
||||
mtr_memo_push(&mtr, rwl + i, MTR_MEMO_S_LOCK);
|
||||
}
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
rw_lock_list_print_info();
|
||||
ut_ad(rw_lock_n_locked() == 0);
|
||||
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Speed test function. */
|
||||
void
|
||||
speed_mtr(void)
|
||||
/*===========*/
|
||||
{
|
||||
mtr_t mtr;
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
mtr_s_lock(rwl, &mtr);
|
||||
mtr_s_lock(rwl + 1, &mtr);
|
||||
mtr_s_lock(rwl + 2, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Speed test function without mtr. */
|
||||
void
|
||||
speed_no_mtr(void)
|
||||
/*===========*/
|
||||
{
|
||||
rw_lock_s_lock(rwl);
|
||||
rw_lock_s_lock(rwl + 1);
|
||||
rw_lock_s_lock(rwl + 2);
|
||||
rw_lock_s_unlock(rwl + 2);
|
||||
rw_lock_s_unlock(rwl + 1);
|
||||
rw_lock_s_unlock(rwl);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Speed test function. */
|
||||
|
||||
void
|
||||
test2(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
ulint i, j;
|
||||
mtr_t mtr;
|
||||
byte buf[50];
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
speed_mtr();
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for %lu mtrs %lu milliseconds\n",
|
||||
i, tm - oldtm);
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
speed_no_mtr();
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for %lu no-mtrs %lu milliseconds\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
mtr_start(&mtr);
|
||||
for (j = 0; j < 250; j++) {
|
||||
mlog_catenate_ulint(&mtr, 5, MLOG_1BYTE);
|
||||
mlog_catenate_ulint(&mtr, i, MLOG_4BYTES);
|
||||
mlog_catenate_ulint(&mtr, i + 1, MLOG_4BYTES);
|
||||
mlog_catenate_string(&mtr, buf, 50);
|
||||
}
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for %lu log writes %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
mtr_start(&mtr);
|
||||
for (j = 0; j < 250; j++) {
|
||||
mlog_catenate_ulint(&mtr, 5, MLOG_1BYTE);
|
||||
mlog_catenate_ulint(&mtr, i, MLOG_4BYTES);
|
||||
mlog_catenate_ulint(&mtr, i + 1, MLOG_4BYTES);
|
||||
mlog_catenate_string(&mtr, buf, 50);
|
||||
}
|
||||
|
||||
mtr_print(&mtr);
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
sync_init();
|
||||
mem_init();
|
||||
log_init();
|
||||
|
||||
test1();
|
||||
test2();
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
|
||||
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
doall: tsos tsosaux
|
||||
|
||||
|
||||
tsos: ..\os.lib tsos.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\os.lib tsos.c $(LFL)
|
||||
|
||||
tsosaux: tsosaux.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\..\ut.lib ..\os.lib tsosaux.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,793 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for the operating system interface
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 9/27/1995 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
#include "../os0thread.h"
|
||||
#include "../os0shm.h"
|
||||
#include "../os0proc.h"
|
||||
#include "../os0sync.h"
|
||||
#include "../os0file.h"
|
||||
#include "ut0ut.h"
|
||||
#include "ut0mem.h"
|
||||
#include "sync0sync.h"
|
||||
#include "mem0mem.h"
|
||||
|
||||
#define _WIN32_WINNT 0x0400
|
||||
#include "n:\program files\devstudio\vc\include\windows.h"
|
||||
#include "n:\program files\devstudio\vc\include\winbase.h"
|
||||
|
||||
ulint last_thr = 1;
|
||||
|
||||
byte global_buf[4000000];
|
||||
|
||||
ulint* cache_buf;
|
||||
|
||||
os_file_t file;
|
||||
os_file_t file2;
|
||||
|
||||
os_event_t gl_ready;
|
||||
|
||||
mutex_t ios_mutex;
|
||||
ulint ios;
|
||||
ulint rnd = 9837497;
|
||||
|
||||
/********************************************************************
|
||||
Start function for threads in test1. */
|
||||
|
||||
ulint
|
||||
thread(void* arg)
|
||||
/*==============*/
|
||||
{
|
||||
ulint i;
|
||||
void* arg2;
|
||||
ulint count = 0;
|
||||
ulint n;
|
||||
ulint rnd_loc;
|
||||
byte local_buf[2000];
|
||||
|
||||
arg2 = arg;
|
||||
|
||||
n = *((ulint*)arg);
|
||||
|
||||
/* printf("Thread %lu started!\n", n); */
|
||||
|
||||
for (i = 0; i < 8000; i++) {
|
||||
|
||||
rnd_loc = rnd;
|
||||
rnd += 763482469;
|
||||
|
||||
ut_memcpy(global_buf + (rnd_loc % 1500000) + 8200, local_buf,
|
||||
2000);
|
||||
if (last_thr != n) {
|
||||
count++;
|
||||
last_thr = n;
|
||||
}
|
||||
|
||||
if (i % 32 == 0) {
|
||||
os_thread_yield();
|
||||
}
|
||||
}
|
||||
|
||||
printf("Thread %lu exits: %lu thread switches noticed\n", n, count);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Test of the speed of wait for multiple events. */
|
||||
|
||||
void
|
||||
testa1(void)
|
||||
/*========*/
|
||||
{
|
||||
ulint i;
|
||||
os_event_t arr[64];
|
||||
ulint tm, oldtm;
|
||||
|
||||
printf("-------------------------------------------------\n");
|
||||
printf("TEST A1. Speed of waits\n");
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
arr[i] = os_event_create(NULL);
|
||||
ut_a(arr[i]);
|
||||
}
|
||||
|
||||
os_event_set(arr[1]);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 10000; i++) {
|
||||
os_event_wait_multiple(4, arr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for %lu multiple waits %lu millisecs\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 10000; i++) {
|
||||
os_event_wait(arr[1]);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for %lu single waits %lu millisecs\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
os_event_free(arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Test for threads. */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
os_thread_t thr[64];
|
||||
os_thread_id_t id[64];
|
||||
ulint n[64];
|
||||
ulint tm, oldtm;
|
||||
ulint i, j;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("OS-TEST 1. Test of thread switching through yield\n");
|
||||
|
||||
printf("Main thread %lu starts!\n", os_thread_get_curr_id());
|
||||
|
||||
for (j = 0; j < 2; j++) {
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
n[i] = i;
|
||||
|
||||
thr[i] = os_thread_create(thread, n + i, id + i);
|
||||
/* printf("Thread %lu created, id %lu \n", i, id[i]); */
|
||||
}
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
os_thread_wait(thr[i]);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 64; i++) {
|
||||
|
||||
thr[5] = os_thread_create(thread, n + 5, id + 5);
|
||||
|
||||
/* printf("Thread created, id %lu \n", id[5]); */
|
||||
|
||||
os_thread_wait(thr[5]);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for single thread test %lu milliseconds\n",
|
||||
tm - oldtm);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Test for shared memory and process switching through yield. */
|
||||
|
||||
void
|
||||
test2(void)
|
||||
/*=======*/
|
||||
{
|
||||
os_shm_t shm;
|
||||
ulint tm, oldtm;
|
||||
ulint* pr_no;
|
||||
ulint count;
|
||||
ulint i;
|
||||
bool ret;
|
||||
os_process_t proc;
|
||||
os_process_id_t proc_id;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("OS-TEST 2. Test of process switching through yield\n");
|
||||
|
||||
shm = os_shm_create(1000, "TSOS_SHM");
|
||||
|
||||
pr_no = os_shm_map(shm);
|
||||
|
||||
*pr_no = 1;
|
||||
count = 0;
|
||||
|
||||
ret = os_process_create("tsosaux.exe", NULL, &proc, &proc_id);
|
||||
|
||||
printf("Last error: %lu\n", os_thread_get_last_error());
|
||||
|
||||
ut_a(ret);
|
||||
|
||||
printf("Process 1 starts test!\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 500000; i++) {
|
||||
if (*pr_no != 1) {
|
||||
count++;
|
||||
*pr_no = 1;
|
||||
}
|
||||
|
||||
os_thread_yield();
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Process 1 finishes test: %lu process switches noticed\n",
|
||||
count);
|
||||
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
os_shm_unmap(shm);
|
||||
|
||||
os_shm_free(shm);
|
||||
}
|
||||
|
||||
#ifdef notdefined
|
||||
|
||||
/*********************************************************************
|
||||
Test for asynchronous file io. */
|
||||
|
||||
void
|
||||
test3(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i;
|
||||
ulint j;
|
||||
void* mess;
|
||||
bool ret;
|
||||
void* buf;
|
||||
ulint rnd;
|
||||
ulint addr[64];
|
||||
ulint serv[64];
|
||||
ulint tm, oldtm;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("OS-TEST 3. Test of asynchronous file io\n");
|
||||
|
||||
/* Align the buffer for file io */
|
||||
|
||||
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
|
||||
|
||||
rnd = ut_time();
|
||||
|
||||
rnd = rnd * 3416133;
|
||||
|
||||
printf("rnd seed %lu\n", rnd % 4900);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
|
||||
ret = os_aio_read(file, buf, 8192 * (rnd % 4900), 0,
|
||||
8192, (void*)i);
|
||||
ut_a(ret);
|
||||
rnd += 1;
|
||||
ret = os_aio_wait(0, &mess);
|
||||
ut_a(ret);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for synchr. io %lu milliseconds\n",
|
||||
tm - oldtm);
|
||||
|
||||
rnd = rnd * 3416133;
|
||||
|
||||
printf("rnd seed %lu\n", rnd % 5000);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 5; j++) {
|
||||
|
||||
rnd = rnd + 3416133;
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
ret = os_aio_read(file, buf, 8192 * (rnd % 5000), 0, 8192,
|
||||
(void*)i);
|
||||
addr[i] = rnd % 5000;
|
||||
ut_a(ret);
|
||||
rnd += 1;
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
ret = os_aio_read(file, buf, 8192 * (rnd % 5000), 0, 8192,
|
||||
(void*)i);
|
||||
addr[i] = rnd % 5000;
|
||||
ut_a(ret);
|
||||
rnd += 1;
|
||||
}
|
||||
|
||||
rnd = rnd + 3416133;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
ret = os_aio_wait(0, &mess);
|
||||
ut_a(ret);
|
||||
ut_a((ulint)mess < 64);
|
||||
serv[(ulint)mess] = i;
|
||||
}
|
||||
}
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for aio %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
rnd = rnd * 3416133;
|
||||
|
||||
printf("rnd seed %lu\n", rnd % 4900);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 5; j++) {
|
||||
|
||||
rnd = rnd + 3416133;
|
||||
|
||||
for (i = 0; i < 1; i++) {
|
||||
ret = os_aio_read(file, buf, 8192 * (rnd % 4900), 0,
|
||||
64 * 8192, (void*)i);
|
||||
ut_a(ret);
|
||||
rnd += 4;
|
||||
ret = os_aio_wait(0, &mess);
|
||||
ut_a(ret);
|
||||
ut_a((ulint)mess < 64);
|
||||
}
|
||||
}
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for synchr. io %lu milliseconds\n",
|
||||
tm - oldtm);
|
||||
|
||||
|
||||
/*
|
||||
for (i = 0; i < 63; i++) {
|
||||
printf("read %lu addr %lu served as %lu\n",
|
||||
i, addr[i], serv[i]);
|
||||
}
|
||||
*/
|
||||
|
||||
ut_a(ret);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Io-handler thread function. */
|
||||
|
||||
ulint
|
||||
handler_thread(
|
||||
/*===========*/
|
||||
void* arg)
|
||||
{
|
||||
ulint segment;
|
||||
void* mess;
|
||||
ulint i;
|
||||
bool ret;
|
||||
|
||||
segment = *((ulint*)arg);
|
||||
|
||||
printf("Thread %lu starts\n", segment);
|
||||
|
||||
for (i = 0;; i++) {
|
||||
ret = os_aio_wait(segment, &mess);
|
||||
|
||||
mutex_enter(&ios_mutex);
|
||||
ios++;
|
||||
mutex_exit(&ios_mutex);
|
||||
|
||||
ut_a(ret);
|
||||
/* printf("Message for thread %lu %lu\n", segment,
|
||||
(ulint)mess); */
|
||||
if ((ulint)mess == 3333) {
|
||||
os_event_set(gl_ready);
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Test of io-handler threads */
|
||||
|
||||
void
|
||||
test4(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i;
|
||||
ulint j;
|
||||
bool ret;
|
||||
void* buf;
|
||||
ulint rnd;
|
||||
ulint tm, oldtm;
|
||||
os_thread_t thr[5];
|
||||
os_thread_id_t id[5];
|
||||
ulint n[5];
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("OS-TEST 4. Test of asynchronous file io\n");
|
||||
|
||||
/* Align the buffer for file io */
|
||||
|
||||
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
|
||||
|
||||
gl_ready = os_event_create(NULL);
|
||||
ios = 0;
|
||||
|
||||
sync_init();
|
||||
mem_init();
|
||||
|
||||
mutex_create(&ios_mutex);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
n[i] = i;
|
||||
|
||||
thr[i] = os_thread_create(handler_thread, n + i, id + i);
|
||||
}
|
||||
|
||||
rnd = 0;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 128; j++) {
|
||||
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
ret = os_aio_read(file, (byte*)buf + 8192 * (rnd % 100),
|
||||
8192 * (rnd % 4096), 0,
|
||||
8192, (void*)i);
|
||||
ut_a(ret);
|
||||
rnd += 1;
|
||||
}
|
||||
|
||||
/*
|
||||
rnd += 67475941;
|
||||
|
||||
for (i = 0; i < 1; i++) {
|
||||
ret = os_aio_read(file2, buf, 8192 * (rnd % 5000), 0,
|
||||
8192, (void*)i);
|
||||
ut_a(ret);
|
||||
rnd += 1;
|
||||
}
|
||||
*/
|
||||
}
|
||||
ret = os_aio_read(file, buf, 8192 * (rnd % 4096), 0, 8192,
|
||||
(void*)3333);
|
||||
ut_a(ret);
|
||||
|
||||
ut_a(!os_aio_all_slots_free());
|
||||
/*
|
||||
printf("Starting flush!\n");
|
||||
ret = os_file_flush(file);
|
||||
ut_a(ret);
|
||||
printf("Ending flush!\n");
|
||||
*/
|
||||
tm = ut_clock();
|
||||
|
||||
printf("All ios queued! N ios: %lu\n", ios);
|
||||
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
os_event_wait(gl_ready);
|
||||
|
||||
tm = ut_clock();
|
||||
printf("N ios: %lu\n", ios);
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
os_thread_sleep(2000000);
|
||||
|
||||
printf("N ios: %lu\n", ios);
|
||||
|
||||
ut_a(os_aio_all_slots_free());
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Initializes the asyncronous io system for tests. */
|
||||
|
||||
void
|
||||
init_aio(void)
|
||||
/*==========*/
|
||||
{
|
||||
bool ret;
|
||||
ulint i;
|
||||
void* buf;
|
||||
void* mess;
|
||||
|
||||
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
|
||||
|
||||
os_aio_init(160, 5);
|
||||
file = os_file_create("j:\\tsfile2", OS_FILE_CREATE, OS_FILE_TABLESPACE,
|
||||
&ret);
|
||||
|
||||
if (ret == FALSE) {
|
||||
ut_a(os_file_get_last_error() == OS_FILE_ALREADY_EXISTS);
|
||||
|
||||
file = os_file_create("j:\\tsfile2", OS_FILE_OPEN,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
ut_a(ret);
|
||||
} else {
|
||||
|
||||
for (i = 0; i < 4100; i++) {
|
||||
ret = os_aio_write(file, buf, 8192 * i, 0, 8192, NULL);
|
||||
ut_a(ret);
|
||||
|
||||
ret = os_aio_wait(0, &mess);
|
||||
|
||||
ut_a(ret);
|
||||
ut_a(mess == NULL);
|
||||
}
|
||||
}
|
||||
|
||||
file2 = os_file_create("F:\\tmp\\tsfile", OS_FILE_CREATE,
|
||||
OS_FILE_TABLESPACE,
|
||||
&ret);
|
||||
|
||||
if (ret == FALSE) {
|
||||
ut_a(os_file_get_last_error() == OS_FILE_ALREADY_EXISTS);
|
||||
|
||||
file2 = os_file_create("F:\\tmp\\tsfile", OS_FILE_OPEN,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
ut_a(ret);
|
||||
} else {
|
||||
|
||||
for (i = 0; i < 5000; i++) {
|
||||
ret = os_aio_write(file2, buf, 8192 * i, 0, 8192, NULL);
|
||||
ut_a(ret);
|
||||
|
||||
ret = os_aio_wait(0, &mess);
|
||||
|
||||
ut_a(ret);
|
||||
ut_a(mess == NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Test of synchronous io */
|
||||
|
||||
void
|
||||
test5(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j, k;
|
||||
bool ret;
|
||||
void* buf;
|
||||
ulint rnd = 0;
|
||||
ulint tm = 0;
|
||||
ulint oldtm = 0;
|
||||
os_file_t files[1000];
|
||||
char name[5];
|
||||
ulint err;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("OS-TEST 5. Test of creating and opening of many files\n");
|
||||
|
||||
/* Align the buffer for file io */
|
||||
|
||||
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
|
||||
|
||||
name[2] = '.';
|
||||
name[3] = 'd';
|
||||
name[4] = '\0';
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 20; j++) {
|
||||
for (i = 0; i < 20; i++) {
|
||||
name[0] = (char)(i + (ulint)'A');
|
||||
name[1] = (char)(j + (ulint)'A');
|
||||
files[j * 20 + i] = os_file_create(name, OS_FILE_CREATE,
|
||||
OS_FILE_NORMAL, &ret);
|
||||
if (!ret) {
|
||||
err = os_file_get_last_error();
|
||||
}
|
||||
ut_a(ret);
|
||||
}
|
||||
}
|
||||
|
||||
for (k = 0; k < i * j; k++) {
|
||||
ret = os_file_close(files[k]);
|
||||
ut_a(ret);
|
||||
}
|
||||
|
||||
for (j = 0; j < 20; j++) {
|
||||
for (i = 0; i < 20; i++) {
|
||||
name[0] = (char)(i + (ulint)'A');
|
||||
name[1] = (char)(j + (ulint)'A');
|
||||
ret = os_file_delete(name);
|
||||
ut_a(ret);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Test of synchronous io */
|
||||
|
||||
void
|
||||
test6(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j;
|
||||
bool ret;
|
||||
void* buf;
|
||||
ulint rnd = 0;
|
||||
ulint tm = 0;
|
||||
ulint oldtm = 0;
|
||||
os_file_t s_file;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("OS-TEST 6. Test of synchronous io\n");
|
||||
|
||||
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
|
||||
|
||||
ret = os_file_close(file);
|
||||
ut_a(ret);
|
||||
|
||||
ret = os_file_close(file2);
|
||||
ut_a(ret);
|
||||
|
||||
s_file = os_file_create("tsfile", OS_FILE_OPEN,
|
||||
OS_FILE_NORMAL, &ret);
|
||||
if (!ret) {
|
||||
printf("Error no %lu\n", os_file_get_last_error());
|
||||
}
|
||||
|
||||
ut_a(ret);
|
||||
|
||||
rnd = ut_time() * 6346353;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 100; j++) {
|
||||
|
||||
rnd += 8072791;
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
ret = os_file_read(s_file, buf, 8192 * (rnd % 5000), 0,
|
||||
8192);
|
||||
ut_a(ret);
|
||||
rnd += 1;
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Test of file size operations. */
|
||||
|
||||
void
|
||||
test7(void)
|
||||
/*=======*/
|
||||
{
|
||||
bool ret;
|
||||
os_file_t f;
|
||||
ulint len;
|
||||
ulint high;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("OS-TEST 7. Test of setting and getting file size\n");
|
||||
|
||||
|
||||
f = os_file_create("sizefile", OS_FILE_CREATE, OS_FILE_TABLESPACE,
|
||||
&ret);
|
||||
ut_a(ret);
|
||||
|
||||
ret = os_file_get_size(f, &len, &high);
|
||||
ut_a(ret);
|
||||
|
||||
ut_a(len == 0);
|
||||
ut_a(high == 0);
|
||||
|
||||
ret = os_file_set_size(f, 5000000, 0);
|
||||
ut_a(ret);
|
||||
|
||||
ret = os_file_get_size(f, &len, &high);
|
||||
ut_a(ret);
|
||||
|
||||
ut_a(len == 5000000);
|
||||
ut_a(high == 0);
|
||||
|
||||
ret = os_file_set_size(f, 4000000, 0);
|
||||
ut_a(ret);
|
||||
|
||||
ret = os_file_get_size(f, &len, &high);
|
||||
ut_a(ret);
|
||||
|
||||
ut_a(len == 4000000);
|
||||
ut_a(high == 0);
|
||||
|
||||
ret = os_file_close(f);
|
||||
ut_a(ret);
|
||||
|
||||
ret = os_file_delete("sizefile");
|
||||
ut_a(ret);
|
||||
}
|
||||
#endif
|
||||
|
||||
/************************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
ulint i;
|
||||
CRITICAL_SECTION cs;
|
||||
ulint sum;
|
||||
ulint rnd;
|
||||
|
||||
cache_buf = VirtualAlloc(NULL, 4 * 1024, MEM_COMMIT,
|
||||
PAGE_READWRITE /* | PAGE_NOCACHE */);
|
||||
oldtm = ut_clock();
|
||||
|
||||
sum = 0;
|
||||
rnd = 0;
|
||||
|
||||
for (i = 0; i < 1000000; i++) {
|
||||
|
||||
sum += cache_buf[rnd * (16)];
|
||||
|
||||
rnd += 1;
|
||||
|
||||
if (rnd > 7) {
|
||||
rnd = 0;
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for cache test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
InterlockedExchange(&i, 5);
|
||||
|
||||
InitializeCriticalSection(&cs);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 10000000; i++) {
|
||||
|
||||
TryEnterCriticalSection(&cs);
|
||||
|
||||
LeaveCriticalSection(&cs);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
testa1();
|
||||
|
||||
test1();
|
||||
|
||||
/* test2(); */
|
||||
|
||||
/* init_aio(); */
|
||||
/*
|
||||
test3();
|
||||
*/
|
||||
/* test4();
|
||||
|
||||
test5();
|
||||
|
||||
test6();
|
||||
|
||||
test7(); */
|
||||
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
||||
|
@ -1,83 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for the operating system interface
|
||||
Auxiliary executable run alongside tsos.exe to test
|
||||
process switching speed
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 9/27/1995 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
|
||||
#include "../os0thread.h"
|
||||
#include "../os0shm.h"
|
||||
#include "../os0proc.h"
|
||||
#include "ut0ut.h"
|
||||
|
||||
/*********************************************************************
|
||||
Test for shared memory and process switching through yield. */
|
||||
|
||||
void
|
||||
test2(void)
|
||||
/*=======*/
|
||||
{
|
||||
os_shm_t shm;
|
||||
ulint tm, oldtm;
|
||||
ulint* pr_no;
|
||||
ulint count;
|
||||
ulint i;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("OS-TEST 2. Test of process switching through yield\n");
|
||||
|
||||
|
||||
shm = os_shm_create(1000, "TSOS_SHM");
|
||||
|
||||
pr_no = os_shm_map(shm);
|
||||
|
||||
count = 0;
|
||||
|
||||
printf("Process 2 starts test!\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 100000; i++) {
|
||||
if (*pr_no != 2) {
|
||||
count++;
|
||||
*pr_no = 2;
|
||||
}
|
||||
os_thread_yield();
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Process 2 finishes test: %lu process switches noticed\n",
|
||||
count);
|
||||
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
|
||||
|
||||
os_shm_unmap(shm);
|
||||
|
||||
os_shm_free(shm);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
test2();
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
|
||||
os_process_exit(0);
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
|
||||
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tspage: ..\page.lib tspage.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\page.lib ..\..\btr.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tspage.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,705 +0,0 @@
|
||||
/************************************************************************
|
||||
The test for the index page
|
||||
|
||||
(c) 1994-1996 Innobase Oy
|
||||
|
||||
Created 1/31/1994 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "sync0sync.h"
|
||||
#include "ut0mem.h"
|
||||
#include "mem0mem.h"
|
||||
#include "data0data.h"
|
||||
#include "data0type.h"
|
||||
#include "dict0dict.h"
|
||||
#include "buf0buf.h"
|
||||
#include "os0file.h"
|
||||
#include "fil0fil.h"
|
||||
#include "rem0rec.h"
|
||||
#include "rem0cmp.h"
|
||||
#include "mtr0mtr.h"
|
||||
#include "log0log.h"
|
||||
#include "..\page0page.h"
|
||||
#include "..\page0cur.h"
|
||||
|
||||
os_file_t files[1000];
|
||||
|
||||
mutex_t ios_mutex;
|
||||
ulint ios;
|
||||
ulint n[10];
|
||||
|
||||
mutex_t incs_mutex;
|
||||
ulint incs;
|
||||
|
||||
byte bigbuf[1000000];
|
||||
|
||||
#define N_SPACES 1
|
||||
#define N_FILES 2
|
||||
#define FILE_SIZE 1000 /* must be > 512 */
|
||||
#define POOL_SIZE 1000
|
||||
#define COUNTER_OFFSET 1500
|
||||
|
||||
#define LOOP_SIZE 150
|
||||
#define N_THREADS 5
|
||||
|
||||
|
||||
ulint zero = 0;
|
||||
|
||||
buf_block_t* bl_arr[POOL_SIZE];
|
||||
|
||||
/************************************************************************
|
||||
Io-handler thread function. */
|
||||
|
||||
ulint
|
||||
handler_thread(
|
||||
/*===========*/
|
||||
void* arg)
|
||||
{
|
||||
ulint segment;
|
||||
void* mess;
|
||||
ulint i;
|
||||
bool ret;
|
||||
|
||||
segment = *((ulint*)arg);
|
||||
|
||||
printf("Io handler thread %lu starts\n", segment);
|
||||
|
||||
for (i = 0;; i++) {
|
||||
ret = fil_aio_wait(segment, &mess);
|
||||
ut_a(ret);
|
||||
|
||||
buf_page_io_complete((buf_block_t*)mess);
|
||||
|
||||
mutex_enter(&ios_mutex);
|
||||
ios++;
|
||||
mutex_exit(&ios_mutex);
|
||||
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
Creates the files for the file system test and inserts them to
|
||||
the file system. */
|
||||
|
||||
void
|
||||
create_files(void)
|
||||
/*==============*/
|
||||
{
|
||||
bool ret;
|
||||
ulint i, k;
|
||||
char name[20];
|
||||
os_thread_t thr[5];
|
||||
os_thread_id_t id[5];
|
||||
|
||||
printf("--------------------------------------------------------\n");
|
||||
printf("Create or open database files\n");
|
||||
|
||||
strcpy(name, "j:\\tsfile00");
|
||||
|
||||
for (k = 0; k < N_SPACES; k++) {
|
||||
for (i = 0; i < N_FILES; i++) {
|
||||
|
||||
name[9] = (char)((ulint)'0' + k);
|
||||
name[10] = (char)((ulint)'0' + i);
|
||||
|
||||
files[i] = os_file_create(name, OS_FILE_CREATE,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
if (ret == FALSE) {
|
||||
ut_a(os_file_get_last_error() ==
|
||||
OS_FILE_ALREADY_EXISTS);
|
||||
|
||||
files[i] = os_file_create(
|
||||
name, OS_FILE_OPEN,
|
||||
OS_FILE_TABLESPACE, &ret);
|
||||
|
||||
ut_a(ret);
|
||||
}
|
||||
|
||||
ret = os_file_close(files[i]);
|
||||
ut_a(ret);
|
||||
|
||||
if (i == 0) {
|
||||
fil_space_create(name, k, OS_FILE_TABLESPACE);
|
||||
}
|
||||
|
||||
ut_a(fil_validate());
|
||||
|
||||
fil_node_create(name, FILE_SIZE, k);
|
||||
}
|
||||
}
|
||||
|
||||
ios = 0;
|
||||
|
||||
mutex_create(&ios_mutex);
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
n[i] = i;
|
||||
|
||||
thr[i] = os_thread_create(handler_thread, n + i, id + i);
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Test for index page. */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
page_t* page;
|
||||
dtuple_t* tuple;
|
||||
mem_heap_t* heap;
|
||||
ulint i;
|
||||
ulint rnd = 0;
|
||||
rec_t* rec;
|
||||
page_cur_t cursor;
|
||||
dict_index_t* index;
|
||||
dict_table_t* table;
|
||||
buf_block_t* block;
|
||||
buf_frame_t* frame;
|
||||
mtr_t mtr;
|
||||
|
||||
printf("-------------------------------------------------\n");
|
||||
printf("TEST 1. Basic test\n");
|
||||
|
||||
heap = mem_heap_create(0);
|
||||
|
||||
table = dict_table_create("TS_TABLE1", 3);
|
||||
|
||||
dict_table_add_col(table, "COL1", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
|
||||
dict_table_add_col(table, "COL2", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
|
||||
dict_table_add_col(table, "COL3", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
|
||||
|
||||
ut_a(0 == dict_table_publish(table));
|
||||
|
||||
index = dict_index_create("TS_TABLE1", "IND1", 0, 3, 0);
|
||||
|
||||
dict_index_add_field(index, "COL1", 0);
|
||||
dict_index_add_field(index, "COL2", 0);
|
||||
dict_index_add_field(index, "COL3", 0);
|
||||
|
||||
ut_a(0 == dict_index_publish(index));
|
||||
|
||||
index = dict_index_get("TS_TABLE1", "IND1");
|
||||
ut_a(index);
|
||||
|
||||
tuple = dtuple_create(heap, 3);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_create(0, 5, &mtr);
|
||||
buf_page_x_lock(block, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
for (i = 0; i < 512; i++) {
|
||||
|
||||
rnd = (rnd + 534671) % 512;
|
||||
|
||||
if (i % 27 == 0) {
|
||||
ut_a(page_validate(page, index));
|
||||
}
|
||||
|
||||
dtuple_gen_test_tuple(tuple, rnd);
|
||||
|
||||
/* dtuple_print(tuple);*/
|
||||
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
|
||||
ut_a(rec);
|
||||
|
||||
rec_validate(rec);
|
||||
/* page_print_list(page, 151); */
|
||||
}
|
||||
|
||||
/* page_print_list(page, 151); */
|
||||
|
||||
ut_a(page_validate(page, index));
|
||||
ut_a(page_get_n_recs(page) == 512);
|
||||
|
||||
for (i = 0; i < 512; i++) {
|
||||
|
||||
rnd = (rnd + 7771) % 512;
|
||||
|
||||
if (i % 27 == 0) {
|
||||
ut_a(page_validate(page, index));
|
||||
}
|
||||
|
||||
dtuple_gen_test_tuple(tuple, rnd);
|
||||
|
||||
/* dtuple_print(tuple);*/
|
||||
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
page_cur_delete_rec(&cursor, &mtr);
|
||||
|
||||
ut_a(rec);
|
||||
|
||||
rec_validate(rec);
|
||||
/* page_print_list(page, 151); */
|
||||
}
|
||||
|
||||
ut_a(page_get_n_recs(page) == 0);
|
||||
|
||||
ut_a(page_validate(page, index));
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
rnd = 311;
|
||||
|
||||
for (i = 0; i < 512; i++) {
|
||||
|
||||
rnd = (rnd + 1) % 512;
|
||||
|
||||
if (i % 27 == 0) {
|
||||
ut_a(page_validate(page, index));
|
||||
}
|
||||
|
||||
dtuple_gen_test_tuple(tuple, rnd);
|
||||
|
||||
/* dtuple_print(tuple);*/
|
||||
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
|
||||
ut_a(rec);
|
||||
|
||||
rec_validate(rec);
|
||||
/* page_print_list(page, 151); */
|
||||
}
|
||||
|
||||
ut_a(page_validate(page, index));
|
||||
ut_a(page_get_n_recs(page) == 512);
|
||||
|
||||
rnd = 217;
|
||||
|
||||
for (i = 0; i < 512; i++) {
|
||||
|
||||
rnd = (rnd + 1) % 512;
|
||||
|
||||
if (i % 27 == 0) {
|
||||
ut_a(page_validate(page, index));
|
||||
}
|
||||
|
||||
dtuple_gen_test_tuple(tuple, rnd);
|
||||
|
||||
/* dtuple_print(tuple);*/
|
||||
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
page_cur_delete_rec(&cursor, &mtr);
|
||||
|
||||
ut_a(rec);
|
||||
|
||||
rec_validate(rec);
|
||||
/* page_print_list(page, 151); */
|
||||
}
|
||||
|
||||
ut_a(page_validate(page, index));
|
||||
ut_a(page_get_n_recs(page) == 0);
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
rnd = 291;
|
||||
|
||||
for (i = 0; i < 512; i++) {
|
||||
|
||||
rnd = (rnd - 1) % 512;
|
||||
|
||||
if (i % 27 == 0) {
|
||||
ut_a(page_validate(page, index));
|
||||
}
|
||||
|
||||
dtuple_gen_test_tuple(tuple, rnd);
|
||||
|
||||
/* dtuple_print(tuple);*/
|
||||
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
|
||||
ut_a(rec);
|
||||
|
||||
rec_validate(rec);
|
||||
/* page_print_list(page, 151); */
|
||||
}
|
||||
|
||||
ut_a(page_validate(page, index));
|
||||
ut_a(page_get_n_recs(page) == 512);
|
||||
|
||||
rnd = 277;
|
||||
|
||||
for (i = 0; i < 512; i++) {
|
||||
|
||||
rnd = (rnd - 1) % 512;
|
||||
|
||||
if (i % 27 == 0) {
|
||||
ut_a(page_validate(page, index));
|
||||
}
|
||||
|
||||
dtuple_gen_test_tuple(tuple, rnd);
|
||||
|
||||
/* dtuple_print(tuple);*/
|
||||
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
page_cur_delete_rec(&cursor, &mtr);
|
||||
|
||||
ut_a(rec);
|
||||
|
||||
rec_validate(rec);
|
||||
/* page_print_list(page, 151); */
|
||||
}
|
||||
|
||||
ut_a(page_validate(page, index));
|
||||
ut_a(page_get_n_recs(page) == 0);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
mem_heap_free(heap);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Test for index page. */
|
||||
|
||||
void
|
||||
test2(void)
|
||||
/*=======*/
|
||||
{
|
||||
page_t* page;
|
||||
dtuple_t* tuple;
|
||||
mem_heap_t* heap;
|
||||
ulint i, j;
|
||||
ulint rnd = 0;
|
||||
rec_t* rec;
|
||||
page_cur_t cursor;
|
||||
dict_index_t* index;
|
||||
dict_table_t* table;
|
||||
buf_block_t* block;
|
||||
buf_frame_t* frame;
|
||||
ulint tm, oldtm;
|
||||
byte buf[8];
|
||||
mtr_t mtr;
|
||||
mtr_t mtr2;
|
||||
|
||||
printf("-------------------------------------------------\n");
|
||||
printf("TEST 2. Speed test\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
ut_memcpy(bigbuf, bigbuf + 800, 800);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for %lu mem copys of 800 bytes %lu millisecs\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rnd = 0;
|
||||
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
ut_memcpy(bigbuf + rnd, bigbuf + rnd + 800, 800);
|
||||
rnd += 1600;
|
||||
if (rnd > 995000) {
|
||||
rnd = 0;
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for %lu mem copys of 800 bytes %lu millisecs\n",
|
||||
i, tm - oldtm);
|
||||
|
||||
heap = mem_heap_create(0);
|
||||
|
||||
table = dict_table_create("TS_TABLE2", 2);
|
||||
|
||||
dict_table_add_col(table, "COL1", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
|
||||
dict_table_add_col(table, "COL2", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
|
||||
|
||||
ut_a(0 == dict_table_publish(table));
|
||||
|
||||
index = dict_index_create("TS_TABLE2", "IND2", 0, 2, 0);
|
||||
|
||||
dict_index_add_field(index, "COL1", 0);
|
||||
dict_index_add_field(index, "COL2", 0);
|
||||
|
||||
ut_a(0 == dict_index_publish(index));
|
||||
|
||||
index = dict_index_get("TS_TABLE2", "IND2");
|
||||
ut_a(index);
|
||||
|
||||
tuple = dtuple_create(heap, 3);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rnd = 677;
|
||||
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_create(0, 5, &mtr);
|
||||
buf_page_x_lock(block, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
for (j = 0; j < 200; j++) {
|
||||
rnd = (rnd + 54841) % 1000;
|
||||
dtuple_gen_test_tuple3(tuple, rnd, buf);
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
ut_a(rec);
|
||||
}
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for insertion of %lu recs %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_get(0, 5, &mtr);
|
||||
buf_page_s_lock(block, &mtr);
|
||||
|
||||
page = buf_block_get_frame(block);
|
||||
ut_a(page_validate(page, index));
|
||||
mtr_commit(&mtr);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
rnd = 677;
|
||||
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_create(0, 5, &mtr);
|
||||
buf_page_x_lock(block, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
for (j = 0; j < 200; j++) {
|
||||
rnd = (rnd + 54841) % 1000;
|
||||
dtuple_gen_test_tuple3(tuple, rnd, buf);
|
||||
}
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf(
|
||||
"Wall time for %lu empty loops with page create %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_create(0, 5, &mtr);
|
||||
buf_page_x_lock(block, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
|
||||
rnd = 100;
|
||||
for (j = 0; j < 200; j++) {
|
||||
mtr_start(&mtr2);
|
||||
|
||||
block = buf_page_get(0, 5, &mtr2);
|
||||
buf_page_x_lock(block, &mtr2);
|
||||
|
||||
page = buf_block_get_frame(block);
|
||||
|
||||
rnd = (rnd + 1) % 1000;
|
||||
dtuple_gen_test_tuple3(tuple, rnd, buf);
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr2);
|
||||
ut_a(rec);
|
||||
|
||||
mtr_commit(&mtr2);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf(
|
||||
"Wall time for sequential insertion of %lu recs %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_get(0, 5, &mtr);
|
||||
buf_page_s_lock(block, &mtr);
|
||||
|
||||
page = buf_block_get_frame(block);
|
||||
ut_a(page_validate(page, index));
|
||||
mtr_commit(&mtr);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_create(0, 5, &mtr);
|
||||
buf_page_x_lock(block, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
rnd = 500;
|
||||
for (j = 0; j < 200; j++) {
|
||||
rnd = (rnd - 1) % 1000;
|
||||
dtuple_gen_test_tuple3(tuple, rnd, buf);
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
ut_a(rec);
|
||||
}
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf(
|
||||
"Wall time for descend. seq. insertion of %lu recs %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_create(0, 5, &mtr);
|
||||
buf_page_x_lock(block, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
rnd = 677;
|
||||
|
||||
for (j = 0; j < 200; j++) {
|
||||
rnd = (rnd + 54841) % 1000;
|
||||
dtuple_gen_test_tuple3(tuple, rnd, buf);
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
ut_a(rec);
|
||||
}
|
||||
|
||||
rnd = 677;
|
||||
for (j = 0; j < 200; j++) {
|
||||
rnd = (rnd + 54841) % 1000;
|
||||
dtuple_gen_test_tuple3(tuple, rnd, buf);
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
page_cur_delete_rec(&cursor, &mtr);
|
||||
}
|
||||
ut_a(page_get_n_recs(page) == 0);
|
||||
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for insert and delete of %lu recs %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
mtr_start(&mtr);
|
||||
|
||||
block = buf_page_create(0, 5, &mtr);
|
||||
buf_page_x_lock(block, &mtr);
|
||||
|
||||
frame = buf_block_get_frame(block);
|
||||
|
||||
page = page_create(frame, &mtr);
|
||||
|
||||
rnd = 677;
|
||||
|
||||
for (j = 0; j < 200; j++) {
|
||||
rnd = (rnd + 54841) % 1000;
|
||||
dtuple_gen_test_tuple3(tuple, rnd, buf);
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
|
||||
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
|
||||
ut_a(rec);
|
||||
}
|
||||
ut_a(page_validate(page, index));
|
||||
mtr_print(&mtr);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
rnd = 677;
|
||||
for (j = 0; j < 200; j++) {
|
||||
/* rnd = (rnd + 54841) % 1000;*/
|
||||
dtuple_gen_test_tuple3(tuple, rnd, buf);
|
||||
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for search of %lu recs %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
|
||||
rnd = 677;
|
||||
for (j = 0; j < 200; j++) {
|
||||
rnd = (rnd + 54841) % 1000;
|
||||
dtuple_gen_test_tuple3(tuple, rnd, buf);
|
||||
}
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for %lu empty loops %lu milliseconds\n",
|
||||
i * j, tm - oldtm);
|
||||
mtr_commit(&mtr);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
|
||||
sync_init();
|
||||
mem_init();
|
||||
os_aio_init(160, 5);
|
||||
fil_init(25);
|
||||
buf_pool_init(100, 100);
|
||||
dict_init();
|
||||
log_init();
|
||||
|
||||
create_files();
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
ut_rnd_set_seed(19);
|
||||
|
||||
test1();
|
||||
test2();
|
||||
|
||||
mem_print_info();
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
|
||||
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tsrem: ..\rem.lib tsrem.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\rem.lib ..\..\page.lib ..\..\mtr.lib ..\..\btr.lib ..\..\log.lib ..\..\dyn.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsrem.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,464 +0,0 @@
|
||||
/************************************************************************
|
||||
The test for the record manager
|
||||
|
||||
(c) 1994-1996 Innobase Oy
|
||||
|
||||
Created 1/25/1994 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "sync0sync.h"
|
||||
#include "mem0mem.h"
|
||||
#include "data0data.h"
|
||||
#include "data0type.h"
|
||||
#include "dict0dict.h"
|
||||
#include "buf0buf.h"
|
||||
#include "fil0fil.h"
|
||||
#include "../rem0rec.h"
|
||||
#include "../rem0cmp.h"
|
||||
|
||||
byte buf1[100000];
|
||||
|
||||
/*********************************************************************
|
||||
Test for data tuples. */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
dtype_t* type;
|
||||
dtuple_t* tuple, *tuple2;
|
||||
dfield_t* field;
|
||||
mem_heap_t* heap;
|
||||
ulint i, j;
|
||||
ulint n;
|
||||
char* p_Pascal;
|
||||
char* p_Cobol;
|
||||
|
||||
heap = mem_heap_create(0);
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("DATA TUPLE-TEST 1. Basic tests.\n");
|
||||
|
||||
tuple = dtuple_create(heap, 2);
|
||||
|
||||
field = dtuple_get_nth_field(tuple, 0);
|
||||
dfield_set_data(field, "Pascal", 7);
|
||||
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 7, 0);
|
||||
|
||||
field = dtuple_get_nth_field(tuple, 1);
|
||||
dfield_set_data(field, "Cobol", 6);
|
||||
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 6, 0);
|
||||
|
||||
dtuple_validate(tuple);
|
||||
dtuple_print(tuple);
|
||||
|
||||
tuple2 = dtuple_create(heap, 10);
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
field = dtuple_get_nth_field(tuple2, i);
|
||||
dfield_set_data(field, NULL, UNIV_SQL_NULL);
|
||||
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH,
|
||||
6, 0);
|
||||
}
|
||||
|
||||
dtuple_print(tuple2);
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("DATA TUPLE-TEST 2. Accessor function tests.\n");
|
||||
|
||||
tuple = dtuple_create(heap, 2);
|
||||
|
||||
p_Pascal = "Pascal";
|
||||
p_Cobol = "Cobol";
|
||||
|
||||
field = dtuple_get_nth_field(tuple, 0);
|
||||
dfield_set_data(field, p_Pascal, 7);
|
||||
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 7, 0);
|
||||
|
||||
field = dtuple_get_nth_field(tuple, 1);
|
||||
dfield_set_data(field, p_Cobol, 6);
|
||||
dtype_set(dfield_get_type(field), DATA_VARCHAR, DATA_ENGLISH, 16, 3);
|
||||
|
||||
ut_a(dtuple_get_n_fields(tuple) == 2);
|
||||
|
||||
field = dtuple_get_nth_field(tuple, 0);
|
||||
ut_a(p_Pascal == dfield_get_data(field));
|
||||
ut_a(7 == dfield_get_len(field));
|
||||
type = dfield_get_type(field);
|
||||
ut_a(type->mtype == DATA_CHAR);
|
||||
ut_a(type->prtype == DATA_ENGLISH);
|
||||
ut_a(type->len == 7);
|
||||
ut_a(type->prec == 0);
|
||||
|
||||
field = dtuple_get_nth_field(tuple, 1);
|
||||
ut_a(p_Cobol == dfield_get_data(field));
|
||||
ut_a(6 == dfield_get_len(field));
|
||||
type = dfield_get_type(field);
|
||||
ut_a(type->mtype == DATA_VARCHAR);
|
||||
ut_a(type->prtype == DATA_ENGLISH);
|
||||
ut_a(type->len == 16);
|
||||
ut_a(type->prec == 3);
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("DATA TYPE-TEST 3. Other function tests\n");
|
||||
|
||||
ut_a(dtuple_get_data_size(tuple) == 13);
|
||||
|
||||
ut_a(dtuple_fold(tuple, 2) == dtuple_fold(tuple, 2));
|
||||
ut_a(dtuple_fold(tuple, 1) != dtuple_fold(tuple, 2));
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("DATA TUPLE-TEST 4. Random tuple generation test\n");
|
||||
|
||||
for (i = 0; i < 500; i++) {
|
||||
tuple = dtuple_gen_rnd_tuple(heap);
|
||||
printf("%lu ", i);
|
||||
|
||||
dtuple_validate(tuple);
|
||||
n = dtuple_get_n_fields(tuple);
|
||||
|
||||
if (n < 25) {
|
||||
tuple2 = dtuple_create(heap, n);
|
||||
for (j = 0; j < n; j++) {
|
||||
dfield_copy(
|
||||
dtuple_get_nth_field(tuple2, j),
|
||||
dtuple_get_nth_field(tuple, j));
|
||||
}
|
||||
dtuple_validate(tuple2);
|
||||
|
||||
ut_a(dtuple_fold(tuple, n) ==
|
||||
dtuple_fold(tuple2, n));
|
||||
}
|
||||
}
|
||||
|
||||
mem_print_info();
|
||||
mem_heap_free(heap);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Test for physical records. */
|
||||
|
||||
void
|
||||
test2(void)
|
||||
/*=======*/
|
||||
{
|
||||
dtuple_t* tuple, *tuple2;
|
||||
dfield_t* field;
|
||||
mem_heap_t* heap;
|
||||
ulint i, n;
|
||||
char* p_Pascal;
|
||||
char* p_Cobol;
|
||||
rec_t* rec, *rec2;
|
||||
byte* data;
|
||||
ulint len;
|
||||
byte* buf;
|
||||
|
||||
heap = mem_heap_create(0);
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("REC-TEST 1. Basic tests.\n");
|
||||
|
||||
tuple = dtuple_create(heap, 2);
|
||||
|
||||
p_Pascal = "Pascal";
|
||||
p_Cobol = "Cobol";
|
||||
|
||||
field = dtuple_get_nth_field(tuple, 0);
|
||||
dfield_set_data(field, "Pascal", 7);
|
||||
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 7, 0);
|
||||
|
||||
field = dtuple_get_nth_field(tuple, 1);
|
||||
dfield_set_data(field, "Cobol", 6);
|
||||
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 6, 0);
|
||||
|
||||
tuple2 = dtuple_create(heap, 37);
|
||||
|
||||
for (i = 0; i < 37; i++) {
|
||||
field = dtuple_get_nth_field(tuple2, i);
|
||||
dfield_set_data(field, NULL, UNIV_SQL_NULL);
|
||||
dtype_set(dfield_get_type(field), DATA_CHAR,
|
||||
DATA_ENGLISH, 6, 0);
|
||||
}
|
||||
|
||||
rec = rec_convert_dtuple_to_rec(buf1, tuple);
|
||||
|
||||
rec_validate(rec);
|
||||
rec_print(rec);
|
||||
|
||||
rec2 = rec_convert_dtuple_to_rec(buf1 + 1000, tuple2);
|
||||
|
||||
rec_validate(rec2);
|
||||
|
||||
data = rec_get_nth_field(rec, 0, &len);
|
||||
|
||||
ut_a(0 == memcmp(p_Pascal, data, 7));
|
||||
ut_a(len == 7);
|
||||
|
||||
data = rec_get_nth_field(rec, 1, &len);
|
||||
|
||||
ut_a(0 == memcmp(p_Cobol, data, 6));
|
||||
ut_a(len == 6);
|
||||
|
||||
ut_a(2 == rec_get_n_fields(rec));
|
||||
|
||||
for (i = 0; i < 37; i++) {
|
||||
data = rec_get_nth_field(rec2, i, &len);
|
||||
ut_a(len == UNIV_SQL_NULL);
|
||||
}
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("REC-TEST 2. Test of accessor functions\n");
|
||||
|
||||
rec_set_next_offs(rec, 8190);
|
||||
rec_set_n_owned(rec, 15);
|
||||
rec_set_heap_no(rec, 0);
|
||||
|
||||
ut_a(rec_get_next_offs(rec) == 8190);
|
||||
ut_a(rec_get_n_owned(rec) == 15);
|
||||
ut_a(rec_get_heap_no(rec) == 0);
|
||||
|
||||
rec_set_next_offs(rec, 1);
|
||||
rec_set_n_owned(rec, 1);
|
||||
rec_set_heap_no(rec, 8190);
|
||||
|
||||
ut_a(rec_get_next_offs(rec) == 1);
|
||||
ut_a(rec_get_n_owned(rec) == 1);
|
||||
ut_a(rec_get_heap_no(rec) == 8190);
|
||||
|
||||
buf = mem_heap_alloc(heap, 6);
|
||||
|
||||
rec_copy_nth_field(buf, rec, 1, &len);
|
||||
|
||||
ut_a(ut_memcmp(p_Cobol, buf, len) == 0);
|
||||
ut_a(len == 6);
|
||||
|
||||
rec_set_nth_field(rec, 1, "Algol", 6);
|
||||
|
||||
rec_validate(rec);
|
||||
|
||||
rec_copy_nth_field(buf, rec, 1, &len);
|
||||
|
||||
ut_a(ut_memcmp("Algol", buf, len) == 0);
|
||||
ut_a(len == 6);
|
||||
|
||||
ut_a(rec_get_data_size(rec) == 13);
|
||||
ut_a((ulint)(rec_get_end(rec) - rec) == 13);
|
||||
ut_a(14 == (ulint)(rec - rec_get_start(rec)));
|
||||
|
||||
ut_a(rec_get_size(rec) == 27);
|
||||
|
||||
mem_heap_free(heap);
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("REC-TEST 3. Massive test of conversions \n");
|
||||
|
||||
heap = mem_heap_create(0);
|
||||
|
||||
for (i = 0; i < 100; i++) {
|
||||
|
||||
tuple = dtuple_gen_rnd_tuple(heap);
|
||||
|
||||
if (i % 10 == 0) {
|
||||
printf("%lu ", i);
|
||||
}
|
||||
|
||||
if (i % 10 == 0) {
|
||||
printf(
|
||||
"data tuple generated: %lu fields, data size %lu\n",
|
||||
dtuple_get_n_fields(tuple),
|
||||
dtuple_get_data_size(tuple));
|
||||
}
|
||||
|
||||
dtuple_validate(tuple);
|
||||
|
||||
rec = rec_convert_dtuple_to_rec(buf1, tuple);
|
||||
|
||||
rec_validate(rec);
|
||||
|
||||
n = dtuple_get_n_fields(tuple);
|
||||
|
||||
ut_a(cmp_dtuple_rec_prefix_equal(tuple, rec, n));
|
||||
ut_a(dtuple_fold(tuple, n) == rec_fold(rec, n));
|
||||
ut_a(rec_get_converted_size(tuple) == rec_get_size(rec));
|
||||
ut_a(rec_get_data_size(rec) == dtuple_get_data_size(tuple));
|
||||
}
|
||||
|
||||
mem_print_info();
|
||||
mem_heap_free(heap);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
Test for comparisons. */
|
||||
|
||||
void
|
||||
test3(void)
|
||||
/*=======*/
|
||||
{
|
||||
dtuple_t* tuple, *tuple2, *tuple3;
|
||||
dfield_t* field;
|
||||
mem_heap_t* heap;
|
||||
ulint i, j;
|
||||
ulint field_match, byte_match;
|
||||
rec_t* rec;
|
||||
rec_t* rec2;
|
||||
ulint tm, oldtm;
|
||||
dict_index_t* index;
|
||||
dict_table_t* table;
|
||||
|
||||
heap = mem_heap_create(0);
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("CMP-TEST 1. Basic tests.\n");
|
||||
|
||||
tuple = dtuple_create(heap, 2);
|
||||
|
||||
field = dtuple_get_nth_field(tuple, 0);
|
||||
dfield_set_data(field, "Pascal", 7);
|
||||
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 7, 0);
|
||||
|
||||
field = dtuple_get_nth_field(tuple, 1);
|
||||
dfield_set_data(field, "Cobol", 6);
|
||||
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 6, 0);
|
||||
|
||||
tuple2 = dtuple_create(heap, 2);
|
||||
|
||||
field = dtuple_get_nth_field(tuple2, 0);
|
||||
dfield_set_data(field, "Pascal", 7);
|
||||
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 7, 0);
|
||||
|
||||
field = dtuple_get_nth_field(tuple2, 1);
|
||||
dfield_set_data(field, "Cobom", 6);
|
||||
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 6, 0);
|
||||
|
||||
tuple3 = dtuple_create(heap, 2);
|
||||
|
||||
field = dtuple_get_nth_field(tuple3, 0);
|
||||
dfield_set_data(field, "PaSCal", 7);
|
||||
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 7, 0);
|
||||
|
||||
field = dtuple_get_nth_field(tuple3, 1);
|
||||
dfield_set_data(field, "CobOL", 6);
|
||||
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 6, 0);
|
||||
|
||||
rec = rec_convert_dtuple_to_rec(buf1, tuple);
|
||||
|
||||
rec_validate(rec);
|
||||
|
||||
ut_a(!cmp_dtuple_rec_prefix_equal(tuple2, rec, 2));
|
||||
ut_a(cmp_dtuple_rec_prefix_equal(tuple, rec, 2));
|
||||
ut_a(cmp_dtuple_rec_prefix_equal(tuple3, rec, 2));
|
||||
|
||||
oldtm = ut_clock();
|
||||
j = 0;
|
||||
for (i = 0; i < 1000; i++) {
|
||||
field_match = 1;
|
||||
byte_match = 4;
|
||||
if (1 == cmp_dtuple_rec_with_match(tuple2, rec,
|
||||
&field_match, &byte_match)) {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
tm = ut_clock();
|
||||
printf("Time for fast comp. %lu records = %lu\n", j, tm - oldtm);
|
||||
|
||||
ut_a(field_match == 1);
|
||||
ut_a(byte_match == 4);
|
||||
|
||||
oldtm = ut_clock();
|
||||
j = 0;
|
||||
for (i = 0; i < 1000; i++) {
|
||||
field_match = 0;
|
||||
byte_match = 0;
|
||||
if (1 == cmp_dtuple_rec_with_match(tuple2, rec,
|
||||
&field_match, &byte_match)) {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
tm = ut_clock();
|
||||
printf("Time for test comp. %lu records = %lu\n", j, tm - oldtm);
|
||||
|
||||
ut_a(field_match == 1);
|
||||
ut_a(byte_match == 4);
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf(
|
||||
"CMP-TEST 2. A systematic test of comparisons and conversions\n");
|
||||
|
||||
tuple = dtuple_create(heap, 3);
|
||||
tuple2 = dtuple_create(heap, 3);
|
||||
|
||||
table = dict_table_create("TS_TABLE1", 3);
|
||||
|
||||
dict_table_add_col(table, "COL1", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
|
||||
dict_table_add_col(table, "COL2", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
|
||||
dict_table_add_col(table, "COL3", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
|
||||
|
||||
ut_a(0 == dict_table_publish(table));
|
||||
|
||||
index = dict_index_create("TS_TABLE1", "IND1", 0, 3, 0);
|
||||
|
||||
dict_index_add_field(index, "COL1", 0);
|
||||
dict_index_add_field(index, "COL2", 0);
|
||||
dict_index_add_field(index, "COL3", 0);
|
||||
|
||||
ut_a(0 == dict_index_publish(index));
|
||||
|
||||
index = dict_index_get("TS_TABLE1", "IND1");
|
||||
ut_a(index);
|
||||
|
||||
/* Compare all test data tuples to each other */
|
||||
for (i = 0; i < 512; i++) {
|
||||
dtuple_gen_test_tuple(tuple, i);
|
||||
rec = rec_convert_dtuple_to_rec(buf1, tuple);
|
||||
ut_a(rec_validate(rec));
|
||||
|
||||
ut_a(0 == cmp_dtuple_rec(tuple, rec));
|
||||
|
||||
for (j = 0; j < 512; j++) {
|
||||
dtuple_gen_test_tuple(tuple2, j);
|
||||
ut_a(dtuple_validate(tuple2));
|
||||
|
||||
rec2 = rec_convert_dtuple_to_rec(buf1 + 500, tuple2);
|
||||
|
||||
if (j < i) {
|
||||
ut_a(-1 == cmp_dtuple_rec(tuple2, rec));
|
||||
ut_a(-1 == cmp_rec_rec(rec2, rec, index));
|
||||
} else if (j == i) {
|
||||
ut_a(0 == cmp_dtuple_rec(tuple2, rec));
|
||||
ut_a(0 == cmp_rec_rec(rec2, rec, index));
|
||||
} else if (j > i) {
|
||||
ut_a(1 == cmp_dtuple_rec(tuple2, rec));
|
||||
ut_a(1 == cmp_rec_rec(rec2, rec, index));
|
||||
}
|
||||
}
|
||||
}
|
||||
mem_heap_free(heap);
|
||||
}
|
||||
|
||||
/********************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
|
||||
sync_init();
|
||||
mem_init();
|
||||
fil_init(25);
|
||||
buf_pool_init(100, 100);
|
||||
dict_init();
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
ut_rnd_set_seed(19);
|
||||
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
|
||||
tm = ut_clock();
|
||||
printf("CPU time for test %lu microseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
|
||||
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tstcur: ..\tcur.lib tstcur.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\tcur.lib ..\..\trx.lib ..\..\btr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tstcur.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,15 +0,0 @@
|
||||
|
||||
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tssrv: ..\srv.lib tssrv.c makefile
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\srv.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\btr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tssrv.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,118 +0,0 @@
|
||||
/************************************************************************
|
||||
Database client test program
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 10/10/1995 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "com0com.h"
|
||||
#include "com0shm.h"
|
||||
#include "ut0ut.h"
|
||||
#include "mem0mem.h"
|
||||
#include "os0thread.h"
|
||||
#include "sync0ipm.h"
|
||||
#include "sync0sync.h"
|
||||
|
||||
byte buf[10000];
|
||||
char addr[150];
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
com_endpoint_t* ep;
|
||||
ulint ret;
|
||||
ulint size;
|
||||
ulint len;
|
||||
ulint addr_len;
|
||||
ulint i, j;
|
||||
ulint tm, oldtm;
|
||||
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 10000; i++) {
|
||||
|
||||
ut_delay(100);
|
||||
}
|
||||
|
||||
for (j = 0; j < i / 10; j++) {
|
||||
|
||||
ut_delay(200);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test without server %ld milliseconds\n",
|
||||
tm - oldtm);
|
||||
printf("%lu rounds\n", i);
|
||||
|
||||
ep = com_endpoint_create(COM_SHM);
|
||||
|
||||
ut_a(ep);
|
||||
|
||||
size = 8192;
|
||||
|
||||
ret = com_endpoint_set_option(ep, COM_OPT_MAX_DGRAM_SIZE,
|
||||
(byte*)&size, 0);
|
||||
|
||||
ut_a(ret == 0);
|
||||
|
||||
ret = com_bind(ep, "CLI", 3);
|
||||
|
||||
ut_a(ret == 0);
|
||||
|
||||
printf("Client endpoint created!\n");
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (i = 0; i < 50000; i++) {
|
||||
|
||||
ret = com_sendto(ep, (byte*)"Hello from client!\n", 18, "ibsrv", 5);
|
||||
|
||||
ut_a(ret == 0);
|
||||
|
||||
ret = com_recvfrom(ep, buf, 10000, &len, addr, 150, &addr_len);
|
||||
|
||||
ut_a(ret == 0);
|
||||
|
||||
buf[len] = '\0';
|
||||
addr[addr_len] = '\0';
|
||||
/*
|
||||
printf(
|
||||
"Message of len %lu\n%s \nreceived from address %s of len %lu\n",
|
||||
len, buf, addr, addr_len);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %ld milliseconds\n", tm - oldtm);
|
||||
printf("%lu message pairs\n", i);
|
||||
|
||||
|
||||
printf("System calls in com_shm %lu ip_mutex %lu mutex %lu\n",
|
||||
com_shm_system_call_count,
|
||||
ip_mutex_system_call_count,
|
||||
mutex_system_call_count);
|
||||
|
||||
|
||||
ret = com_endpoint_free(ep);
|
||||
|
||||
ut_ad(ret == 0);
|
||||
}
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
|
||||
|
||||
|
||||
sync_init();
|
||||
mem_init();
|
||||
|
||||
test1();
|
||||
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
/******************************************************
|
||||
Test for the database server
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 10/10/1995 Heikki Tuuri
|
||||
*******************************************************/
|
||||
|
||||
#include "srv0srv.h"
|
||||
#include "os0proc.h"
|
||||
#include "ut0mem.h"
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
The main function of the server. */
|
||||
|
||||
void
|
||||
main(
|
||||
/*=*/
|
||||
#ifdef notdefined
|
||||
|
||||
ulint argc, /* in: number of string arguments given on
|
||||
the command line */
|
||||
char* argv[]
|
||||
#endif
|
||||
) /* in: array of character pointers giving
|
||||
the arguments */
|
||||
{
|
||||
/*
|
||||
if (argc != 2) {
|
||||
printf("Error! Wrong number of command line arguments!\n");
|
||||
printf("Usage: ib <init-file-name>\n");
|
||||
os_process_exit(1);
|
||||
}
|
||||
*/
|
||||
srv_boot("init.ib"/*argv[1]*/);
|
||||
|
||||
os_process_exit(0);
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
|
||||
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tssync: ..\sync.lib tssync.c makefile
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\sync.lib ..\..\mach.lib ..\..\ut.lib ..\..\mem.lib ..\..\os.lib tssync.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,14 +0,0 @@
|
||||
|
||||
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tsthr: ..\thr.lib tsthr.c makefile
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\thr.lib ..\..\ha.lib ..\..\sync.lib ..\..\ut.lib ..\..\mem.lib ..\..\os.lib tsthr.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,131 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for the thread management of Innobase
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 10/5/1995 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "../thr0loc.h"
|
||||
#include "sync0sync.h"
|
||||
#include "mem0mem.h"
|
||||
#include "os0thread.h"
|
||||
#include "os0sync.h"
|
||||
#include "ut0ut.h"
|
||||
|
||||
ulint val = 500;
|
||||
os_event_t event;
|
||||
|
||||
/******************************************************************
|
||||
Thread start function in test1. */
|
||||
|
||||
ulint
|
||||
thread1(
|
||||
/*====*/
|
||||
void* arg)
|
||||
{
|
||||
ulint n;
|
||||
|
||||
thr_local_create();
|
||||
|
||||
n = *((ulint*)arg);
|
||||
|
||||
printf("Thread %lu starts\n", n);
|
||||
|
||||
thr_local_set_slot_no(os_thread_get_curr_id(), n);
|
||||
|
||||
ut_a(n == thr_local_get_slot_no(os_thread_get_curr_id()));
|
||||
|
||||
os_event_wait(event);
|
||||
|
||||
thr_local_free();
|
||||
|
||||
os_thread_exit(0);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
Test function for local storage. */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
os_thread_t thr1, thr2, thr3, thr4, thr5;
|
||||
os_thread_id_t id1, id2, id3, id4, id5;
|
||||
ulint tm, oldtm;
|
||||
ulint n1, n2, n3, n4, n5;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("THR-TEST 1. Test of local storage\n");
|
||||
|
||||
event = os_event_create(NULL);
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
n1 = 1;
|
||||
thr1 = os_thread_create(thread1,
|
||||
&n1,
|
||||
&id1);
|
||||
n2 = 2;
|
||||
thr2 = os_thread_create(thread1,
|
||||
&n2,
|
||||
&id2);
|
||||
n3 = 3;
|
||||
thr3 = os_thread_create(thread1,
|
||||
&n3,
|
||||
&id3);
|
||||
n4 = 4;
|
||||
thr4 = os_thread_create(thread1,
|
||||
&n4,
|
||||
&id4);
|
||||
n5 = 5;
|
||||
thr5 = os_thread_create(thread1,
|
||||
&n5,
|
||||
&id5);
|
||||
|
||||
os_thread_sleep(500000);
|
||||
|
||||
ut_a(n1 == thr_local_get_slot_no(id1));
|
||||
ut_a(n2 == thr_local_get_slot_no(id2));
|
||||
ut_a(n3 == thr_local_get_slot_no(id3));
|
||||
ut_a(n4 == thr_local_get_slot_no(id4));
|
||||
ut_a(n5 == thr_local_get_slot_no(id5));
|
||||
|
||||
os_event_set(event);
|
||||
|
||||
os_thread_wait(thr1);
|
||||
os_thread_wait(thr2);
|
||||
os_thread_wait(thr3);
|
||||
os_thread_wait(thr4);
|
||||
os_thread_wait(thr5);
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for 5 threads %ld milliseconds\n",
|
||||
tm - oldtm);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
Main test function. */
|
||||
|
||||
void
|
||||
main(void)
|
||||
/*======*/
|
||||
{
|
||||
ulint tm, oldtm;
|
||||
|
||||
sync_init();
|
||||
mem_init();
|
||||
thr_local_init();
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
test1();
|
||||
|
||||
thr_local_close();
|
||||
|
||||
tm = ut_clock();
|
||||
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
|
||||
printf("TESTS COMPLETED SUCCESSFULLY!\n");
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
|
||||
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tstrx: ..\trx.lib tstrx.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\btr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tstrx.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,12 +0,0 @@
|
||||
|
||||
include ..\..\makefile.i
|
||||
|
||||
tsut: ..\ut.lib tsut.c
|
||||
$(CCOM) $(CFL) -I.. -I..\.. ..\ut.lib ..\..\os.lib tsut.c $(LFL)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,347 +0,0 @@
|
||||
/************************************************************************
|
||||
The test module for the utilities
|
||||
|
||||
(c) 1995 Innobase Oy
|
||||
|
||||
Created 10/28/1995 Heikki Tuuri
|
||||
*************************************************************************/
|
||||
|
||||
#include "../ut0lst.h"
|
||||
#include "../ut0mem.h"
|
||||
#include "../ut0byte.h"
|
||||
#include "../ut0sort.h"
|
||||
#include "../ut0rnd.h"
|
||||
|
||||
typedef struct node_struct node_t;
|
||||
struct node_struct {
|
||||
ulint index;
|
||||
ulint zyx;
|
||||
UT_LIST_NODE_T(node_t) list1;
|
||||
ulint yzx;
|
||||
UT_LIST_NODE_T(node_t) list2;
|
||||
};
|
||||
|
||||
/* Arrays to be sorted */
|
||||
ulint uarr[100000];
|
||||
ulint aux_uarr[100000];
|
||||
dulint duarr[100000];
|
||||
dulint aux_duarr[100000];
|
||||
|
||||
/*********************************************************************
|
||||
Tests for two-way lists. */
|
||||
|
||||
void
|
||||
test1(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i;
|
||||
UT_LIST_BASE_NODE_T(node_t) base1;
|
||||
UT_LIST_BASE_NODE_T(node_t) base2;
|
||||
node_t* node;
|
||||
node_t* node2;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 1. Test of two-way lists \n");
|
||||
|
||||
UT_LIST_INIT(base1);
|
||||
UT_LIST_INIT(base2);
|
||||
|
||||
for (i = 0; i < 1000; i++) {
|
||||
node = ut_malloc(sizeof(node_t));
|
||||
|
||||
node->index = 999 - i;
|
||||
|
||||
UT_LIST_ADD_FIRST(list1, base1, node);
|
||||
UT_LIST_ADD_LAST(list2, base2, node);
|
||||
}
|
||||
|
||||
UT_LIST_VALIDATE(list1, node_t, base1);
|
||||
UT_LIST_VALIDATE(list2, node_t, base2);
|
||||
|
||||
node = UT_LIST_GET_FIRST(base1);
|
||||
|
||||
for (i = 0; i < 1000; i++) {
|
||||
|
||||
ut_a(node);
|
||||
ut_a(node->index == i);
|
||||
|
||||
node = UT_LIST_GET_NEXT(list1, node);
|
||||
}
|
||||
|
||||
ut_a(node == NULL);
|
||||
|
||||
node = UT_LIST_GET_FIRST(base2);
|
||||
|
||||
for (i = 0; i < 1000; i++) {
|
||||
|
||||
ut_a(node);
|
||||
ut_a(node->index == 999 - i);
|
||||
|
||||
node = UT_LIST_GET_NEXT(list2, node);
|
||||
}
|
||||
|
||||
ut_a(node == NULL);
|
||||
|
||||
UT_LIST_VALIDATE(list1, node_t, base1);
|
||||
UT_LIST_VALIDATE(list2, node_t, base2);
|
||||
|
||||
node = UT_LIST_GET_FIRST(base1);
|
||||
|
||||
for (i = 0; i < 500; i++) {
|
||||
|
||||
ut_a(node);
|
||||
ut_a(node->index == i);
|
||||
|
||||
node = UT_LIST_GET_NEXT(list1, node);
|
||||
}
|
||||
|
||||
for (i = 0; i < 100; i++) {
|
||||
node2 = ut_malloc(sizeof(node_t));
|
||||
|
||||
node2->index = 99 - i;
|
||||
|
||||
UT_LIST_INSERT_AFTER(list1, base1, node, node2);
|
||||
UT_LIST_VALIDATE(list1, node_t, base1);
|
||||
}
|
||||
|
||||
node2 = ut_malloc(sizeof(node_t));
|
||||
node2->index = 1000;
|
||||
UT_LIST_INSERT_AFTER(list1, base1, UT_LIST_GET_LAST(base1), node2);
|
||||
|
||||
node2 = node;
|
||||
|
||||
for (i = 0; i < 100; i++) {
|
||||
node2 = UT_LIST_GET_NEXT(list1, node2);
|
||||
|
||||
ut_a(node2);
|
||||
ut_a(node2->index == i);
|
||||
}
|
||||
|
||||
UT_LIST_VALIDATE(list1, node_t, base1);
|
||||
|
||||
for (i = 0; i < 600; i++) {
|
||||
|
||||
node2 = UT_LIST_GET_NEXT(list1, node);
|
||||
|
||||
UT_LIST_REMOVE(list1, base1, node2);
|
||||
UT_LIST_VALIDATE(list1, node_t, base1);
|
||||
}
|
||||
|
||||
node2 = UT_LIST_GET_NEXT(list1, node);
|
||||
|
||||
UT_LIST_VALIDATE(list1, node_t, base1);
|
||||
UT_LIST_VALIDATE(list2, node_t, base2);
|
||||
|
||||
ut_a(UT_LIST_GET_LEN(base1) == 501);
|
||||
|
||||
ut_a(UT_LIST_GET_LAST(base1) == node);
|
||||
|
||||
for (i = 0; i < 500; i++) {
|
||||
|
||||
node = UT_LIST_GET_PREV(list1, node);
|
||||
}
|
||||
|
||||
ut_a(UT_LIST_GET_FIRST(base1) == node);
|
||||
|
||||
for (i = 0; i < 501; i++) {
|
||||
|
||||
node2 = UT_LIST_GET_FIRST(base1);
|
||||
|
||||
UT_LIST_REMOVE(list1, base1, node2);
|
||||
}
|
||||
|
||||
UT_LIST_VALIDATE(list1, node_t, base1);
|
||||
UT_LIST_VALIDATE(list2, node_t, base2);
|
||||
|
||||
ut_a(UT_LIST_GET_LEN(base1) == 0);
|
||||
ut_a(UT_LIST_GET_LEN(base2) == 1000);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Tests for dulints. */
|
||||
|
||||
void
|
||||
test2(void)
|
||||
/*=======*/
|
||||
{
|
||||
dulint a, b;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 2. Test of dulints \n");
|
||||
|
||||
a = ut_dulint_create(0xFFFFFFFF, 0xFFFFFFFF);
|
||||
|
||||
b = a;
|
||||
|
||||
ut_a(ut_dulint_cmp(a, b) == 0);
|
||||
|
||||
ut_a(ut_dulint_get_low(b) == 0xFFFFFFFF);
|
||||
ut_a(ut_dulint_get_high(b) == 0xFFFFFFFF);
|
||||
|
||||
a = ut_dulint_create(0xFFFFFFFE, 0xFFFFFFFF);
|
||||
ut_a(ut_dulint_cmp(a, b) == -1);
|
||||
ut_a(ut_dulint_cmp(b, a) == 1);
|
||||
|
||||
a = ut_dulint_create(0xFFFFFFFF, 0xFFFFFFFE);
|
||||
ut_a(ut_dulint_cmp(a, b) == -1);
|
||||
ut_a(ut_dulint_cmp(b, a) == 1);
|
||||
|
||||
a = ut_dulint_create(5, 0xFFFFFFFF);
|
||||
|
||||
a = ut_dulint_add(a, 5);
|
||||
|
||||
ut_a(ut_dulint_get_low(a) == 4);
|
||||
ut_a(ut_dulint_get_high(a) == 6);
|
||||
|
||||
a = ut_dulint_create(5, 0x80000000);
|
||||
|
||||
a = ut_dulint_add(a, 0x80000000);
|
||||
|
||||
ut_a(ut_dulint_get_low(a) == 0);
|
||||
ut_a(ut_dulint_get_high(a) == 6);
|
||||
|
||||
a = ut_dulint_create(5, 10);
|
||||
|
||||
a = ut_dulint_add(a, 20);
|
||||
|
||||
ut_a(ut_dulint_get_low(a) == 30);
|
||||
ut_a(ut_dulint_get_high(a) == 5);
|
||||
}
|
||||
|
||||
/***************************************************************
|
||||
Comparison function for ulints. */
|
||||
UNIV_INLINE
|
||||
int
|
||||
cmp_ulint(ulint a, ulint b)
|
||||
/*=======================*/
|
||||
{
|
||||
if (a < b) {
|
||||
return(-1);
|
||||
} else if (b < a) {
|
||||
return(1);
|
||||
} else {
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
Sort function for ulint arrays. */
|
||||
void
|
||||
sort_ulint(ulint* arr, ulint* aux_arr, ulint low, ulint high)
|
||||
/*=========================================================*/
|
||||
{
|
||||
ut_ad(high <= 100000);
|
||||
|
||||
UT_SORT_FUNCTION_BODY(sort_ulint, arr, aux_arr, low, high,
|
||||
cmp_ulint);
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
Sort function for dulint arrays. */
|
||||
void
|
||||
sort_dulint(dulint* arr, dulint* aux_arr, ulint low, ulint high)
|
||||
/*=========================================================*/
|
||||
{
|
||||
ut_ad(high <= 100000);
|
||||
|
||||
UT_SORT_FUNCTION_BODY(sort_dulint, arr, aux_arr, low, high,
|
||||
ut_dulint_cmp);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
Tests for sorting. */
|
||||
|
||||
void
|
||||
test3(void)
|
||||
/*=======*/
|
||||
{
|
||||
ulint i, j;
|
||||
ulint tm, oldtm;
|
||||
|
||||
printf("-------------------------------------------\n");
|
||||
printf("TEST 3. Test of sorting \n");
|
||||
|
||||
for (i = 0; i < 100000; i++) {
|
||||
uarr[i] = ut_rnd_gen_ulint();
|
||||
}
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
for (j = 0; j < 1; j++) {
|
||||
i = 100000;
|
||||
|
||||
sort_ulint(uarr, aux_uarr, 0, i);
|
||||
}
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for sort of %lu ulints %lu millisecs\n",
|
||||
j * i, tm - oldtm);
|
||||
|
||||
for (i = 1; i < 100000; i++) {
|
||||
ut_a(uarr[i - 1] < uarr[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < 100000; i++) {
|
||||
uarr[i] = 99999 - i;
|
||||
}
|
||||
|
||||
sort_ulint(uarr, aux_uarr, 0, 100000);
|
||||
|
||||
for (i = 1; i < 100000; i++) {
|
||||
ut_a(uarr[i] == i);
|
||||
}
|
||||
|
||||
sort_ulint(uarr, aux_uarr, 0, 100000);
|
||||
|
||||
for (i = 1; i < 100000; i++) {
|
||||
ut_a(uarr[i] == i);
|
||||
}
|
||||
|
||||
sort_ulint(uarr, aux_uarr, 5, 6);
|
||||
|
||||
for (i = 1; i < 100000; i++) {
|
||||
ut_a(uarr[i] == i);
|
||||
}
|
||||
|
||||
for (i = 0; i < 100000; i++) {
|
||||
uarr[i] = 5;
|
||||
}
|
||||
|
||||
sort_ulint(uarr, aux_uarr, 0, 100000);
|
||||
|
||||
for (i = 1; i < 100000; i++) {
|
||||
ut_a(uarr[i] == 5);
|
||||
}
|
||||
|
||||
for (i = 0; i < 100000; i++) {
|
||||
duarr[i] = ut_dulint_create(ut_rnd_gen_ulint() & 0xFFFFFFFF,
|
||||
ut_rnd_gen_ulint() & 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
oldtm = ut_clock();
|
||||
|
||||
i = 100000;
|
||||
|
||||
sort_dulint(duarr, aux_duarr, 0, i);
|
||||
|
||||
tm = ut_clock();
|
||||
|
||||
printf("Wall clock time for sort of %lu dulints %lu millisecs\n",
|
||||
j * i, tm - oldtm);
|
||||
|
||||
for (i = 1; i < 100000; i++) {
|
||||
ut_a(ut_dulint_cmp(duarr[i - 1], duarr[i]) < 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
main(void)
|
||||
{
|
||||
test1();
|
||||
test2();
|
||||
test3();
|
||||
|
||||
printf("TEST SUCCESSFULLY COMPLETED!\n");
|
||||
}
|
Reference in New Issue
Block a user