#include <ndb_global.h>#include <NdbOut.hpp>#include <NdbThread.h>#include <NdbMutex.h>#include <NdbCondition.h>#include <NdbSleep.h>#include <NdbTick.h>#include <NdbEnv.h>#include <NdbHost.h>#include <NdbMain.h>#include <getarg.h>Include dependency graph for munmaptest.cpp:

Go to the source code of this file.
Classes | |
| struct | ThreadData |
Functions | |
| long long | getMilli () |
| long long | getMicro () |
| void * | mapSegment (void *arg) |
| void * | unmapSegment (void *arg) |
| NDB_MAIN (munmaptest) | |
Variables | |
| static int | trash |
| static int | segmentsize = 1 |
| static struct getargs | args [] |
| static const int | num_args = sizeof(args) / sizeof(args[0]) |
| long long getMicro | ( | ) |
| long long getMilli | ( | ) |
| void * mapSegment | ( | void * | arg | ) |
Definition at line 50 of file munmaptest.cpp.
References ThreadData::chunk, exit, getMicro(), ThreadData::idx, int(), MAP_PRIVATE, ThreadData::mapAddr, ThreadData::mapSize, max, min, NDB_THREAD_PRIO_MEAN, ndbout(), ndbout_c(), NdbThread_Create(), NdbThread_WaitFor(), PROT_READ, PROT_WRITE, start(), status, and unmapSegment().
Referenced by NDB_MAIN().
00050 { 00051 00052 ThreadData * threadArgs; 00053 long long start=0; 00054 int total=0; 00055 int id = *(int *)arg; 00056 threadArgs = new ThreadData [1]; 00057 Uint32 size=5*1024*1024; 00058 struct NdbThread* unmapthread_var; 00059 void *status = 0; 00060 int run = 1; 00061 int max=0, min =100000000, sum=0; 00062 while(run < 1001) { 00063 start=getMicro(); 00064 char * ptr =(char*) mmap(0, 00065 size, 00066 PROT_READ|PROT_WRITE, 00067 MAP_PRIVATE|MAP_ANONYMOUS, 00068 0, 00069 0); 00070 00071 total=(int)(getMicro()-start); 00072 00073 ndbout << "T" << id << ": mmap took : " << total << " microsecs. " 00074 << " Run: " << run ; 00075 ndbout_c(" mapped @ %p \n", ptr); 00076 00077 if(total>max) 00078 max = total; 00079 if(total<min) 00080 min=total; 00081 00082 sum+=total; 00083 00084 if(ptr<0) { 00085 ndbout << "failed to mmap!" << endl; 00086 exit(1); 00087 } 00088 00089 00090 threadArgs[0].mapAddr = (char *)ptr; 00091 threadArgs[0].mapSize = size; 00092 threadArgs[0].chunk = 4096; 00093 threadArgs[0].idx = 0; 00094 00095 00096 for(Uint32 j=0; j<size; j=j+4096) 00097 ptr[j]='1'; 00098 00099 unmapthread_var = NdbThread_Create(unmapSegment, // Function 00100 (void**)&threadArgs[0],// Arg 00101 32768, // Stacksize 00102 (char*)"unmapthread", // Thread name 00103 NDB_THREAD_PRIO_MEAN); // Thread prio 00104 00105 00106 if(NdbThread_WaitFor(unmapthread_var, &status) != 0) { 00107 ndbout << "test failed - exitting " << endl; 00108 exit(1); 00109 } 00110 run++; 00111 } 00112 00113 ndbout << "MAX: " << max << " MIN: " << min; 00114 float mean = (float) ((float)sum/(float)run); 00115 ndbout_c(" AVERAGE: %2.5f\n",mean); 00116 }
Here is the call graph for this function:

Here is the caller graph for this function:

| NDB_MAIN | ( | munmaptest | ) |
Definition at line 165 of file munmaptest.cpp.
References exit, ThreadData::idx, MAP_PRIVATE, mapSegment(), NDB_THREAD_PRIO_MEAN, ndbout(), NdbSleep_MilliSleep(), NdbThread_Create(), NdbThread_WaitFor(), num_args, progname, PROT_READ, PROT_WRITE, segmentsize, status, and trash.
00165 { 00166 00167 const char *progname = "munmaptest"; 00168 int optind = 0; 00169 00170 if(getarg(args, num_args, argc, argv, &optind)) { 00171 arg_printusage(args, num_args, progname, ""); 00172 exit(1); 00173 } 00174 00175 int size; 00176 char * ptr; 00177 if(trash) { 00178 for(int i=0; i<100; i++) { 00179 size=1+(int) (10.0*rand()/(RAND_MAX+1.0)); 00180 NdbSleep_MilliSleep(10); 00181 ptr =(char*) mmap(0, 00182 size*1024*1024, 00183 PROT_READ|PROT_WRITE, 00184 MAP_PRIVATE|MAP_ANONYMOUS, 00185 0, 00186 0); 00187 for(int i=0;i<(size*1024*1024); i=i+4096) { 00188 *(ptr+i)='1'; 00189 } 00190 NdbSleep_MilliSleep(10); 00191 00192 munmap(ptr,size); 00193 00194 } 00195 00196 00197 } 00198 00199 int noThreads = 1; 00200 struct NdbThread* mapthread_var; 00201 int id[noThreads]; 00202 void *status=0; 00203 00204 ThreadData * threadArgs = new ThreadData[noThreads]; 00205 00206 00207 00208 00209 for(int i=0; i < noThreads; i++) { 00210 threadArgs[i].mapSize = segmentsize*1024*1024; 00211 threadArgs[i].idx = i; 00212 mapthread_var = NdbThread_Create(mapSegment, // Function 00213 (void**)&threadArgs[i],// Arg 00214 32768, // Stacksize 00215 (char*)"mapthread", // Thread name 00216 NDB_THREAD_PRIO_MEAN); // Thread prio 00217 00218 } 00219 00220 00221 if(NdbThread_WaitFor(mapthread_var, &status) != 0) { 00222 ndbout << "test failed - exitting " << endl; 00223 exit(1); 00224 } 00225 00226 }
Here is the call graph for this function:

| void * unmapSegment | ( | void * | arg | ) |
Definition at line 120 of file munmaptest.cpp.
References ThreadData::chunk, exit, getMicro(), int(), ThreadData::mapAddr, ThreadData::mapSize, ndbout(), NdbSleep_MilliSleep(), NULL, and start().
Referenced by mapSegment().
00121 { 00122 00123 char * freeAddr; 00124 char * mapAddr; 00125 ThreadData * threadData = (ThreadData*) arg; 00126 int start=0; 00127 int total=0; 00128 Uint32 mapSize = threadData->mapSize; 00129 Uint32 chunk = threadData->chunk; 00130 mapAddr = threadData->mapAddr; 00131 00132 00133 00134 freeAddr = mapAddr+mapSize-chunk; 00135 NdbSleep_MilliSleep(100); 00136 for(Uint32 i=0;i<mapSize; i = i+chunk) { 00137 start=getMicro(); 00138 if(munmap(freeAddr, chunk) < 0){ 00139 ndbout << "munmap failed" << endl; 00140 exit(1); 00141 } 00142 total=(int)(getMicro()-start); 00143 freeAddr = freeAddr - chunk; 00144 NdbSleep_MilliSleep(10); 00145 ndbout << "unmap 4096 bytes : " << total << "microsecs" << endl; 00146 } 00147 return NULL; 00148 }
Here is the call graph for this function:

Here is the caller graph for this function:

struct getargs args[] [static] |
Initial value:
{
{ "trash", 't', arg_integer, &trash,
"trash the memory before (1 to trash 0 to not trash)", "trash"},
{ "segment", 's', arg_integer, &segmentsize,
"segment size (in MB)", "segment"},
}
Definition at line 155 of file munmaptest.cpp.
Referenced by _db_doprnt_(), abort_not_supported_test(), agg_item_charsets(), MYSQL_BIN_LOG::appendv(), build_equal_items_for_cond(), change_cond_ref_to_const(), check_group_min_max_predicates(), create_func_bool(), create_func_ceiling(), create_func_concat(), create_func_contains(), create_func_count(), create_func_floor(), create_func_not(), create_func_number(), create_func_round(), create_func_string_length(), create_func_substr(), create_func_sum(), create_tmp_table(), default_reporter(), die(), sp_head::execute_procedure(), CommandInterpreter::executeStartBackup(), fatal(), fill_schema_files(), general_log_print(), get_interval_value(), get_sort(), MgmApiSession::getConfig_old(), MgmApiSession::getConnectionParameter(), handle_parser_directive(), ieee_function_type(), listener(), load_defaults(), log_error(), log_info(), main(), matching_cond(), mi_check_print_error(), mi_check_print_info(), mi_check_print_warning(), multi_alloc_root(), my_b_printf(), my_coll_agg_error(), my_error(), my_multi_malloc(), my_printf_error(), my_snprintf(), my_snprintf_8bit(), my_xpath_parse_FunctionCall(), mysql_connection(), NDB_COMMAND(), ndb_mgm_abort_backup(), ndb_mgm_alloc_nodeid(), ndb_mgm_dump_state(), ndb_mgm_enter_single_user(), ndb_mgm_get_clusterlog_severity_filter(), ndb_mgm_get_configuration(), ndb_mgm_get_connection_int_parameter(), ndb_mgm_get_mgmd_nodeid(), ndb_mgm_get_version(), ndb_mgm_insert_error(), ndb_mgm_listen_event_internal(), ndb_mgm_log_signals(), ndb_mgm_purge_stale_sessions(), ndb_mgm_rep_command(), ndb_mgm_report_event(), ndb_mgm_restart3(), ndb_mgm_set_clusterlog_loglevel(), ndb_mgm_set_clusterlog_severity_filter(), ndb_mgm_set_connection_int_parameter(), ndb_mgm_set_int64_parameter(), ndb_mgm_set_int_parameter(), ndb_mgm_set_loglevel_node(), ndb_mgm_set_string_parameter(), ndb_mgm_set_trace(), ndb_mgm_start(), ndb_mgm_start_backup(), ndb_mgm_start_signallog(), ndb_mgm_stop3(), ndb_mgm_stop_signallog(), net_printf_error(), opt_sum_query(), option_error_reporter(), parse_stab_argtypes(), parse_stab_type(), print_error(), print_header(), print_info(), print_row(), print_trailer(), printf_log(), propagate_cond_constants(), push_warning_printf(), remove_eq_conds(), MgmApiSession::report_event(), run_hton_fill_schema_files(), set_args(), simple_pred(), sql_print_error(), sql_print_information(), sql_print_warning(), stab_demangle_type(), start_thread(), tcp_accept(), tee_fprintf(), verbose_msg(), and wait_tcp_ready().
int segmentsize = 1 [static] |
int trash [static] |
1.4.7

