3 * Author: Mingqiang Zhuang
5 * Created on February 10, 2009
7 * (c) Copyright 2009, Schooner Information Technology, Inc.
8 * http://www.schoonerinfotech.com/
14 #include "ms_memslap.h"
20 #define MCD_SRVS_NUM_INIT 8
21 #define MCD_HOST_LENGTH 64
22 #define KEY_RANGE_COUNT_INIT 8
23 #define VALUE_RANGE_COUNT_INIT 8
24 #define PROP_ERROR 0.001
26 #define MIN_KEY_SIZE 16
27 #define MAX_KEY_SIZE 250
28 #define MAX_VALUE_SIZE (1024 * 1024)
30 /* the content of the configuration file for memslap running without configuration file */
31 #define DEFAULT_CONGIF_STR \
40 /* Used to parse the value length return by server and path string */
41 typedef struct token_s
49 /* server information */
50 typedef struct mcd_sever
52 char srv_host_name
[MCD_HOST_LENGTH
]; /* host name of server */
53 int srv_port
; /* server port */
55 /* for calculating how long the server disconnects */
56 volatile uint32_t disconn_cnt
; /* number of disconnections count */
57 volatile uint32_t reconn_cnt
; /* number of reconnections count */
58 struct timeval disconn_time
; /* start time of disconnection */
59 struct timeval reconn_time
; /* end time of reconnection */
62 /* information of an item distribution including key and value */
65 size_t key_size
; /* size of key */
66 int key_offset
; /* offset of one key in character block */
67 size_t value_size
; /* size of value */
70 /* information of key distribution */
71 typedef struct key_distr
73 size_t start_len
; /* start of the key length range */
74 size_t end_len
; /* end of the key length range */
75 double key_prop
; /* key proportion */
78 /* information of value distribution */
79 typedef struct value_distr
81 size_t start_len
; /* start of the value length range */
82 size_t end_len
; /* end of the value length range */
83 double value_prop
; /* value proportion */
86 /* memcached command types */
94 /* types in the configuration file */
95 typedef enum conf_type
103 /* information of command distribution */
104 typedef struct cmd_distr
106 ms_cmd_type_t cmd_type
; /* command type */
107 double cmd_prop
; /* proportion of the command */
110 /* global setting structure */
111 typedef struct setting
113 uint32_t ncpu
; /* cpu count of this system */
114 uint32_t nthreads
; /* total thread count, must equal or less than cpu cores */
115 uint32_t nconns
; /* total conn count, must multiply by total thread count */
116 int64_t exec_num
; /* total execute number */
117 int run_time
; /* total run time */
119 uint32_t char_blk_size
; /* global character block size */
120 char *char_block
; /* global character block with random character */
121 ms_distr_t
*distr
; /* distribution from configure file */
123 char *srv_str
; /* string includes servers information */
124 char *cfg_file
; /* configure file name */
126 ms_mcd_server_t
*servers
; /* servers array */
127 uint32_t total_srv_cnt
; /* total servers count of the servers array */
128 uint32_t srv_cnt
; /* servers count */
130 ms_key_distr_t
*key_distr
; /* array of key distribution */
131 int total_key_rng_cnt
; /* total key range count of the array */
132 int key_rng_cnt
; /* actual key range count */
134 ms_value_distr_t
*value_distr
; /* array of value distribution */
135 int total_val_rng_cnt
; /* total value range count of the array */
136 int val_rng_cnt
; /* actual value range count */
138 ms_cmd_distr_t cmd_distr
[CMD_NULL
]; /* total we have CMD_NULL commands */
139 int cmd_used_count
; /* supported command count */
141 size_t fixed_value_size
; /* fixed value size */
142 size_t avg_val_size
; /* average value size */
143 size_t avg_key_size
; /* average value size */
145 double verify_percent
; /* percent of data verification */
146 double exp_ver_per
; /* percent of data verification with expire time */
147 double overwrite_percent
; /* percent of overwrite */
148 int mult_key_num
; /* number of keys used by multi-get once */
149 size_t win_size
; /* item window size per connection */
150 bool udp
; /* whether or not use UDP */
151 int stat_freq
; /* statistic frequency second */
152 bool reconnect
; /* whether it reconnect when connection close */
153 bool verbose
; /* whether it outputs detailed information when verification */
154 bool facebook_test
; /* facebook test, TCP set and multi-get with UDP */
155 uint32_t sock_per_conn
; /* number of socks per connection structure */
156 bool binary_prot
; /* whether it use binary protocol */
157 int expected_tps
; /* expected throughput */
158 uint32_t rep_write_srv
; /* which servers are used to do replication writing */
161 extern ms_setting_st ms_setting
;
163 /* previous part of initialization of setting structure */
164 void ms_setting_init_pre(void);
167 /* post part of initialization of setting structure */
168 void ms_setting_init_post(void);
171 /* clean up the global setting structure */
172 void ms_setting_cleanup(void);
175 #define UNUSED_ARGUMENT(x) (void)x
181 #endif /* end of MS_SETTING_H */