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 /* global structure */
36 ms_global_t ms_global
;
38 /* global stats information structure */
41 /* global statistic structure */
42 ms_statistic_t ms_statistic
;
44 #define PROGRAM_NAME "memaslap"
45 #define PROGRAM_DESCRIPTION \
46 "Generates workload against memcached servers."
49 /* For some odd reason the option struct on solaris defines the argument
50 * as char* and not const char*
52 #define OPTIONSTRING char*
54 #define OPTIONSTRING const char*
58 static struct option long_options
[]=
60 { (OPTIONSTRING
)"servers", required_argument
, NULL
,
62 { (OPTIONSTRING
)"threads", required_argument
, NULL
,
64 { (OPTIONSTRING
)"concurrency", required_argument
, NULL
,
66 { (OPTIONSTRING
)"conn_sock", required_argument
, NULL
,
68 { (OPTIONSTRING
)"execute_number", required_argument
, NULL
,
70 { (OPTIONSTRING
)"time", required_argument
, NULL
,
72 { (OPTIONSTRING
)"cfg_cmd", required_argument
, NULL
,
74 { (OPTIONSTRING
)"win_size", required_argument
, NULL
,
76 { (OPTIONSTRING
)"fixed_size", required_argument
, NULL
,
78 { (OPTIONSTRING
)"verify", required_argument
, NULL
,
80 { (OPTIONSTRING
)"division", required_argument
, NULL
,
82 { (OPTIONSTRING
)"stat_freq", required_argument
, NULL
,
84 { (OPTIONSTRING
)"exp_verify", required_argument
, NULL
,
86 { (OPTIONSTRING
)"overwrite", required_argument
, NULL
,
88 { (OPTIONSTRING
)"reconnect", no_argument
, NULL
,
90 { (OPTIONSTRING
)"udp", no_argument
, NULL
,
92 { (OPTIONSTRING
)"facebook", no_argument
, NULL
,
94 { (OPTIONSTRING
)"binary", no_argument
, NULL
,
95 OPT_BINARY_PROTOCOL
},
96 { (OPTIONSTRING
)"tps", required_argument
, NULL
,
98 { (OPTIONSTRING
)"rep_write", required_argument
, NULL
,
100 { (OPTIONSTRING
)"verbose", no_argument
, NULL
,
102 { (OPTIONSTRING
)"help", no_argument
, NULL
,
104 { (OPTIONSTRING
)"version", no_argument
, NULL
,
110 static void ms_sync_lock_init(void);
111 static void ms_sync_lock_destroy(void);
112 static void ms_global_struct_init(void);
113 static void ms_global_struct_destroy(void);
114 static void ms_version_command(const char *command_name
);
115 static const char *ms_lookup_help(ms_options_t option
);
116 static int64_t ms_parse_time(void);
117 static int64_t ms_parse_size(void);
118 static void ms_options_parse(int argc
, char *argv
[]);
119 static int ms_check_para(void);
120 static void ms_statistic_init(void);
121 static void ms_stats_init(void);
122 static void ms_print_statistics(int in_time
);
123 static void ms_print_memaslap_stats(struct timeval
*start_time
,
124 struct timeval
*end_time
);
125 static void ms_monitor_slap_mode(void);
128 * output the help information
130 * @param command_name, the string of this process
131 * @param description, description of this process
132 * @param long_options, global options array
134 static void ms_help_command(const char *command_name
, const char *description
)
136 char *help_message
= NULL
;
138 printf("%s v%u.%u\n", command_name
, 1U, 0U);
139 printf(" %s\n\n", description
);
142 " memaslap -hV | -s servers [-F config_file] [-t time | -x exe_num] [...]\n\n"
145 for (int x
= 0; long_options
[x
].name
; x
++)
147 printf(" -%c, --%s%c\n", long_options
[x
].val
, long_options
[x
].name
,
148 long_options
[x
].has_arg
? '=' : ' ');
150 if ((help_message
= (char *)ms_lookup_help(long_options
[x
].val
)) != NULL
)
152 printf(" %s\n", help_message
);
158 " memaslap -s 127.0.0.1:11211 -S 5s\n"
159 " memaslap -s 127.0.0.1:11211 -t 2m -v 0.2 -e 0.05 -b\n"
160 " memaslap -s 127.0.0.1:11211 -F config -t 2m -w 40k -S 20s -o 0.2\n"
161 " memaslap -s 127.0.0.1:11211 -F config -t 2m -T 4 -c 128 -d 20 -P 40k\n"
162 " memaslap -s 127.0.0.1:11211 -F config -t 2m -d 50 -a -n 40\n"
163 " memaslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m\n"
164 " memaslap -s 127.0.0.1:11211,127.0.0.1:11212 -F config -t 2m -p 2\n\n");
165 } /* ms_help_command */
168 /* initialize the global locks */
169 static void ms_sync_lock_init()
171 ms_global
.init_lock
.count
= 0;
172 pthread_mutex_init(&ms_global
.init_lock
.lock
, NULL
);
173 pthread_cond_init(&ms_global
.init_lock
.cond
, NULL
);
175 ms_global
.warmup_lock
.count
= 0;
176 pthread_mutex_init(&ms_global
.warmup_lock
.lock
, NULL
);
177 pthread_cond_init(&ms_global
.warmup_lock
.cond
, NULL
);
179 ms_global
.run_lock
.count
= 0;
180 pthread_mutex_init(&ms_global
.run_lock
.lock
, NULL
);
181 pthread_cond_init(&ms_global
.run_lock
.cond
, NULL
);
183 pthread_mutex_init(&ms_global
.quit_mutex
, NULL
);
184 pthread_mutex_init(&ms_global
.seq_mutex
, NULL
);
185 } /* ms_sync_lock_init */
188 /* destroy the global locks */
189 static void ms_sync_lock_destroy()
191 pthread_mutex_destroy(&ms_global
.init_lock
.lock
);
192 pthread_cond_destroy(&ms_global
.init_lock
.cond
);
194 pthread_mutex_destroy(&ms_global
.warmup_lock
.lock
);
195 pthread_cond_destroy(&ms_global
.warmup_lock
.cond
);
197 pthread_mutex_destroy(&ms_global
.run_lock
.lock
);
198 pthread_cond_destroy(&ms_global
.run_lock
.cond
);
200 pthread_mutex_destroy(&ms_global
.quit_mutex
);
201 pthread_mutex_destroy(&ms_global
.seq_mutex
);
203 if (ms_setting
.stat_freq
> 0)
205 pthread_mutex_destroy(&ms_statistic
.stat_mutex
);
207 } /* ms_sync_lock_destroy */
210 /* initialize the global structure */
211 static void ms_global_struct_init()
214 ms_global
.finish_warmup
= false;
215 ms_global
.time_out
= false;
219 /* destroy the global structure */
220 static void ms_global_struct_destroy()
222 ms_sync_lock_destroy();
227 * output the version information
229 * @param command_name, the string of this process
231 static void ms_version_command(const char *command_name
)
233 printf("%s v%u.%u\n", command_name
, 1U, 0U);
239 * get the description of the option
241 * @param option, option of command line
243 * @return char*, description of the command option
245 static const char *ms_lookup_help(ms_options_t option
)
251 "List one or more servers to connect. Servers count must be less than\n"
252 " threads count. e.g.: --servers=localhost:1234,localhost:11211";
255 return "Display the version of the application and then exit.";
258 return "Display this message and then exit.";
260 case OPT_EXECUTE_NUMBER
:
261 return "Number of operations(get and set) to execute for the\n"
262 " given test. Default 1000000.";
264 case OPT_THREAD_NUMBER
:
266 "Number of threads to startup, better equal to CPU numbers. Default 8.";
268 case OPT_CONCURRENCY
:
269 return "Number of concurrency to simulate with load. Default 128.";
272 return "Fixed length of value.";
275 return "The proportion of date verification, e.g.: --verify=0.01";
277 case OPT_GETS_DIVISION
:
278 return "Number of keys to multi-get once. Default 1, means single get.";
282 "How long the test to run, suffix: s-seconds, m-minutes, h-hours,\n"
283 " d-days e.g.: --time=2h.";
287 "Load the configure file to get command,key and value distribution list.";
289 case OPT_WINDOW_SIZE
:
291 "Task window size of each concurrency, suffix: K, M e.g.: --win_size=10k.\n"
296 "UDP support, by default memaslap uses TCP; TCP port and UDP port of\n"
297 " server must be same.";
301 "The proportion of objects with expire time, e.g.: --exp_verify=0.01.\n"
302 " Default no object with expire time";
306 "The proportion of objects need overwrite, e.g.: --overwrite=0.01.\n"
307 " Default never overwrite object.";
311 "Frequency of dumping statistic information. suffix: s-seconds,\n"
312 " m-minutes, e.g.: --resp_freq=10s.";
314 case OPT_SOCK_PER_CONN
:
315 return "Number of TCP socks per concurrency. Default 1.";
319 "Reconnect support, when connection is closed it will be reconnected.";
323 "Whether it outputs detailed information when verification fails.";
325 case OPT_FACEBOOK_TEST
:
327 "Whether it enables facebook test feature, set with TCP and multi-get with UDP.";
329 case OPT_BINARY_PROTOCOL
:
331 "Whether it enables binary protocol. Default with ASCII protocol.";
334 return "Expected throughput, suffix: K, e.g.: --tps=10k.";
336 case OPT_REP_WRITE_SRV
:
337 return "The first nth servers can write data, e.g.: --rep_write=2.";
340 return "Forgot to document this option :)";
342 } /* ms_lookup_help */
345 /* used to parse the time string */
346 static int64_t ms_parse_time()
349 char unit
= optarg
[strlen(optarg
) - 1];
351 optarg
[strlen(optarg
) - 1]= '\0';
378 } /* ms_parse_time */
381 /* used to parse the size string */
382 static int64_t ms_parse_size()
385 char unit
= optarg
[strlen(optarg
) - 1];
387 optarg
[strlen(optarg
) - 1]= '\0';
389 ret
= strtoll(optarg
, (char **)NULL
, 10);
392 fprintf(stderr
, "strtoll(optarg,..): %s\n", strerror(errno
));
410 ret
*= 1024 * 1024 * 1024;
419 } /* ms_parse_size */
422 /* used to parse the options of command line */
423 static void ms_options_parse(int argc
, char *argv
[])
428 while ((option_rv
= getopt_long(argc
, argv
, "VhURbaBs:x:T:c:X:v:d:"
429 "t:S:F:w:e:o:n:P:p:",
430 long_options
, &option_index
)) != -1)
437 case OPT_VERSION
: /* --version or -V */
438 ms_version_command(PROGRAM_NAME
);
441 case OPT_HELP
: /* --help or -h */
442 ms_help_command(PROGRAM_NAME
, PROGRAM_DESCRIPTION
);
446 case OPT_SERVERS
: /* --servers or -s */
447 ms_setting
.srv_str
= strdup(optarg
);
450 case OPT_CONCURRENCY
: /* --concurrency or -c */
452 ms_setting
.nconns
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
453 if (ms_setting
.nconns
<= 0 || errno
!= 0)
455 fprintf(stderr
, "Concurrency must be greater than 0.:-)\n");
460 case OPT_EXECUTE_NUMBER
: /* --execute_number or -x */
462 ms_setting
.exec_num
= (int)strtol(optarg
, (char **) NULL
, 10);
463 if (ms_setting
.exec_num
<= 0 || errno
!= 0)
465 fprintf(stderr
, "Execute number must be greater than 0.:-)\n");
470 case OPT_THREAD_NUMBER
: /* --threads or -T */
472 ms_setting
.nthreads
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
473 if (ms_setting
.nthreads
<= 0 || errno
!= 0)
475 fprintf(stderr
, "Threads number must be greater than 0.:-)\n");
480 case OPT_FIXED_LTH
: /* --fixed_size or -X */
482 ms_setting
.fixed_value_size
= (size_t)strtoull(optarg
, (char **) NULL
, 10);
483 if ((ms_setting
.fixed_value_size
<= 0 || errno
!= 0)
484 || (ms_setting
.fixed_value_size
> MAX_VALUE_SIZE
))
486 fprintf(stderr
, "Value size must be between 0 and 1M.:-)\n");
491 case OPT_VERIFY
: /* --verify or -v */
492 ms_setting
.verify_percent
= atof(optarg
);
493 if ((ms_setting
.verify_percent
<= 0)
494 || (ms_setting
.verify_percent
> 1.0))
496 fprintf(stderr
, "Data verification rate must be "
497 "greater than 0 and less than 1.0. :-)\n");
502 case OPT_GETS_DIVISION
: /* --division or -d */
504 ms_setting
.mult_key_num
= (int)strtol(optarg
, (char **) NULL
, 10);
505 if (ms_setting
.mult_key_num
<= 0 || errno
!= 0)
507 fprintf(stderr
, "Multi-get key number must be greater than 0.:-)\n");
512 case OPT_TIME
: /* --time or -t */
513 ms_setting
.run_time
= (int)ms_parse_time();
514 if (ms_setting
.run_time
== -1)
516 fprintf(stderr
, "Please specify the run time. :-)\n"
517 "'s' for second, 'm' for minute, 'h' for hour, "
518 "'d' for day. e.g.: --time=24h (means 24 hours).\n");
522 if (ms_setting
.run_time
== 0)
524 fprintf(stderr
, "Running time can not be 0. :-)\n");
529 case OPT_CONFIG_CMD
: /* --cfg_cmd or -F */
530 ms_setting
.cfg_file
= strdup(optarg
);
533 case OPT_WINDOW_SIZE
: /* --win_size or -w */
534 ms_setting
.win_size
= (size_t)ms_parse_size();
535 if (ms_setting
.win_size
== (size_t)-1)
539 "Please specify the item window size. :-)\n"
540 "e.g.: --win_size=10k (means 10k task window size).\n");
545 case OPT_UDP
: /* --udp or -U*/
546 ms_setting
.udp
= true;
549 case OPT_EXPIRE
: /* --exp_verify or -e */
550 ms_setting
.exp_ver_per
= atof(optarg
);
551 if ((ms_setting
.exp_ver_per
<= 0) || (ms_setting
.exp_ver_per
> 1.0))
553 fprintf(stderr
, "Expire time verification rate must be "
554 "greater than 0 and less than 1.0. :-)\n");
559 case OPT_OVERWRITE
: /* --overwrite or -o */
560 ms_setting
.overwrite_percent
= atof(optarg
);
561 if ((ms_setting
.overwrite_percent
<= 0)
562 || (ms_setting
.overwrite_percent
> 1.0))
564 fprintf(stderr
, "Objects overwrite rate must be "
565 "greater than 0 and less than 1.0. :-)\n");
570 case OPT_STAT_FREQ
: /* --stat_freq or -S */
571 ms_setting
.stat_freq
= (int)ms_parse_time();
572 if (ms_setting
.stat_freq
== -1)
574 fprintf(stderr
, "Please specify the frequency of dumping "
575 "statistic information. :-)\n"
576 "'s' for second, 'm' for minute, 'h' for hour, "
577 "'d' for day. e.g.: --time=24h (means 24 hours).\n");
581 if (ms_setting
.stat_freq
== 0)
583 fprintf(stderr
, "The frequency of dumping statistic information "
584 "can not be 0. :-)\n");
589 case OPT_SOCK_PER_CONN
: /* --conn_sock or -n */
591 ms_setting
.sock_per_conn
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
592 if (ms_setting
.sock_per_conn
<= 0 || errno
!= 0)
594 fprintf(stderr
, "Number of socks of each concurrency "
595 "must be greater than 0.:-)\n");
600 case OPT_RECONNECT
: /* --reconnect or -R */
601 ms_setting
.reconnect
= true;
604 case OPT_VERBOSE
: /* --verbose or -b */
605 ms_setting
.verbose
= true;
608 case OPT_FACEBOOK_TEST
: /* --facebook or -a */
609 ms_setting
.facebook_test
= true;
612 case OPT_BINARY_PROTOCOL
: /* --binary or -B */
613 ms_setting
.binary_prot_
= true;
616 case OPT_TPS
: /* --tps or -P */
617 ms_setting
.expected_tps
= (int)ms_parse_size();
618 if (ms_setting
.expected_tps
== -1)
621 "Please specify the item expected throughput. :-)\n"
622 "e.g.: --tps=10k (means 10k throughput).\n");
627 case OPT_REP_WRITE_SRV
: /* --rep_write or -p */
629 ms_setting
.rep_write_srv
= (uint32_t)strtoul(optarg
, (char **) NULL
, 10);
630 if (ms_setting
.rep_write_srv
<= 0 || errno
!= 0)
633 "Number of replication writing server must be greater "
640 /* getopt_long already printed an error message. */
647 } /* ms_options_parse */
650 static int ms_check_para()
652 if (ms_setting
.srv_str
== NULL
)
656 if ((temp
= getenv("MEMCACHED_SERVERS")))
658 ms_setting
.srv_str
= strdup(temp
);
662 fprintf(stderr
, "No servers provided\n\n");
667 if (ms_setting
.nconns
% (uint32_t)ms_setting
.nthreads
!= 0)
669 fprintf(stderr
, "Concurrency must be the multiples of threads count.\n");
673 if (ms_setting
.win_size
% UNIT_ITEMS_COUNT
!= 0)
675 fprintf(stderr
, "Window size must be the multiples of 1024.\n\n");
680 } /* ms_check_para */
683 /* initialize the statistic structure */
684 static void ms_statistic_init()
686 pthread_mutex_init(&ms_statistic
.stat_mutex
, NULL
);
687 ms_init_stats(&ms_statistic
.get_stat
, "Get");
688 ms_init_stats(&ms_statistic
.set_stat
, "Set");
689 ms_init_stats(&ms_statistic
.total_stat
, "Total");
690 } /* ms_statistic_init */
693 /* initialize the global state structure */
694 static void ms_stats_init()
696 memset(&ms_stats
, 0, sizeof(ms_stats_t
));
697 if (ms_setting
.stat_freq
> 0)
701 } /* ms_stats_init */
704 /* use to output the statistic */
705 static void ms_print_statistics(int in_time
)
707 int obj_size
= (int)(ms_setting
.avg_key_size
+ ms_setting
.avg_val_size
);
709 printf("\033[1;1H\033[2J\n");
710 ms_dump_format_stats(&ms_statistic
.get_stat
, in_time
,
711 ms_setting
.stat_freq
, obj_size
);
712 ms_dump_format_stats(&ms_statistic
.set_stat
, in_time
,
713 ms_setting
.stat_freq
, obj_size
);
714 ms_dump_format_stats(&ms_statistic
.total_stat
, in_time
,
715 ms_setting
.stat_freq
, obj_size
);
716 } /* ms_print_statistics */
719 /* used to print the states of memaslap */
720 static void ms_print_memaslap_stats(struct timeval
*start_time
,
721 struct timeval
*end_time
)
727 sizeof(buf
), "cmd_get: %lu\n",
728 (unsigned long) ms_stats
.cmd_get
);
730 sizeof(buf
) - (size_t)(pos
-buf
),
732 (unsigned long) ms_stats
.cmd_set
);
734 sizeof(buf
) - (size_t)(pos
-buf
),
736 (unsigned long) ms_stats
.get_misses
);
738 if (ms_setting
.verify_percent
> 0)
741 sizeof(buf
) - (size_t)(pos
-buf
),
742 "verify_misses: %lu\n",
743 (unsigned long) ms_stats
.vef_miss
);
745 sizeof(buf
) - (size_t)(pos
-buf
),
746 "verify_failed: %lu\n",
747 (unsigned long) ms_stats
.vef_failed
);
750 if (ms_setting
.exp_ver_per
> 0)
753 sizeof(buf
) - (size_t)(pos
-buf
),
754 "expired_get: %lu\n",
755 (unsigned long) ms_stats
.exp_get
);
757 sizeof(buf
) - (size_t)(pos
-buf
),
758 "unexpired_unget: %lu\n",
759 (unsigned long) ms_stats
.unexp_unget
);
763 sizeof(buf
) - (size_t)(pos
-buf
),
764 "written_bytes: %lu\n",
765 (unsigned long) ms_stats
.bytes_written
);
767 sizeof(buf
) - (size_t)(pos
-buf
),
769 (unsigned long) ms_stats
.bytes_read
);
771 sizeof(buf
) - (size_t)(pos
-buf
),
772 "object_bytes: %lu\n",
773 (unsigned long) ms_stats
.obj_bytes
);
775 if (ms_setting
.udp
|| ms_setting
.facebook_test
)
778 sizeof(buf
) - (size_t)(pos
-buf
),
779 "packet_disorder: %lu\n",
780 (unsigned long) ms_stats
.pkt_disorder
);
782 sizeof(buf
) - (size_t)(pos
-buf
),
783 "packet_drop: %lu\n",
784 (unsigned long)ms_stats
.pkt_drop
);
786 sizeof(buf
) - (size_t)(pos
-buf
),
787 "udp_timeout: %lu\n",
788 (unsigned long)ms_stats
.udp_timeout
);
791 if (ms_setting
.stat_freq
> 0)
793 ms_dump_stats(&ms_statistic
.get_stat
);
794 ms_dump_stats(&ms_statistic
.set_stat
);
795 ms_dump_stats(&ms_statistic
.total_stat
);
798 int64_t time_diff
= ms_time_diff(start_time
, end_time
);
800 sizeof(buf
) - (size_t)(pos
-buf
),
801 "\nRun time: %.1fs Ops: %llu TPS: %.0Lf Net_rate: %.1fM/s\n",
802 (double)time_diff
/ 1000000,
803 (unsigned long long)(ms_stats
.cmd_get
+ ms_stats
.cmd_set
),
805 + ms_stats
.cmd_set
) / ((long double)time_diff
/ 1000000),
807 ms_stats
.bytes_written
808 + ms_stats
.bytes_read
) / 1024 / 1024
809 / ((double)time_diff
/ 1000000));
810 assert(pos
<= (buf
+ sizeof(buf
)));
812 fwrite(buf
, 1, pos
- buf
, stdout
);
814 } /* ms_print_memaslap_stats */
817 /* the loop of the main thread, wait the work threads to complete */
818 static void ms_monitor_slap_mode()
820 struct timeval start_time
, end_time
;
822 /* Wait all the threads complete initialization. */
823 pthread_mutex_lock(&ms_global
.init_lock
.lock
);
824 while (ms_global
.init_lock
.count
< ms_setting
.nthreads
)
826 pthread_cond_wait(&ms_global
.init_lock
.cond
,
827 &ms_global
.init_lock
.lock
);
829 pthread_mutex_unlock(&ms_global
.init_lock
.lock
);
831 /* only when there is no set operation it need warm up */
832 if (ms_setting
.cmd_distr
[CMD_SET
].cmd_prop
< PROP_ERROR
)
834 /* Wait all the connects complete warm up. */
835 pthread_mutex_lock(&ms_global
.warmup_lock
.lock
);
836 while (ms_global
.warmup_lock
.count
< ms_setting
.nconns
)
838 pthread_cond_wait(&ms_global
.warmup_lock
.cond
, &ms_global
.warmup_lock
.lock
);
840 pthread_mutex_unlock(&ms_global
.warmup_lock
.lock
);
842 ms_global
.finish_warmup
= true;
844 /* running in "run time" mode, user specify run time */
845 if (ms_setting
.run_time
> 0)
848 gettimeofday(&start_time
, NULL
);
854 if ((ms_setting
.stat_freq
> 0) && (second
% ms_setting
.stat_freq
== 0)
855 && (ms_stats
.active_conns
>= ms_setting
.nconns
)
856 && (ms_stats
.active_conns
<= INT_MAX
))
858 ms_print_statistics(second
);
861 if (ms_setting
.run_time
<= second
)
863 ms_global
.time_out
= true;
867 /* all connections disconnect */
868 if ((second
> 5) && (ms_stats
.active_conns
== 0))
873 gettimeofday(&end_time
, NULL
);
874 sleep(1); /* wait all threads clean up */
878 /* running in "execute number" mode, user specify execute number */
879 gettimeofday(&start_time
, NULL
);
882 * We loop until we know that all connects have cleaned up.
884 pthread_mutex_lock(&ms_global
.run_lock
.lock
);
885 while (ms_global
.run_lock
.count
< ms_setting
.nconns
)
887 pthread_cond_wait(&ms_global
.run_lock
.cond
, &ms_global
.run_lock
.lock
);
889 pthread_mutex_unlock(&ms_global
.run_lock
.lock
);
891 gettimeofday(&end_time
, NULL
);
894 ms_print_memaslap_stats(&start_time
, &end_time
);
895 } /* ms_monitor_slap_mode */
898 /* the main function */
899 int main(int argc
, char *argv
[])
901 srandom((unsigned int)time(NULL
));
902 ms_global_struct_init();
905 ms_setting_init_pre();
906 ms_options_parse(argc
, argv
);
909 ms_help_command(PROGRAM_NAME
, PROGRAM_DESCRIPTION
);
912 ms_setting_init_post();
916 /* waiting work thread complete its task */
917 ms_monitor_slap_mode();
921 ms_global_struct_destroy();
922 ms_setting_cleanup();