Skip to content

Commit

Permalink
Version 1.2.2
Browse files Browse the repository at this point in the history
* Add --key-pattern=P:P
* Add -n allkeys
  • Loading branch information
oranagra committed Dec 8, 2014
1 parent 1f5be4c commit 9d7ede3
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Version 1.2.2
* Add --key-pattern=P:P
* Add -n allkeys

* Version 1.2.1
* Add --distinct-client-seed

Expand Down
12 changes: 11 additions & 1 deletion client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,17 @@ bool client::setup_client(benchmark_config *config, abstract_protocol *protocol,
m_obj_gen = objgen->clone();
assert(m_obj_gen != NULL);
if (config->distinct_client_seed)
m_obj_gen->set_random_seed(config->distinct_client_seed++);
m_obj_gen->set_random_seed(config->next_client_idx);
if (config->key_pattern[0]=='P')
{
int range = (config->key_maximum - config->key_minimum)/(config->clients*config->threads) + 1;
int min = config->key_minimum + range*config->next_client_idx;
int max = min+range;
if(config->next_client_idx==(int)(config->clients*config->threads)-1)
max = config->key_maximum; //the last clients takes the leftover
m_obj_gen->set_key_range(min, max);
}
config->next_client_idx++;

m_keylist = new keylist(m_config->multi_key_get + 1);
assert(m_keylist != NULL);
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dnl You should have received a copy of the GNU General Public License
dnl along with this program. If not, see <http://www.gnu.org/licenses/>.

AC_PREREQ(2.59)
AC_INIT(memtier_benchmark,1.2.1,[email protected])
AC_INIT(memtier_benchmark,1.2.2,[email protected])
AC_CONFIG_SRCDIR([memtier_benchmark.cpp])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE
Expand Down
40 changes: 27 additions & 13 deletions memtier_benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,6 @@ static void config_init_defaults(struct benchmark_config *cfg)
cfg->protocol = "redis";
if (!cfg->run_count)
cfg->run_count = 1;
if (!cfg->requests && !cfg->test_time)
cfg->requests = 10000;
if (!cfg->clients)
cfg->clients = 50;
if (!cfg->threads)
Expand All @@ -188,6 +186,14 @@ static void config_init_defaults(struct benchmark_config *cfg)
cfg->key_pattern = "R:R";
if (!cfg->data_size_pattern)
cfg->data_size_pattern = "R";
if (cfg->requests == (unsigned int)-1) {
cfg->requests = cfg->key_maximum - cfg->key_minimum;
if (strcmp(cfg->key_pattern, "P:P")==0)
cfg->requests = cfg->requests / (cfg->clients * cfg->threads) + 1;
printf("setting requests to %d\n", cfg->requests);
}
if (!cfg->requests && !cfg->test_time)
cfg->requests = 10000;
}

static int config_parse_args(int argc, char *argv[], struct benchmark_config *cfg)
Expand Down Expand Up @@ -334,14 +340,18 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
break;
case 'n':
endptr = NULL;
cfg->requests = (unsigned int) strtoul(optarg, &endptr, 10);
if (!cfg->requests || !endptr || *endptr != '\0') {
fprintf(stderr, "error: requests must be greater than zero.\n");
return -1;
}
if (cfg->test_time) {
fprintf(stderr, "error: --test-time and --requests are mutually exclusive.\n");
return -1;
if (strcmp(optarg, "allkeys")==0)
cfg->requests = -1;
else {
cfg->requests = (unsigned int) strtoul(optarg, &endptr, 10);
if (!cfg->requests || !endptr || *endptr != '\0') {
fprintf(stderr, "error: requests must be greater than zero.\n");
return -1;
}
if (cfg->test_time) {
fprintf(stderr, "error: --test-time and --requests are mutually exclusive.\n");
return -1;
}
}
break;
case 'c':
Expand Down Expand Up @@ -483,8 +493,8 @@ static int config_parse_args(int argc, char *argv[], struct benchmark_config *cf
case o_key_pattern:
cfg->key_pattern = optarg;
if (strlen(cfg->key_pattern) != 3 || cfg->key_pattern[1] != ':' ||
(cfg->key_pattern[0] != 'R' && cfg->key_pattern[0] != 'S' && cfg->key_pattern[0] != 'G') ||
(cfg->key_pattern[2] != 'R' && cfg->key_pattern[2] != 'S' && cfg->key_pattern[2] != 'G')) {
(cfg->key_pattern[0] != 'R' && cfg->key_pattern[0] != 'S' && cfg->key_pattern[0] != 'G' && cfg->key_pattern[0] != 'P') ||
(cfg->key_pattern[2] != 'R' && cfg->key_pattern[2] != 'S' && cfg->key_pattern[2] != 'G' && cfg->key_pattern[2] != 'P')) {
fprintf(stderr, "error: key-pattern must be in the format of [S/R/G]:[S/R/G].\n");
return -1;
}
Expand Down Expand Up @@ -550,6 +560,7 @@ void usage() {
"\n"
"Test Options:\n"
" -n, --requests=NUMBER Number of total requests per client (default: 10000)\n"
" use 'allkeys' to run on the entire key-range\n"
" -c, --clients=NUMBER Number of clients per thread (default: 50)\n"
" -t, --threads=NUMBER Number of threads (default: 4)\n"
" --test-time=SECS Number of seconds to run the test\n"
Expand Down Expand Up @@ -587,7 +598,10 @@ void usage() {
" --key-minimum=NUMBER Key ID minimum value (default: 0)\n"
" --key-maximum=NUMBER Key ID maximum value (default: 10000000)\n"
" --key-pattern=PATTERN Set:Get pattern (default: R:R)\n"
" G for Gaussian distribution, R for uniform Random, S for Sequential\n"
" G for Gaussian distribution.\n"
" R for uniform Random.\n"
" S for Sequential.\n"
" P for Parallel (Sequential were each client has a subset of the key-range).\n"
" --key-stddev The standard deviation used in the Gaussian distribution\n"
" (default is key range / 6)\n"
" --key-median The median point used in the Gaussian distribution\n"
Expand Down
1 change: 1 addition & 0 deletions memtier_benchmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct benchmark_config {
int show_config;
int hide_histogram;
int distinct_client_seed;
int next_client_idx;
unsigned int requests;
unsigned int clients;
unsigned int threads;
Expand Down

0 comments on commit 9d7ede3

Please sign in to comment.