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>
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);
117 void ms_help_command(const char *command_name
, const char *description
);
120 /* initialize the global locks */
121 static void ms_sync_lock_init()
123 ms_global
.init_lock
.count
= 0;
124 pthread_mutex_init(&ms_global
.init_lock
.lock
, NULL
);
125 pthread_cond_init(&ms_global
.init_lock
.cond
, NULL
);
127 ms_global
.warmup_lock
.count
= 0;
128 pthread_mutex_init(&ms_global
.warmup_lock
.lock
, NULL
);
129 pthread_cond_init(&ms_global
.warmup_lock
.cond
, NULL
);
131 ms_global
.run_lock
.count
= 0;
132 pthread_mutex_init(&ms_global
.run_lock
.lock
, NULL
);
133 pthread_cond_init(&ms_global
.run_lock
.cond
, NULL
);
135 pthread_mutex_init(&ms_global
.quit_mutex
, NULL
);
136 pthread_mutex_init(&ms_global
.seq_mutex
, NULL
);
137 } /* ms_sync_lock_init */
140 /* destroy the global locks */
141 static void ms_sync_lock_destroy()
143 pthread_mutex_destroy(&ms_global
.init_lock
.lock
);
144 pthread_cond_destroy(&ms_global
.init_lock
.cond
);
146 pthread_mutex_destroy(&ms_global
.warmup_lock
.lock
);
147 pthread_cond_destroy(&ms_global
.warmup_lock
.cond
);
149 pthread_mutex_destroy(&ms_global
.run_lock
.lock
);
150 pthread_cond_destroy(&ms_global
.run_lock
.cond
);
152 pthread_mutex_destroy(&ms_global
.quit_mutex
);
153 pthread_mutex_destroy(&ms_global
.seq_mutex
);
155 if (ms_setting
.stat_freq
> 0)
157 pthread_mutex_destroy(&ms_statistic
.stat_mutex
);
159 } /* ms_sync_lock_destroy */
162 /* initialize the global structure */
163 static void ms_global_struct_init()
166 ms_global
.finish_warmup
= false;
167 ms_global
.time_out
= false;
171 /* destroy the global structure */
172 static void ms_global_struct_destroy()
174 ms_sync_lock_destroy();
179 * output the version information
181 * @param command_name, the string of this process
183 static void ms_version_command(const char *command_name
)
185 printf("%s v%u.%u\n", command_name
, 1U, 0U);
191 * get the description of the option
193 * @param option, option of command line
195 * @return char*, description of the command option
197 static const char *ms_lookup_help(ms_options_t option
)
203 "List one or more servers to connect. Servers count must be less than\n"
204 " threads count. e.g.: --servers=localhost:1234,localhost:11211";
207 return "Display the version of the application and then exit.";
210 return "Display this message and then exit.";
212 case OPT_EXECUTE_NUMBER
:
213 return "Number of operations(get and set) to execute for the\n"
214 " given test. Default 1000000.";
216 case OPT_THREAD_NUMBER
:
218 "Number of threads to startup, better equal to CPU numbers. Default 8.";
220 case OPT_CONCURRENCY
:
221 return "Number of concurrency to simulate with load. Default 128.";
224 return "Fixed length of value.";
227 return "The proportion of date verification, e.g.: --verify=0.01";
229 case OPT_GETS_DIVISION
:
230 return "Number of keys to multi-get once. Default 1, means single get.";
234 "How long the test to run, suffix: s-seconds, m-minutes, h-hours,\n"
235 " d-days e.g.: --time=2h.";
239 "Load the configure file to get command,key and value distribution list.";
241 case OPT_WINDOW_SIZE
:
243 "Task window size of each concurrency, suffix: K, M e.g.: --win_size=10k.\n"
248 "UDP support, default memslap uses TCP, TCP port and UDP port of\n"
249 " server must be same.";
253 "The proportion of objects with expire time, e.g.: --exp_verify=0.01.\n"
254 " Default no object with expire time";
258 "The proportion of objects need overwrite, e.g.: --overwrite=0.01.\n"
259 " Default never overwrite object.";
263 "Frequency of dumping statistic information. suffix: s-seconds,\n"
264 " m-minutes, e.g.: --resp_freq=10s.";
266 case OPT_SOCK_PER_CONN
:
267 return "Number of TCP socks per concurrency. Default 1.";
271 "Reconnect support, when connection is closed it will be reconnected.";
275 "Whether it outputs detailed information when verification fails.";
277 case OPT_FACEBOOK_TEST
:
279 "Whether it enables facebook test feature, set with TCP and multi-get with UDP.";
281 case OPT_BINARY_PROTOCOL
:
283 "Whether it enables binary protocol. Default with ASCII protocol.";
286 return "Expected throughput, suffix: K, e.g.: --tps=10k.";
288 case OPT_REP_WRITE_SRV
:
289 return "The first nth servers can write data, e.g.: --rep_write=2.";
292 return "Forgot to document this option :)";
294 } /* ms_lookup_help */
298 * output the help information
300 * @param command_name, the string of this process
301 * @param description, description of this process
302 * @param long_options, global options array
304 void ms_help_command(const char *command_name
, const char *description
)
306 char *help_message
= NULL
;
308 printf("%s v%u.%u\n", command_name
, 1U, 0U);
309 printf(" %s\n\n", description
);
312 " memslap -hV | -s servers [-F config_file] [-t time | -x exe_num] [...]\n\n"
315 for (int x
= 0; long_options
[x
].name
; x
++)
317 printf(" -%c, --%s%c\n", long_options
[x
].val
, long_options
[x
].name
,
318 long_options
[x
].has_arg
? '=' : ' ');
320 if ((help_message
= (char *)ms_lookup_help(long_options
[x
].val
)) != NULL
)
322 printf(" %s\n", help_message
);
328 " memslap -s 127.0.0.1:11211 -S 5s\n"
329 " memslap -s 127.0.0.1:11211 -t 2m -v 0.2 -e 0.05 -b\n"
330 " memslap -s 127.0.0.1:11211 -F config -t 2m -w 40k -S 20s -o 0.2\n"
331 " memslap -s 127.0.0.1:11211 -F config -t 2m -T 4 -c 128 -d 20 -P 40k\n"
332 " memslap -s 127.0.0.1:11211 -F config -t 2m -d 50 -a -n 40\n"
333 " memslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m\n"
334 " memslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m -p 2\n\n");
337 } /* ms_help_command */
340 /* used to parse the time string */
341 static int64_t ms_parse_time()
344 char unit
= optarg
[strlen(optarg
) - 1];
346 optarg
[strlen(optarg
) - 1]= '\0';
373 } /* ms_parse_time */
376 /* used to parse the size string */
377 static int64_t ms_parse_size()
380 char unit
= optarg
[strlen(optarg
) - 1];
382 optarg
[strlen(optarg
) - 1]= '\0';
383 ret
= strtoll(optarg
, (char **)NULL
, 10);
399 ret
*= 1024 * 1024 * 1024;
408 } /* ms_parse_size */
411 /* used to parse the options of command line */
412 static void ms_options_parse(int argc
, char *argv
[])
417 while ((option_rv
= getopt_long(argc
, argv
, "VhURbaBs:x:T:c:X:v:d:"
418 "t:S:F:w:e:o:n:P:p:",
419 long_options
, &option_index
)) != -1)
426 case OPT_VERSION
: /* --version or -V */
427 ms_version_command(PROGRAM_NAME
);
430 case OPT_HELP
: /* --help or -h */
431 ms_help_command(PROGRAM_NAME
, PROGRAM_DESCRIPTION
);
434 case OPT_SERVERS
: /* --servers or -s */
435 ms_setting
.srv_str
= strdup(optarg
);
438 case OPT_CONCURRENCY
: /* --concurrency or -c */
439 ms_setting
.nconns
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
440 if (ms_setting
.nconns
<= 0)
442 fprintf(stderr
, "Concurrency must be greater than 0.:-)\n");
447 case OPT_EXECUTE_NUMBER
: /* --execute_number or -x */
448 ms_setting
.exec_num
= (int)strtol(optarg
, (char **) NULL
, 10);
449 if (ms_setting
.exec_num
<= 0)
451 fprintf(stderr
, "Execute number must be greater than 0.:-)\n");
456 case OPT_THREAD_NUMBER
: /* --threads or -T */
457 ms_setting
.nthreads
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
458 if (ms_setting
.nthreads
<= 0)
460 fprintf(stderr
, "Threads number must be greater than 0.:-)\n");
465 case OPT_FIXED_LTH
: /* --fixed_size or -X */
466 ms_setting
.fixed_value_size
= (size_t)strtoull(optarg
, (char **) NULL
, 10);
467 if ((ms_setting
.fixed_value_size
<= 0)
468 || (ms_setting
.fixed_value_size
> MAX_VALUE_SIZE
))
470 fprintf(stderr
, "Value size must be between 0 and 1M.:-)\n");
475 case OPT_VERIFY
: /* --verify or -v */
476 ms_setting
.verify_percent
= atof(optarg
);
477 if ((ms_setting
.verify_percent
<= 0)
478 || (ms_setting
.verify_percent
> 1.0))
480 fprintf(stderr
, "Data verification rate must be "
481 "greater than 0 and less than 1.0. :-)\n");
486 case OPT_GETS_DIVISION
: /* --division or -d */
487 ms_setting
.mult_key_num
= (int)strtol(optarg
, (char **) NULL
, 10);
488 if (ms_setting
.mult_key_num
<= 0)
490 fprintf(stderr
, "Multi-get key number must be greater than 0.:-)\n");
495 case OPT_TIME
: /* --time or -t */
496 ms_setting
.run_time
= (int)ms_parse_time();
497 if (ms_setting
.run_time
== -1)
499 fprintf(stderr
, "Please specify the run time. :-)\n"
500 "'s' for second, 'm' for minute, 'h' for hour, "
501 "'d' for day. e.g.: --time=24h (means 24 hours).\n");
505 if (ms_setting
.run_time
== 0)
507 fprintf(stderr
, "Running time can not be 0. :-)\n");
512 case OPT_CONFIG_CMD
: /* --cfg_cmd or -F */
513 ms_setting
.cfg_file
= strdup(optarg
);
516 case OPT_WINDOW_SIZE
: /* --win_size or -w */
517 ms_setting
.win_size
= (size_t)ms_parse_size();
518 if (ms_setting
.win_size
== (size_t)-1)
522 "Please specify the item window size. :-)\n"
523 "e.g.: --win_size=10k (means 10k task window size).\n");
528 case OPT_UDP
: /* --udp or -U*/
529 ms_setting
.udp
= true;
532 case OPT_EXPIRE
: /* --exp_verify or -e */
533 ms_setting
.exp_ver_per
= atof(optarg
);
534 if ((ms_setting
.exp_ver_per
<= 0) || (ms_setting
.exp_ver_per
> 1.0))
536 fprintf(stderr
, "Expire time verification rate must be "
537 "greater than 0 and less than 1.0. :-)\n");
542 case OPT_OVERWRITE
: /* --overwrite or -o */
543 ms_setting
.overwrite_percent
= atof(optarg
);
544 if ((ms_setting
.overwrite_percent
<= 0)
545 || (ms_setting
.overwrite_percent
> 1.0))
547 fprintf(stderr
, "Objects overwrite rate must be "
548 "greater than 0 and less than 1.0. :-)\n");
553 case OPT_STAT_FREQ
: /* --stat_freq or -S */
554 ms_setting
.stat_freq
= (int)ms_parse_time();
555 if (ms_setting
.stat_freq
== -1)
557 fprintf(stderr
, "Please specify the frequency of dumping "
558 "statistic information. :-)\n"
559 "'s' for second, 'm' for minute, 'h' for hour, "
560 "'d' for day. e.g.: --time=24h (means 24 hours).\n");
564 if (ms_setting
.stat_freq
== 0)
566 fprintf(stderr
, "The frequency of dumping statistic information "
567 "can not be 0. :-)\n");
572 case OPT_SOCK_PER_CONN
: /* --conn_sock or -n */
573 ms_setting
.sock_per_conn
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
574 if (ms_setting
.sock_per_conn
<= 0)
576 fprintf(stderr
, "Number of socks of each concurrency "
577 "must be greater than 0.:-)\n");
582 case OPT_RECONNECT
: /* --reconnect or -R */
583 ms_setting
.reconnect
= true;
586 case OPT_VERBOSE
: /* --verbose or -b */
587 ms_setting
.verbose
= true;
590 case OPT_FACEBOOK_TEST
: /* --facebook or -a */
591 ms_setting
.facebook_test
= true;
594 case OPT_BINARY_PROTOCOL
: /* --binary or -B */
595 ms_setting
.binary_prot_
= true;
598 case OPT_TPS
: /* --tps or -P */
599 ms_setting
.expected_tps
= (int)ms_parse_size();
600 if (ms_setting
.expected_tps
== -1)
603 "Please specify the item expected throughput. :-)\n"
604 "e.g.: --tps=10k (means 10k throughput).\n");
609 case OPT_REP_WRITE_SRV
: /* --rep_write or -p */
610 ms_setting
.rep_write_srv
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
611 if (ms_setting
.rep_write_srv
<= 0)
614 "Number of replication writing server must be greater "
621 /* getopt_long already printed an error message. */
628 } /* ms_options_parse */
631 static int ms_check_para()
633 if (ms_setting
.srv_str
== NULL
)
637 if ((temp
= getenv("MEMCACHED_SERVERS")))
639 ms_setting
.srv_str
= strdup(temp
);
643 fprintf(stderr
, "No Servers provided\n\n");
648 if (ms_setting
.nconns
% (uint32_t)ms_setting
.nthreads
!= 0)
650 fprintf(stderr
, "Concurrency must be the multiples of threads count.\n");
654 if (ms_setting
.win_size
% UNIT_ITEMS_COUNT
!= 0)
656 fprintf(stderr
, "Window size must be the multiples of 1024.\n\n");
661 } /* ms_check_para */
664 /* initialize the statistic structure */
665 static void ms_statistic_init()
667 pthread_mutex_init(&ms_statistic
.stat_mutex
, NULL
);
668 ms_init_stats(&ms_statistic
.get_stat
, "Get");
669 ms_init_stats(&ms_statistic
.set_stat
, "Set");
670 ms_init_stats(&ms_statistic
.total_stat
, "Total");
671 } /* ms_statistic_init */
674 /* initialize the global state structure */
675 static void ms_stats_init()
677 memset(&ms_stats
, 0, sizeof(ms_stats_t
));
678 if (ms_setting
.stat_freq
> 0)
682 } /* ms_stats_init */
685 /* use to output the statistic */
686 static void ms_print_statistics(int in_time
)
688 int obj_size
= (int)(ms_setting
.avg_key_size
+ ms_setting
.avg_val_size
);
690 printf("\033[1;1H\033[2J\n");
691 ms_dump_format_stats(&ms_statistic
.get_stat
, in_time
,
692 ms_setting
.stat_freq
, obj_size
);
693 ms_dump_format_stats(&ms_statistic
.set_stat
, in_time
,
694 ms_setting
.stat_freq
, obj_size
);
695 ms_dump_format_stats(&ms_statistic
.total_stat
, in_time
,
696 ms_setting
.stat_freq
, obj_size
);
697 } /* ms_print_statistics */
700 /* used to print the states of memslap */
701 static void ms_print_memslap_stats(struct timeval
*start_time
,
702 struct timeval
*end_time
)
708 sizeof(buf
), "cmd_get: %lu\n",
709 (unsigned long) ms_stats
.cmd_get
);
711 sizeof(buf
) - (size_t)(pos
-buf
),
713 (unsigned long) ms_stats
.cmd_set
);
715 sizeof(buf
) - (size_t)(pos
-buf
),
717 (unsigned long) ms_stats
.get_misses
);
719 if (ms_setting
.verify_percent
> 0)
722 sizeof(buf
) - (size_t)(pos
-buf
),
723 "verify_misses: %lu\n",
724 (unsigned long) ms_stats
.vef_miss
);
726 sizeof(buf
) - (size_t)(pos
-buf
),
727 "verify_failed: %lu\n",
728 (unsigned long) ms_stats
.vef_failed
);
731 if (ms_setting
.exp_ver_per
> 0)
734 sizeof(buf
) - (size_t)(pos
-buf
),
735 "expired_get: %lu\n",
736 (unsigned long) ms_stats
.exp_get
);
738 sizeof(buf
) - (size_t)(pos
-buf
),
739 "unexpired_unget: %lu\n",
740 (unsigned long) ms_stats
.unexp_unget
);
744 sizeof(buf
) - (size_t)(pos
-buf
),
745 "written_bytes: %lu\n",
746 (unsigned long) ms_stats
.bytes_written
);
748 sizeof(buf
) - (size_t)(pos
-buf
),
750 (unsigned long) ms_stats
.bytes_read
);
752 sizeof(buf
) - (size_t)(pos
-buf
),
753 "object_bytes: %lu\n",
754 (unsigned long) ms_stats
.obj_bytes
);
756 if (ms_setting
.udp
|| ms_setting
.facebook_test
)
759 sizeof(buf
) - (size_t)(pos
-buf
),
760 "packet_disorder: %lu\n",
761 (unsigned long) ms_stats
.pkt_disorder
);
763 sizeof(buf
) - (size_t)(pos
-buf
),
764 "packet_drop: %lu\n",
765 (unsigned long)ms_stats
.pkt_drop
);
767 sizeof(buf
) - (size_t)(pos
-buf
),
768 "udp_timeout: %lu\n",
769 (unsigned long)ms_stats
.udp_timeout
);
772 if (ms_setting
.stat_freq
> 0)
774 ms_dump_stats(&ms_statistic
.get_stat
);
775 ms_dump_stats(&ms_statistic
.set_stat
);
776 ms_dump_stats(&ms_statistic
.total_stat
);
779 int64_t time_diff
= ms_time_diff(start_time
, end_time
);
781 sizeof(buf
) - (size_t)(pos
-buf
),
782 "\nRun time: %.1fs Ops: %llu TPS: %.0Lf Net_rate: %.1fM/s\n",
783 (double)time_diff
/ 1000000,
784 (unsigned long long)(ms_stats
.cmd_get
+ ms_stats
.cmd_set
),
786 + ms_stats
.cmd_set
) / ((long double)time_diff
/ 1000000),
788 ms_stats
.bytes_written
789 + ms_stats
.bytes_read
) / 1024 / 1024
790 / ((double)time_diff
/ 1000000));
793 fprintf(stdout
, "%s", buf
);
795 } /* ms_print_memslap_stats */
798 /* the loop of the main thread, wait the work threads to complete */
799 static void ms_monitor_slap_mode()
801 struct timeval start_time
, end_time
;
803 /* Wait all the threads complete initialization. */
804 pthread_mutex_lock(&ms_global
.init_lock
.lock
);
805 while (ms_global
.init_lock
.count
< ms_setting
.nthreads
)
807 pthread_cond_wait(&ms_global
.init_lock
.cond
,
808 &ms_global
.init_lock
.lock
);
810 pthread_mutex_unlock(&ms_global
.init_lock
.lock
);
812 /* only when there is no set operation it need warm up */
813 if (ms_setting
.cmd_distr
[CMD_SET
].cmd_prop
< PROP_ERROR
)
815 /* Wait all the connects complete warm up. */
816 pthread_mutex_lock(&ms_global
.warmup_lock
.lock
);
817 while (ms_global
.warmup_lock
.count
< ms_setting
.nconns
)
819 pthread_cond_wait(&ms_global
.warmup_lock
.cond
, &ms_global
.warmup_lock
.lock
);
821 pthread_mutex_unlock(&ms_global
.warmup_lock
.lock
);
823 ms_global
.finish_warmup
= true;
825 /* running in "run time" mode, user specify run time */
826 if (ms_setting
.run_time
> 0)
829 gettimeofday(&start_time
, NULL
);
835 if ((ms_setting
.stat_freq
> 0) && (second
% ms_setting
.stat_freq
== 0)
836 && (ms_stats
.active_conns
>= ms_setting
.nconns
)
837 && (ms_stats
.active_conns
<= INT_MAX
))
839 ms_print_statistics(second
);
842 if (ms_setting
.run_time
<= second
)
844 ms_global
.time_out
= true;
848 /* all connections disconnect */
849 if ((second
> 5) && (ms_stats
.active_conns
== 0))
854 gettimeofday(&end_time
, NULL
);
855 sleep(1); /* wait all threads clean up */
859 /* running in "execute number" mode, user specify execute number */
860 gettimeofday(&start_time
, NULL
);
863 * We loop until we know that all connects have cleaned up.
865 pthread_mutex_lock(&ms_global
.run_lock
.lock
);
866 while (ms_global
.run_lock
.count
< ms_setting
.nconns
)
868 pthread_cond_wait(&ms_global
.run_lock
.cond
, &ms_global
.run_lock
.lock
);
870 pthread_mutex_unlock(&ms_global
.run_lock
.lock
);
872 gettimeofday(&end_time
, NULL
);
875 ms_print_memslap_stats(&start_time
, &end_time
);
876 } /* ms_monitor_slap_mode */
879 /* the main function */
880 int main(int argc
, char *argv
[])
882 srandom((unsigned int)time(NULL
));
883 ms_global_struct_init();
886 ms_setting_init_pre();
887 ms_options_parse(argc
, argv
);
890 ms_help_command(PROGRAM_NAME
, PROGRAM_DESCRIPTION
);
893 ms_setting_init_post();
897 /* waiting work thread complete its task */
898 ms_monitor_slap_mode();
902 ms_global_struct_destroy();
903 ms_setting_cleanup();