4 * (c) Copyright 2009, Schooner Information Technology, Inc.
6 * http://www.schoonerinfotech.com/
8 * Use and distribution licensed under the BSD license. See
9 * the COPYING file for full text.
13 * Mingqiang Zhuang <mingqiangzhuang@hengtiansoft.com>
16 #include "mem_config.h"
22 #if defined(HAVE_SYS_TIME_H)
23 # include <sys/time.h>
26 #if defined(HAVE_TIME_H)
31 #include "ms_sigsegv.h"
32 #include "ms_setting.h"
33 #include "ms_thread.h"
35 #define PROGRAM_NAME "memslap"
36 #define PROGRAM_DESCRIPTION \
37 "Generates workload against memcached servers."
40 /* For some odd reason the option struct on solaris defines the argument
41 * as char* and not const char*
43 #define OPTIONSTRING char*
45 #define OPTIONSTRING const char*
49 static struct option long_options
[]=
51 { (OPTIONSTRING
)"servers", required_argument
, NULL
,
53 { (OPTIONSTRING
)"threads", required_argument
, NULL
,
55 { (OPTIONSTRING
)"concurrency", required_argument
, NULL
,
57 { (OPTIONSTRING
)"conn_sock", required_argument
, NULL
,
59 { (OPTIONSTRING
)"execute_number", required_argument
, NULL
,
61 { (OPTIONSTRING
)"time", required_argument
, NULL
,
63 { (OPTIONSTRING
)"cfg_cmd", required_argument
, NULL
,
65 { (OPTIONSTRING
)"win_size", required_argument
, NULL
,
67 { (OPTIONSTRING
)"fixed_size", required_argument
, NULL
,
69 { (OPTIONSTRING
)"verify", required_argument
, NULL
,
71 { (OPTIONSTRING
)"division", required_argument
, NULL
,
73 { (OPTIONSTRING
)"stat_freq", required_argument
, NULL
,
75 { (OPTIONSTRING
)"exp_verify", required_argument
, NULL
,
77 { (OPTIONSTRING
)"overwrite", required_argument
, NULL
,
79 { (OPTIONSTRING
)"reconnect", no_argument
, NULL
,
81 { (OPTIONSTRING
)"udp", no_argument
, NULL
,
83 { (OPTIONSTRING
)"facebook", no_argument
, NULL
,
85 { (OPTIONSTRING
)"binary", no_argument
, NULL
,
86 OPT_BINARY_PROTOCOL
},
87 { (OPTIONSTRING
)"tps", required_argument
, NULL
,
89 { (OPTIONSTRING
)"rep_write", required_argument
, NULL
,
91 { (OPTIONSTRING
)"verbose", no_argument
, NULL
,
93 { (OPTIONSTRING
)"help", no_argument
, NULL
,
95 { (OPTIONSTRING
)"version", no_argument
, NULL
,
101 static void ms_sync_lock_init(void);
102 static void ms_sync_lock_destroy(void);
103 static void ms_global_struct_init(void);
104 static void ms_global_struct_destroy(void);
105 static void ms_version_command(const char *command_name
);
106 static const char *ms_lookup_help(ms_options_t option
);
107 static int64_t ms_parse_time(void);
108 static int64_t ms_parse_size(void);
109 static void ms_options_parse(int argc
, char *argv
[]);
110 static int ms_check_para(void);
111 static void ms_statistic_init(void);
112 static void ms_stats_init(void);
113 static void ms_print_statistics(int in_time
);
114 static void ms_print_memslap_stats(struct timeval
*start_time
,
115 struct timeval
*end_time
);
116 static void ms_monitor_slap_mode(void);
119 * output the help information
121 * @param command_name, the string of this process
122 * @param description, description of this process
123 * @param long_options, global options array
125 static __attribute__((noreturn
)) void ms_help_command(const char *command_name
, const char *description
)
127 char *help_message
= NULL
;
129 printf("%s v%u.%u\n", command_name
, 1U, 0U);
130 printf(" %s\n\n", description
);
133 " memslap -hV | -s servers [-F config_file] [-t time | -x exe_num] [...]\n\n"
136 for (int x
= 0; long_options
[x
].name
; x
++)
138 printf(" -%c, --%s%c\n", long_options
[x
].val
, long_options
[x
].name
,
139 long_options
[x
].has_arg
? '=' : ' ');
141 if ((help_message
= (char *)ms_lookup_help(long_options
[x
].val
)) != NULL
)
143 printf(" %s\n", help_message
);
149 " memslap -s 127.0.0.1:11211 -S 5s\n"
150 " memslap -s 127.0.0.1:11211 -t 2m -v 0.2 -e 0.05 -b\n"
151 " memslap -s 127.0.0.1:11211 -F config -t 2m -w 40k -S 20s -o 0.2\n"
152 " memslap -s 127.0.0.1:11211 -F config -t 2m -T 4 -c 128 -d 20 -P 40k\n"
153 " memslap -s 127.0.0.1:11211 -F config -t 2m -d 50 -a -n 40\n"
154 " memslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m\n"
155 " memslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m -p 2\n\n");
158 } /* ms_help_command */
161 /* initialize the global locks */
162 static void ms_sync_lock_init()
164 ms_global
.init_lock
.count
= 0;
165 pthread_mutex_init(&ms_global
.init_lock
.lock
, NULL
);
166 pthread_cond_init(&ms_global
.init_lock
.cond
, NULL
);
168 ms_global
.warmup_lock
.count
= 0;
169 pthread_mutex_init(&ms_global
.warmup_lock
.lock
, NULL
);
170 pthread_cond_init(&ms_global
.warmup_lock
.cond
, NULL
);
172 ms_global
.run_lock
.count
= 0;
173 pthread_mutex_init(&ms_global
.run_lock
.lock
, NULL
);
174 pthread_cond_init(&ms_global
.run_lock
.cond
, NULL
);
176 pthread_mutex_init(&ms_global
.quit_mutex
, NULL
);
177 pthread_mutex_init(&ms_global
.seq_mutex
, NULL
);
178 } /* ms_sync_lock_init */
181 /* destroy the global locks */
182 static void ms_sync_lock_destroy()
184 pthread_mutex_destroy(&ms_global
.init_lock
.lock
);
185 pthread_cond_destroy(&ms_global
.init_lock
.cond
);
187 pthread_mutex_destroy(&ms_global
.warmup_lock
.lock
);
188 pthread_cond_destroy(&ms_global
.warmup_lock
.cond
);
190 pthread_mutex_destroy(&ms_global
.run_lock
.lock
);
191 pthread_cond_destroy(&ms_global
.run_lock
.cond
);
193 pthread_mutex_destroy(&ms_global
.quit_mutex
);
194 pthread_mutex_destroy(&ms_global
.seq_mutex
);
196 if (ms_setting
.stat_freq
> 0)
198 pthread_mutex_destroy(&ms_statistic
.stat_mutex
);
200 } /* ms_sync_lock_destroy */
203 /* initialize the global structure */
204 static void ms_global_struct_init()
207 ms_global
.finish_warmup
= false;
208 ms_global
.time_out
= false;
212 /* destroy the global structure */
213 static void ms_global_struct_destroy()
215 ms_sync_lock_destroy();
220 * output the version information
222 * @param command_name, the string of this process
224 static void ms_version_command(const char *command_name
)
226 printf("%s v%u.%u\n", command_name
, 1U, 0U);
232 * get the description of the option
234 * @param option, option of command line
236 * @return char*, description of the command option
238 static const char *ms_lookup_help(ms_options_t option
)
244 "List one or more servers to connect. Servers count must be less than\n"
245 " threads count. e.g.: --servers=localhost:1234,localhost:11211";
248 return "Display the version of the application and then exit.";
251 return "Display this message and then exit.";
253 case OPT_EXECUTE_NUMBER
:
254 return "Number of operations(get and set) to execute for the\n"
255 " given test. Default 1000000.";
257 case OPT_THREAD_NUMBER
:
259 "Number of threads to startup, better equal to CPU numbers. Default 8.";
261 case OPT_CONCURRENCY
:
262 return "Number of concurrency to simulate with load. Default 128.";
265 return "Fixed length of value.";
268 return "The proportion of date verification, e.g.: --verify=0.01";
270 case OPT_GETS_DIVISION
:
271 return "Number of keys to multi-get once. Default 1, means single get.";
275 "How long the test to run, suffix: s-seconds, m-minutes, h-hours,\n"
276 " d-days e.g.: --time=2h.";
280 "Load the configure file to get command,key and value distribution list.";
282 case OPT_WINDOW_SIZE
:
284 "Task window size of each concurrency, suffix: K, M e.g.: --win_size=10k.\n"
289 "UDP support, default memslap uses TCP, TCP port and UDP port of\n"
290 " server must be same.";
294 "The proportion of objects with expire time, e.g.: --exp_verify=0.01.\n"
295 " Default no object with expire time";
299 "The proportion of objects need overwrite, e.g.: --overwrite=0.01.\n"
300 " Default never overwrite object.";
304 "Frequency of dumping statistic information. suffix: s-seconds,\n"
305 " m-minutes, e.g.: --resp_freq=10s.";
307 case OPT_SOCK_PER_CONN
:
308 return "Number of TCP socks per concurrency. Default 1.";
312 "Reconnect support, when connection is closed it will be reconnected.";
316 "Whether it outputs detailed information when verification fails.";
318 case OPT_FACEBOOK_TEST
:
320 "Whether it enables facebook test feature, set with TCP and multi-get with UDP.";
322 case OPT_BINARY_PROTOCOL
:
324 "Whether it enables binary protocol. Default with ASCII protocol.";
327 return "Expected throughput, suffix: K, e.g.: --tps=10k.";
329 case OPT_REP_WRITE_SRV
:
330 return "The first nth servers can write data, e.g.: --rep_write=2.";
333 return "Forgot to document this option :)";
335 } /* ms_lookup_help */
338 /* used to parse the time string */
339 static int64_t ms_parse_time()
342 char unit
= optarg
[strlen(optarg
) - 1];
344 optarg
[strlen(optarg
) - 1]= '\0';
371 } /* ms_parse_time */
374 /* used to parse the size string */
375 static int64_t ms_parse_size()
378 char unit
= optarg
[strlen(optarg
) - 1];
380 optarg
[strlen(optarg
) - 1]= '\0';
382 ret
= strtoll(optarg
, (char **)NULL
, 10);
385 fprintf(stderr
, "strtoll(optarg,..): %s\n", strerror(errno
));
403 ret
*= 1024 * 1024 * 1024;
412 } /* ms_parse_size */
415 /* used to parse the options of command line */
416 static void ms_options_parse(int argc
, char *argv
[])
421 while ((option_rv
= getopt_long(argc
, argv
, "VhURbaBs:x:T:c:X:v:d:"
422 "t:S:F:w:e:o:n:P:p:",
423 long_options
, &option_index
)) != -1)
430 case OPT_VERSION
: /* --version or -V */
431 ms_version_command(PROGRAM_NAME
);
434 case OPT_HELP
: /* --help or -h */
435 ms_help_command(PROGRAM_NAME
, PROGRAM_DESCRIPTION
);
438 case OPT_SERVERS
: /* --servers or -s */
439 ms_setting
.srv_str
= strdup(optarg
);
442 case OPT_CONCURRENCY
: /* --concurrency or -c */
444 ms_setting
.nconns
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
445 if (ms_setting
.nconns
<= 0 || errno
!= 0)
447 fprintf(stderr
, "Concurrency must be greater than 0.:-)\n");
452 case OPT_EXECUTE_NUMBER
: /* --execute_number or -x */
454 ms_setting
.exec_num
= (int)strtol(optarg
, (char **) NULL
, 10);
455 if (ms_setting
.exec_num
<= 0 || errno
!= 0)
457 fprintf(stderr
, "Execute number must be greater than 0.:-)\n");
462 case OPT_THREAD_NUMBER
: /* --threads or -T */
464 ms_setting
.nthreads
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
465 if (ms_setting
.nthreads
<= 0 || errno
!= 0)
467 fprintf(stderr
, "Threads number must be greater than 0.:-)\n");
472 case OPT_FIXED_LTH
: /* --fixed_size or -X */
474 ms_setting
.fixed_value_size
= (size_t)strtoull(optarg
, (char **) NULL
, 10);
475 if ((ms_setting
.fixed_value_size
<= 0 || errno
!= 0)
476 || (ms_setting
.fixed_value_size
> MAX_VALUE_SIZE
))
478 fprintf(stderr
, "Value size must be between 0 and 1M.:-)\n");
483 case OPT_VERIFY
: /* --verify or -v */
484 ms_setting
.verify_percent
= atof(optarg
);
485 if ((ms_setting
.verify_percent
<= 0)
486 || (ms_setting
.verify_percent
> 1.0))
488 fprintf(stderr
, "Data verification rate must be "
489 "greater than 0 and less than 1.0. :-)\n");
494 case OPT_GETS_DIVISION
: /* --division or -d */
496 ms_setting
.mult_key_num
= (int)strtol(optarg
, (char **) NULL
, 10);
497 if (ms_setting
.mult_key_num
<= 0 || errno
!= 0)
499 fprintf(stderr
, "Multi-get key number must be greater than 0.:-)\n");
504 case OPT_TIME
: /* --time or -t */
505 ms_setting
.run_time
= (int)ms_parse_time();
506 if (ms_setting
.run_time
== -1)
508 fprintf(stderr
, "Please specify the run time. :-)\n"
509 "'s' for second, 'm' for minute, 'h' for hour, "
510 "'d' for day. e.g.: --time=24h (means 24 hours).\n");
514 if (ms_setting
.run_time
== 0)
516 fprintf(stderr
, "Running time can not be 0. :-)\n");
521 case OPT_CONFIG_CMD
: /* --cfg_cmd or -F */
522 ms_setting
.cfg_file
= strdup(optarg
);
525 case OPT_WINDOW_SIZE
: /* --win_size or -w */
526 ms_setting
.win_size
= (size_t)ms_parse_size();
527 if (ms_setting
.win_size
== (size_t)-1)
531 "Please specify the item window size. :-)\n"
532 "e.g.: --win_size=10k (means 10k task window size).\n");
537 case OPT_UDP
: /* --udp or -U*/
538 ms_setting
.udp
= true;
541 case OPT_EXPIRE
: /* --exp_verify or -e */
542 ms_setting
.exp_ver_per
= atof(optarg
);
543 if ((ms_setting
.exp_ver_per
<= 0) || (ms_setting
.exp_ver_per
> 1.0))
545 fprintf(stderr
, "Expire time verification rate must be "
546 "greater than 0 and less than 1.0. :-)\n");
551 case OPT_OVERWRITE
: /* --overwrite or -o */
552 ms_setting
.overwrite_percent
= atof(optarg
);
553 if ((ms_setting
.overwrite_percent
<= 0)
554 || (ms_setting
.overwrite_percent
> 1.0))
556 fprintf(stderr
, "Objects overwrite rate must be "
557 "greater than 0 and less than 1.0. :-)\n");
562 case OPT_STAT_FREQ
: /* --stat_freq or -S */
563 ms_setting
.stat_freq
= (int)ms_parse_time();
564 if (ms_setting
.stat_freq
== -1)
566 fprintf(stderr
, "Please specify the frequency of dumping "
567 "statistic information. :-)\n"
568 "'s' for second, 'm' for minute, 'h' for hour, "
569 "'d' for day. e.g.: --time=24h (means 24 hours).\n");
573 if (ms_setting
.stat_freq
== 0)
575 fprintf(stderr
, "The frequency of dumping statistic information "
576 "can not be 0. :-)\n");
581 case OPT_SOCK_PER_CONN
: /* --conn_sock or -n */
583 ms_setting
.sock_per_conn
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
584 if (ms_setting
.sock_per_conn
<= 0 || errno
!= 0)
586 fprintf(stderr
, "Number of socks of each concurrency "
587 "must be greater than 0.:-)\n");
592 case OPT_RECONNECT
: /* --reconnect or -R */
593 ms_setting
.reconnect
= true;
596 case OPT_VERBOSE
: /* --verbose or -b */
597 ms_setting
.verbose
= true;
600 case OPT_FACEBOOK_TEST
: /* --facebook or -a */
601 ms_setting
.facebook_test
= true;
604 case OPT_BINARY_PROTOCOL
: /* --binary or -B */
605 ms_setting
.binary_prot_
= true;
608 case OPT_TPS
: /* --tps or -P */
609 ms_setting
.expected_tps
= (int)ms_parse_size();
610 if (ms_setting
.expected_tps
== -1)
613 "Please specify the item expected throughput. :-)\n"
614 "e.g.: --tps=10k (means 10k throughput).\n");
619 case OPT_REP_WRITE_SRV
: /* --rep_write or -p */
621 ms_setting
.rep_write_srv
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
622 if (ms_setting
.rep_write_srv
<= 0 || errno
!= 0)
625 "Number of replication writing server must be greater "
632 /* getopt_long already printed an error message. */
639 } /* ms_options_parse */
642 static int ms_check_para()
644 if (ms_setting
.srv_str
== NULL
)
648 if ((temp
= getenv("MEMCACHED_SERVERS")))
650 ms_setting
.srv_str
= strdup(temp
);
654 fprintf(stderr
, "No Servers provided\n\n");
659 if (ms_setting
.nconns
% (uint32_t)ms_setting
.nthreads
!= 0)
661 fprintf(stderr
, "Concurrency must be the multiples of threads count.\n");
665 if (ms_setting
.win_size
% UNIT_ITEMS_COUNT
!= 0)
667 fprintf(stderr
, "Window size must be the multiples of 1024.\n\n");
672 } /* ms_check_para */
675 /* initialize the statistic structure */
676 static void ms_statistic_init()
678 pthread_mutex_init(&ms_statistic
.stat_mutex
, NULL
);
679 ms_init_stats(&ms_statistic
.get_stat
, "Get");
680 ms_init_stats(&ms_statistic
.set_stat
, "Set");
681 ms_init_stats(&ms_statistic
.total_stat
, "Total");
682 } /* ms_statistic_init */
685 /* initialize the global state structure */
686 static void ms_stats_init()
688 memset(&ms_stats
, 0, sizeof(ms_stats_t
));
689 if (ms_setting
.stat_freq
> 0)
693 } /* ms_stats_init */
696 /* use to output the statistic */
697 static void ms_print_statistics(int in_time
)
699 int obj_size
= (int)(ms_setting
.avg_key_size
+ ms_setting
.avg_val_size
);
701 printf("\033[1;1H\033[2J\n");
702 ms_dump_format_stats(&ms_statistic
.get_stat
, in_time
,
703 ms_setting
.stat_freq
, obj_size
);
704 ms_dump_format_stats(&ms_statistic
.set_stat
, in_time
,
705 ms_setting
.stat_freq
, obj_size
);
706 ms_dump_format_stats(&ms_statistic
.total_stat
, in_time
,
707 ms_setting
.stat_freq
, obj_size
);
708 } /* ms_print_statistics */
711 /* used to print the states of memslap */
712 static void ms_print_memslap_stats(struct timeval
*start_time
,
713 struct timeval
*end_time
)
719 sizeof(buf
), "cmd_get: %lu\n",
720 (unsigned long) ms_stats
.cmd_get
);
722 sizeof(buf
) - (size_t)(pos
-buf
),
724 (unsigned long) ms_stats
.cmd_set
);
726 sizeof(buf
) - (size_t)(pos
-buf
),
728 (unsigned long) ms_stats
.get_misses
);
730 if (ms_setting
.verify_percent
> 0)
733 sizeof(buf
) - (size_t)(pos
-buf
),
734 "verify_misses: %lu\n",
735 (unsigned long) ms_stats
.vef_miss
);
737 sizeof(buf
) - (size_t)(pos
-buf
),
738 "verify_failed: %lu\n",
739 (unsigned long) ms_stats
.vef_failed
);
742 if (ms_setting
.exp_ver_per
> 0)
745 sizeof(buf
) - (size_t)(pos
-buf
),
746 "expired_get: %lu\n",
747 (unsigned long) ms_stats
.exp_get
);
749 sizeof(buf
) - (size_t)(pos
-buf
),
750 "unexpired_unget: %lu\n",
751 (unsigned long) ms_stats
.unexp_unget
);
755 sizeof(buf
) - (size_t)(pos
-buf
),
756 "written_bytes: %lu\n",
757 (unsigned long) ms_stats
.bytes_written
);
759 sizeof(buf
) - (size_t)(pos
-buf
),
761 (unsigned long) ms_stats
.bytes_read
);
763 sizeof(buf
) - (size_t)(pos
-buf
),
764 "object_bytes: %lu\n",
765 (unsigned long) ms_stats
.obj_bytes
);
767 if (ms_setting
.udp
|| ms_setting
.facebook_test
)
770 sizeof(buf
) - (size_t)(pos
-buf
),
771 "packet_disorder: %lu\n",
772 (unsigned long) ms_stats
.pkt_disorder
);
774 sizeof(buf
) - (size_t)(pos
-buf
),
775 "packet_drop: %lu\n",
776 (unsigned long)ms_stats
.pkt_drop
);
778 sizeof(buf
) - (size_t)(pos
-buf
),
779 "udp_timeout: %lu\n",
780 (unsigned long)ms_stats
.udp_timeout
);
783 if (ms_setting
.stat_freq
> 0)
785 ms_dump_stats(&ms_statistic
.get_stat
);
786 ms_dump_stats(&ms_statistic
.set_stat
);
787 ms_dump_stats(&ms_statistic
.total_stat
);
790 int64_t time_diff
= ms_time_diff(start_time
, end_time
);
792 sizeof(buf
) - (size_t)(pos
-buf
),
793 "\nRun time: %.1fs Ops: %llu TPS: %.0Lf Net_rate: %.1fM/s\n",
794 (double)time_diff
/ 1000000,
795 (unsigned long long)(ms_stats
.cmd_get
+ ms_stats
.cmd_set
),
797 + ms_stats
.cmd_set
) / ((long double)time_diff
/ 1000000),
799 ms_stats
.bytes_written
800 + ms_stats
.bytes_read
) / 1024 / 1024
801 / ((double)time_diff
/ 1000000));
804 fprintf(stdout
, "%s", buf
);
806 } /* ms_print_memslap_stats */
809 /* the loop of the main thread, wait the work threads to complete */
810 static void ms_monitor_slap_mode()
812 struct timeval start_time
, end_time
;
814 /* Wait all the threads complete initialization. */
815 pthread_mutex_lock(&ms_global
.init_lock
.lock
);
816 while (ms_global
.init_lock
.count
< ms_setting
.nthreads
)
818 pthread_cond_wait(&ms_global
.init_lock
.cond
,
819 &ms_global
.init_lock
.lock
);
821 pthread_mutex_unlock(&ms_global
.init_lock
.lock
);
823 /* only when there is no set operation it need warm up */
824 if (ms_setting
.cmd_distr
[CMD_SET
].cmd_prop
< PROP_ERROR
)
826 /* Wait all the connects complete warm up. */
827 pthread_mutex_lock(&ms_global
.warmup_lock
.lock
);
828 while (ms_global
.warmup_lock
.count
< ms_setting
.nconns
)
830 pthread_cond_wait(&ms_global
.warmup_lock
.cond
, &ms_global
.warmup_lock
.lock
);
832 pthread_mutex_unlock(&ms_global
.warmup_lock
.lock
);
834 ms_global
.finish_warmup
= true;
836 /* running in "run time" mode, user specify run time */
837 if (ms_setting
.run_time
> 0)
840 gettimeofday(&start_time
, NULL
);
846 if ((ms_setting
.stat_freq
> 0) && (second
% ms_setting
.stat_freq
== 0)
847 && (ms_stats
.active_conns
>= ms_setting
.nconns
)
848 && (ms_stats
.active_conns
<= INT_MAX
))
850 ms_print_statistics(second
);
853 if (ms_setting
.run_time
<= second
)
855 ms_global
.time_out
= true;
859 /* all connections disconnect */
860 if ((second
> 5) && (ms_stats
.active_conns
== 0))
865 gettimeofday(&end_time
, NULL
);
866 sleep(1); /* wait all threads clean up */
870 /* running in "execute number" mode, user specify execute number */
871 gettimeofday(&start_time
, NULL
);
874 * We loop until we know that all connects have cleaned up.
876 pthread_mutex_lock(&ms_global
.run_lock
.lock
);
877 while (ms_global
.run_lock
.count
< ms_setting
.nconns
)
879 pthread_cond_wait(&ms_global
.run_lock
.cond
, &ms_global
.run_lock
.lock
);
881 pthread_mutex_unlock(&ms_global
.run_lock
.lock
);
883 gettimeofday(&end_time
, NULL
);
886 ms_print_memslap_stats(&start_time
, &end_time
);
887 } /* ms_monitor_slap_mode */
890 /* the main function */
891 int main(int argc
, char *argv
[])
893 srandom((unsigned int)time(NULL
));
894 ms_global_struct_init();
897 ms_setting_init_pre();
898 ms_options_parse(argc
, argv
);
901 ms_help_command(PROGRAM_NAME
, PROGRAM_DESCRIPTION
);
904 ms_setting_init_post();
908 /* waiting work thread complete its task */
909 ms_monitor_slap_mode();
913 ms_global_struct_destroy();
914 ms_setting_cleanup();