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 "key\n" \
39 /* Used to parse the value length return by server and path string */
40 typedef struct token_s
{
47 /* server information */
48 typedef struct mcd_sever
{
49 char srv_host_name
[MCD_HOST_LENGTH
]; /* host name of server */
50 int srv_port
; /* server port */
52 /* for calculating how long the server disconnects */
53 int disconn_cnt
; /* number of disconnections count */
54 int reconn_cnt
; /* number of reconnections count */
55 struct timeval disconn_time
; /* start time of disconnection */
56 struct timeval reconn_time
; /* end time of reconnection */
59 /* information of an item distribution including key and value */
60 typedef struct distr
{
61 size_t key_size
; /* size of key */
62 int key_offset
; /* offset of one key in character block */
63 size_t value_size
; /* size of value */
66 /* information of key distribution */
67 typedef struct key_distr
{
68 size_t start_len
; /* start of the key length range */
69 size_t end_len
; /* end of the key length range */
70 double key_prop
; /* key proportion */
73 /* information of value distribution */
74 typedef struct value_distr
{
75 size_t start_len
; /* start of the value length range */
76 size_t end_len
; /* end of the value length range */
77 double value_prop
; /* value proportion */
80 /* memcached command types */
81 typedef enum cmd_type
{
87 /* types in the configuration file */
88 typedef enum conf_type
{
95 /* information of command distribution */
96 typedef struct cmd_distr
{
97 ms_cmd_type_t cmd_type
; /* command type */
98 double cmd_prop
; /* proportion of the command */
101 /* global setting structure */
102 typedef struct setting
{
103 int ncpu
; /* cpu count of this system */
104 int nthreads
; /* total thread count, must equal or less than cpu cores */
105 int nconns
; /* total conn count, must multiply by total thread count */
106 int64_t exec_num
; /* total execute number */
107 int run_time
; /* total run time */
109 uint32_t char_blk_size
; /* global character block size */
110 char *char_block
; /* global character block with random character */
111 ms_distr_t
*distr
; /* distribution from configure file */
113 char *srv_str
; /* string includes servers information */
114 char *cfg_file
; /* configure file name */
116 ms_mcd_server_t
*servers
; /* servers array */
117 int total_srv_cnt
; /* total servers count of the servers array */
118 int srv_cnt
; /* servers count */
120 ms_key_distr_t
*key_distr
; /* array of key distribution */
121 int total_key_rng_cnt
; /* total key range count of the array */
122 int key_rng_cnt
; /* actual key range count */
124 ms_value_distr_t
*value_distr
; /* array of value distribution */
125 int total_val_rng_cnt
; /* total value range count of the array */
126 int val_rng_cnt
; /* actual value range count */
128 ms_cmd_distr_t cmd_distr
[CMD_NULL
];/* total we have CMD_NULL commands */
129 int cmd_used_count
; /* supported command count */
131 size_t fixed_value_size
; /* fixed value size */
132 size_t avg_val_size
; /* average value size */
133 size_t avg_key_size
; /* average value size */
135 double verify_percent
; /* percent of data verification */
136 double exp_ver_per
; /* percent of data verification with expire time */
137 double overwrite_percent
; /* percent of overwrite */
138 int mult_key_num
; /* number of keys used by multi-get once */
139 size_t win_size
; /* item window size per connection */
140 bool udp
; /* whether or not use UDP */
141 int stat_freq
; /* statistic frequency second */
142 bool reconnect
; /* whether it reconnect when connection close */
143 bool verbose
; /* whether it outputs detailed information when verification */
144 bool facebook_test
; /* facebook test, TCP set and multi-get with UDP */
145 int sock_per_conn
; /* number of socks per connection structure */
146 bool binary_prot
; /* whether it use binary protocol */
147 int expected_tps
; /* expected throughput */
148 int rep_write_srv
; /* which servers are used to do replication writing */
151 extern ms_setting_t ms_setting
;
153 /* previous part of initialization of setting structure */
154 void ms_setting_init_pre(void);
156 /* post part of initialization of setting structure */
157 void ms_setting_init_post(void);
159 /* clean up the global setting structure */
160 void ms_setting_cleanup(void);
162 #define UNUSED_ARGUMENT(x) (void)x
168 #endif /* end of MS_SETTING_H */