Skip to content

Commit 9d7ede3

Browse files
committed
Version 1.2.2
* Add --key-pattern=P:P * Add -n allkeys
1 parent 1f5be4c commit 9d7ede3

File tree

5 files changed

+44
-15
lines changed

5 files changed

+44
-15
lines changed

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Version 1.2.2
2+
* Add --key-pattern=P:P
3+
* Add -n allkeys
4+
15
* Version 1.2.1
26
* Add --distinct-client-seed
37

client.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,17 @@ bool client::setup_client(benchmark_config *config, abstract_protocol *protocol,
133133
m_obj_gen = objgen->clone();
134134
assert(m_obj_gen != NULL);
135135
if (config->distinct_client_seed)
136-
m_obj_gen->set_random_seed(config->distinct_client_seed++);
136+
m_obj_gen->set_random_seed(config->next_client_idx);
137+
if (config->key_pattern[0]=='P')
138+
{
139+
int range = (config->key_maximum - config->key_minimum)/(config->clients*config->threads) + 1;
140+
int min = config->key_minimum + range*config->next_client_idx;
141+
int max = min+range;
142+
if(config->next_client_idx==(int)(config->clients*config->threads)-1)
143+
max = config->key_maximum; //the last clients takes the leftover
144+
m_obj_gen->set_key_range(min, max);
145+
}
146+
config->next_client_idx++;
137147

138148
m_keylist = new keylist(m_config->multi_key_get + 1);
139149
assert(m_keylist != NULL);

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dnl You should have received a copy of the GNU General Public License
1616
dnl along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
AC_PREREQ(2.59)
19-
AC_INIT(memtier_benchmark,1.2.1,[email protected])
19+
AC_INIT(memtier_benchmark,1.2.2,[email protected])
2020
AC_CONFIG_SRCDIR([memtier_benchmark.cpp])
2121
AC_CONFIG_HEADER([config.h])
2222
AM_INIT_AUTOMAKE

memtier_benchmark.cpp

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ static void config_init_defaults(struct benchmark_config *cfg)
166166
cfg->protocol = "redis";
167167
if (!cfg->run_count)
168168
cfg->run_count = 1;
169-
if (!cfg->requests && !cfg->test_time)
170-
cfg->requests = 10000;
171169
if (!cfg->clients)
172170
cfg->clients = 50;
173171
if (!cfg->threads)
@@ -188,6 +186,14 @@ static void config_init_defaults(struct benchmark_config *cfg)
188186
cfg->key_pattern = "R:R";
189187
if (!cfg->data_size_pattern)
190188
cfg->data_size_pattern = "R";
189+
if (cfg->requests == (unsigned int)-1) {
190+
cfg->requests = cfg->key_maximum - cfg->key_minimum;
191+
if (strcmp(cfg->key_pattern, "P:P")==0)
192+
cfg->requests = cfg->requests / (cfg->clients * cfg->threads) + 1;
193+
printf("setting requests to %d\n", cfg->requests);
194+
}
195+
if (!cfg->requests && !cfg->test_time)
196+
cfg->requests = 10000;
191197
}
192198

193199
static int config_parse_args(int argc, char *argv[], struct benchmark_config *cfg)
@@ -334,14 +340,18 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
334340
break;
335341
case 'n':
336342
endptr = NULL;
337-
cfg->requests = (unsigned int) strtoul(optarg, &endptr, 10);
338-
if (!cfg->requests || !endptr || *endptr != '\0') {
339-
fprintf(stderr, "error: requests must be greater than zero.\n");
340-
return -1;
341-
}
342-
if (cfg->test_time) {
343-
fprintf(stderr, "error: --test-time and --requests are mutually exclusive.\n");
344-
return -1;
343+
if (strcmp(optarg, "allkeys")==0)
344+
cfg->requests = -1;
345+
else {
346+
cfg->requests = (unsigned int) strtoul(optarg, &endptr, 10);
347+
if (!cfg->requests || !endptr || *endptr != '\0') {
348+
fprintf(stderr, "error: requests must be greater than zero.\n");
349+
return -1;
350+
}
351+
if (cfg->test_time) {
352+
fprintf(stderr, "error: --test-time and --requests are mutually exclusive.\n");
353+
return -1;
354+
}
345355
}
346356
break;
347357
case 'c':
@@ -483,8 +493,8 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
483493
case o_key_pattern:
484494
cfg->key_pattern = optarg;
485495
if (strlen(cfg->key_pattern) != 3 || cfg->key_pattern[1] != ':' ||
486-
(cfg->key_pattern[0] != 'R' && cfg->key_pattern[0] != 'S' && cfg->key_pattern[0] != 'G') ||
487-
(cfg->key_pattern[2] != 'R' && cfg->key_pattern[2] != 'S' && cfg->key_pattern[2] != 'G')) {
496+
(cfg->key_pattern[0] != 'R' && cfg->key_pattern[0] != 'S' && cfg->key_pattern[0] != 'G' && cfg->key_pattern[0] != 'P') ||
497+
(cfg->key_pattern[2] != 'R' && cfg->key_pattern[2] != 'S' && cfg->key_pattern[2] != 'G' && cfg->key_pattern[2] != 'P')) {
488498
fprintf(stderr, "error: key-pattern must be in the format of [S/R/G]:[S/R/G].\n");
489499
return -1;
490500
}
@@ -550,6 +560,7 @@ void usage() {
550560
"\n"
551561
"Test Options:\n"
552562
" -n, --requests=NUMBER Number of total requests per client (default: 10000)\n"
563+
" use 'allkeys' to run on the entire key-range\n"
553564
" -c, --clients=NUMBER Number of clients per thread (default: 50)\n"
554565
" -t, --threads=NUMBER Number of threads (default: 4)\n"
555566
" --test-time=SECS Number of seconds to run the test\n"
@@ -587,7 +598,10 @@ void usage() {
587598
" --key-minimum=NUMBER Key ID minimum value (default: 0)\n"
588599
" --key-maximum=NUMBER Key ID maximum value (default: 10000000)\n"
589600
" --key-pattern=PATTERN Set:Get pattern (default: R:R)\n"
590-
" G for Gaussian distribution, R for uniform Random, S for Sequential\n"
601+
" G for Gaussian distribution.\n"
602+
" R for uniform Random.\n"
603+
" S for Sequential.\n"
604+
" P for Parallel (Sequential were each client has a subset of the key-range).\n"
591605
" --key-stddev The standard deviation used in the Gaussian distribution\n"
592606
" (default is key range / 6)\n"
593607
" --key-median The median point used in the Gaussian distribution\n"

memtier_benchmark.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ struct benchmark_config {
4343
int show_config;
4444
int hide_histogram;
4545
int distinct_client_seed;
46+
int next_client_idx;
4647
unsigned int requests;
4748
unsigned int clients;
4849
unsigned int threads;

0 commit comments

Comments
 (0)