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';
381 ret
= strtoll(optarg
, (char **)NULL
, 10);
397 ret
*= 1024 * 1024 * 1024;
406 } /* ms_parse_size */
409 /* used to parse the options of command line */
410 static void ms_options_parse(int argc
, char *argv
[])
415 while ((option_rv
= getopt_long(argc
, argv
, "VhURbaBs:x:T:c:X:v:d:"
416 "t:S:F:w:e:o:n:P:p:",
417 long_options
, &option_index
)) != -1)
424 case OPT_VERSION
: /* --version or -V */
425 ms_version_command(PROGRAM_NAME
);
428 case OPT_HELP
: /* --help or -h */
429 ms_help_command(PROGRAM_NAME
, PROGRAM_DESCRIPTION
);
432 case OPT_SERVERS
: /* --servers or -s */
433 ms_setting
.srv_str
= strdup(optarg
);
436 case OPT_CONCURRENCY
: /* --concurrency or -c */
437 ms_setting
.nconns
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
438 if (ms_setting
.nconns
<= 0)
440 fprintf(stderr
, "Concurrency must be greater than 0.:-)\n");
445 case OPT_EXECUTE_NUMBER
: /* --execute_number or -x */
446 ms_setting
.exec_num
= (int)strtol(optarg
, (char **) NULL
, 10);
447 if (ms_setting
.exec_num
<= 0)
449 fprintf(stderr
, "Execute number must be greater than 0.:-)\n");
454 case OPT_THREAD_NUMBER
: /* --threads or -T */
455 ms_setting
.nthreads
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
456 if (ms_setting
.nthreads
<= 0)
458 fprintf(stderr
, "Threads number must be greater than 0.:-)\n");
463 case OPT_FIXED_LTH
: /* --fixed_size or -X */
464 ms_setting
.fixed_value_size
= (size_t)strtoull(optarg
, (char **) NULL
, 10);
465 if ((ms_setting
.fixed_value_size
<= 0)
466 || (ms_setting
.fixed_value_size
> MAX_VALUE_SIZE
))
468 fprintf(stderr
, "Value size must be between 0 and 1M.:-)\n");
473 case OPT_VERIFY
: /* --verify or -v */
474 ms_setting
.verify_percent
= atof(optarg
);
475 if ((ms_setting
.verify_percent
<= 0)
476 || (ms_setting
.verify_percent
> 1.0))
478 fprintf(stderr
, "Data verification rate must be "
479 "greater than 0 and less than 1.0. :-)\n");
484 case OPT_GETS_DIVISION
: /* --division or -d */
485 ms_setting
.mult_key_num
= (int)strtol(optarg
, (char **) NULL
, 10);
486 if (ms_setting
.mult_key_num
<= 0)
488 fprintf(stderr
, "Multi-get key number must be greater than 0.:-)\n");
493 case OPT_TIME
: /* --time or -t */
494 ms_setting
.run_time
= (int)ms_parse_time();
495 if (ms_setting
.run_time
== -1)
497 fprintf(stderr
, "Please specify the run time. :-)\n"
498 "'s' for second, 'm' for minute, 'h' for hour, "
499 "'d' for day. e.g.: --time=24h (means 24 hours).\n");
503 if (ms_setting
.run_time
== 0)
505 fprintf(stderr
, "Running time can not be 0. :-)\n");
510 case OPT_CONFIG_CMD
: /* --cfg_cmd or -F */
511 ms_setting
.cfg_file
= strdup(optarg
);
514 case OPT_WINDOW_SIZE
: /* --win_size or -w */
515 ms_setting
.win_size
= (size_t)ms_parse_size();
516 if (ms_setting
.win_size
== (size_t)-1)
520 "Please specify the item window size. :-)\n"
521 "e.g.: --win_size=10k (means 10k task window size).\n");
526 case OPT_UDP
: /* --udp or -U*/
527 ms_setting
.udp
= true;
530 case OPT_EXPIRE
: /* --exp_verify or -e */
531 ms_setting
.exp_ver_per
= atof(optarg
);
532 if ((ms_setting
.exp_ver_per
<= 0) || (ms_setting
.exp_ver_per
> 1.0))
534 fprintf(stderr
, "Expire time verification rate must be "
535 "greater than 0 and less than 1.0. :-)\n");
540 case OPT_OVERWRITE
: /* --overwrite or -o */
541 ms_setting
.overwrite_percent
= atof(optarg
);
542 if ((ms_setting
.overwrite_percent
<= 0)
543 || (ms_setting
.overwrite_percent
> 1.0))
545 fprintf(stderr
, "Objects overwrite rate must be "
546 "greater than 0 and less than 1.0. :-)\n");
551 case OPT_STAT_FREQ
: /* --stat_freq or -S */
552 ms_setting
.stat_freq
= (int)ms_parse_time();
553 if (ms_setting
.stat_freq
== -1)
555 fprintf(stderr
, "Please specify the frequency of dumping "
556 "statistic information. :-)\n"
557 "'s' for second, 'm' for minute, 'h' for hour, "
558 "'d' for day. e.g.: --time=24h (means 24 hours).\n");
562 if (ms_setting
.stat_freq
== 0)
564 fprintf(stderr
, "The frequency of dumping statistic information "
565 "can not be 0. :-)\n");
570 case OPT_SOCK_PER_CONN
: /* --conn_sock or -n */
571 ms_setting
.sock_per_conn
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
572 if (ms_setting
.sock_per_conn
<= 0)
574 fprintf(stderr
, "Number of socks of each concurrency "
575 "must be greater than 0.:-)\n");
580 case OPT_RECONNECT
: /* --reconnect or -R */
581 ms_setting
.reconnect
= true;
584 case OPT_VERBOSE
: /* --verbose or -b */
585 ms_setting
.verbose
= true;
588 case OPT_FACEBOOK_TEST
: /* --facebook or -a */
589 ms_setting
.facebook_test
= true;
592 case OPT_BINARY_PROTOCOL
: /* --binary or -B */
593 ms_setting
.binary_prot_
= true;
596 case OPT_TPS
: /* --tps or -P */
597 ms_setting
.expected_tps
= (int)ms_parse_size();
598 if (ms_setting
.expected_tps
== -1)
601 "Please specify the item expected throughput. :-)\n"
602 "e.g.: --tps=10k (means 10k throughput).\n");
607 case OPT_REP_WRITE_SRV
: /* --rep_write or -p */
608 ms_setting
.rep_write_srv
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
609 if (ms_setting
.rep_write_srv
<= 0)
612 "Number of replication writing server must be greater "
619 /* getopt_long already printed an error message. */
626 } /* ms_options_parse */
629 static int ms_check_para()
631 if (ms_setting
.srv_str
== NULL
)
635 if ((temp
= getenv("MEMCACHED_SERVERS")))
637 ms_setting
.srv_str
= strdup(temp
);
641 fprintf(stderr
, "No Servers provided\n\n");
646 if (ms_setting
.nconns
% (uint32_t)ms_setting
.nthreads
!= 0)
648 fprintf(stderr
, "Concurrency must be the multiples of threads count.\n");
652 if (ms_setting
.win_size
% UNIT_ITEMS_COUNT
!= 0)
654 fprintf(stderr
, "Window size must be the multiples of 1024.\n\n");
659 } /* ms_check_para */
662 /* initialize the statistic structure */
663 static void ms_statistic_init()
665 pthread_mutex_init(&ms_statistic
.stat_mutex
, NULL
);
666 ms_init_stats(&ms_statistic
.get_stat
, "Get");
667 ms_init_stats(&ms_statistic
.set_stat
, "Set");
668 ms_init_stats(&ms_statistic
.total_stat
, "Total");
669 } /* ms_statistic_init */
672 /* initialize the global state structure */
673 static void ms_stats_init()
675 memset(&ms_stats
, 0, sizeof(ms_stats_t
));
676 if (ms_setting
.stat_freq
> 0)
680 } /* ms_stats_init */
683 /* use to output the statistic */
684 static void ms_print_statistics(int in_time
)
686 int obj_size
= (int)(ms_setting
.avg_key_size
+ ms_setting
.avg_val_size
);
688 printf("\033[1;1H\033[2J\n");
689 ms_dump_format_stats(&ms_statistic
.get_stat
, in_time
,
690 ms_setting
.stat_freq
, obj_size
);
691 ms_dump_format_stats(&ms_statistic
.set_stat
, in_time
,
692 ms_setting
.stat_freq
, obj_size
);
693 ms_dump_format_stats(&ms_statistic
.total_stat
, in_time
,
694 ms_setting
.stat_freq
, obj_size
);
695 } /* ms_print_statistics */
698 /* used to print the states of memslap */
699 static void ms_print_memslap_stats(struct timeval
*start_time
,
700 struct timeval
*end_time
)
706 sizeof(buf
), "cmd_get: %lu\n",
707 (unsigned long) ms_stats
.cmd_get
);
709 sizeof(buf
) - (size_t)(pos
-buf
),
711 (unsigned long) ms_stats
.cmd_set
);
713 sizeof(buf
) - (size_t)(pos
-buf
),
715 (unsigned long) ms_stats
.get_misses
);
717 if (ms_setting
.verify_percent
> 0)
720 sizeof(buf
) - (size_t)(pos
-buf
),
721 "verify_misses: %lu\n",
722 (unsigned long) ms_stats
.vef_miss
);
724 sizeof(buf
) - (size_t)(pos
-buf
),
725 "verify_failed: %lu\n",
726 (unsigned long) ms_stats
.vef_failed
);
729 if (ms_setting
.exp_ver_per
> 0)
732 sizeof(buf
) - (size_t)(pos
-buf
),
733 "expired_get: %lu\n",
734 (unsigned long) ms_stats
.exp_get
);
736 sizeof(buf
) - (size_t)(pos
-buf
),
737 "unexpired_unget: %lu\n",
738 (unsigned long) ms_stats
.unexp_unget
);
742 sizeof(buf
) - (size_t)(pos
-buf
),
743 "written_bytes: %lu\n",
744 (unsigned long) ms_stats
.bytes_written
);
746 sizeof(buf
) - (size_t)(pos
-buf
),
748 (unsigned long) ms_stats
.bytes_read
);
750 sizeof(buf
) - (size_t)(pos
-buf
),
751 "object_bytes: %lu\n",
752 (unsigned long) ms_stats
.obj_bytes
);
754 if (ms_setting
.udp
|| ms_setting
.facebook_test
)
757 sizeof(buf
) - (size_t)(pos
-buf
),
758 "packet_disorder: %lu\n",
759 (unsigned long) ms_stats
.pkt_disorder
);
761 sizeof(buf
) - (size_t)(pos
-buf
),
762 "packet_drop: %lu\n",
763 (unsigned long)ms_stats
.pkt_drop
);
765 sizeof(buf
) - (size_t)(pos
-buf
),
766 "udp_timeout: %lu\n",
767 (unsigned long)ms_stats
.udp_timeout
);
770 if (ms_setting
.stat_freq
> 0)
772 ms_dump_stats(&ms_statistic
.get_stat
);
773 ms_dump_stats(&ms_statistic
.set_stat
);
774 ms_dump_stats(&ms_statistic
.total_stat
);
777 int64_t time_diff
= ms_time_diff(start_time
, end_time
);
779 sizeof(buf
) - (size_t)(pos
-buf
),
780 "\nRun time: %.1fs Ops: %llu TPS: %.0Lf Net_rate: %.1fM/s\n",
781 (double)time_diff
/ 1000000,
782 (unsigned long long)(ms_stats
.cmd_get
+ ms_stats
.cmd_set
),
784 + ms_stats
.cmd_set
) / ((long double)time_diff
/ 1000000),
786 ms_stats
.bytes_written
787 + ms_stats
.bytes_read
) / 1024 / 1024
788 / ((double)time_diff
/ 1000000));
791 fprintf(stdout
, "%s", buf
);
793 } /* ms_print_memslap_stats */
796 /* the loop of the main thread, wait the work threads to complete */
797 static void ms_monitor_slap_mode()
799 struct timeval start_time
, end_time
;
801 /* Wait all the threads complete initialization. */
802 pthread_mutex_lock(&ms_global
.init_lock
.lock
);
803 while (ms_global
.init_lock
.count
< ms_setting
.nthreads
)
805 pthread_cond_wait(&ms_global
.init_lock
.cond
,
806 &ms_global
.init_lock
.lock
);
808 pthread_mutex_unlock(&ms_global
.init_lock
.lock
);
810 /* only when there is no set operation it need warm up */
811 if (ms_setting
.cmd_distr
[CMD_SET
].cmd_prop
< PROP_ERROR
)
813 /* Wait all the connects complete warm up. */
814 pthread_mutex_lock(&ms_global
.warmup_lock
.lock
);
815 while (ms_global
.warmup_lock
.count
< ms_setting
.nconns
)
817 pthread_cond_wait(&ms_global
.warmup_lock
.cond
, &ms_global
.warmup_lock
.lock
);
819 pthread_mutex_unlock(&ms_global
.warmup_lock
.lock
);
821 ms_global
.finish_warmup
= true;
823 /* running in "run time" mode, user specify run time */
824 if (ms_setting
.run_time
> 0)
827 gettimeofday(&start_time
, NULL
);
833 if ((ms_setting
.stat_freq
> 0) && (second
% ms_setting
.stat_freq
== 0)
834 && (ms_stats
.active_conns
>= ms_setting
.nconns
)
835 && (ms_stats
.active_conns
<= INT_MAX
))
837 ms_print_statistics(second
);
840 if (ms_setting
.run_time
<= second
)
842 ms_global
.time_out
= true;
846 /* all connections disconnect */
847 if ((second
> 5) && (ms_stats
.active_conns
== 0))
852 gettimeofday(&end_time
, NULL
);
853 sleep(1); /* wait all threads clean up */
857 /* running in "execute number" mode, user specify execute number */
858 gettimeofday(&start_time
, NULL
);
861 * We loop until we know that all connects have cleaned up.
863 pthread_mutex_lock(&ms_global
.run_lock
.lock
);
864 while (ms_global
.run_lock
.count
< ms_setting
.nconns
)
866 pthread_cond_wait(&ms_global
.run_lock
.cond
, &ms_global
.run_lock
.lock
);
868 pthread_mutex_unlock(&ms_global
.run_lock
.lock
);
870 gettimeofday(&end_time
, NULL
);
873 ms_print_memslap_stats(&start_time
, &end_time
);
874 } /* ms_monitor_slap_mode */
877 /* the main function */
878 int main(int argc
, char *argv
[])
880 srandom((unsigned int)time(NULL
));
881 ms_global_struct_init();
884 ms_setting_init_pre();
885 ms_options_parse(argc
, argv
);
888 ms_help_command(PROGRAM_NAME
, PROGRAM_DESCRIPTION
);
891 ms_setting_init_post();
895 /* waiting work thread complete its task */
896 ms_monitor_slap_mode();
900 ms_global_struct_destroy();
901 ms_setting_cleanup();