Fixed bug concerning redis-benchmark non clustered benchmark forcing always the same hash tag {tag} (#7931)
Adding the ":{tag}" only if --cluster is used, so that when used against a proxy it generates traffic to all shards. Co-authored-by: Oran Agra <oran@redislabs.com> (cherry picked from commit 6cf23d6610677d38e4892e02649fc2de7095274b)
This commit is contained in:
parent
30bb0dd595
commit
71c1427a1b
@ -759,7 +759,7 @@ static client createClient(char *cmd, size_t len, client from, int thread_id) {
|
|||||||
}
|
}
|
||||||
c->stagptr[c->staglen++] = p;
|
c->stagptr[c->staglen++] = p;
|
||||||
c->stagfree--;
|
c->stagfree--;
|
||||||
p += 5; /* 12 is strlen("{tag}"). */
|
p += 5; /* 5 is strlen("{tag}"). */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1515,7 +1515,7 @@ int test_is_selected(char *name) {
|
|||||||
|
|
||||||
int main(int argc, const char **argv) {
|
int main(int argc, const char **argv) {
|
||||||
int i;
|
int i;
|
||||||
char *data, *cmd;
|
char *data, *cmd, *tag;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
client c;
|
client c;
|
||||||
@ -1565,7 +1565,12 @@ int main(int argc, const char **argv) {
|
|||||||
|
|
||||||
config.latency = zmalloc(sizeof(long long)*config.requests);
|
config.latency = zmalloc(sizeof(long long)*config.requests);
|
||||||
|
|
||||||
|
tag = "";
|
||||||
|
|
||||||
if (config.cluster_mode) {
|
if (config.cluster_mode) {
|
||||||
|
// We only include the slot placeholder {tag} if cluster mode is enabled
|
||||||
|
tag = ":{tag}";
|
||||||
|
|
||||||
/* Fetch cluster configuration. */
|
/* Fetch cluster configuration. */
|
||||||
if (!fetchClusterConfiguration() || !config.cluster_nodes) {
|
if (!fetchClusterConfiguration() || !config.cluster_nodes) {
|
||||||
if (!config.hostsocket) {
|
if (!config.hostsocket) {
|
||||||
@ -1673,63 +1678,63 @@ int main(int argc, const char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("set")) {
|
if (test_is_selected("set")) {
|
||||||
len = redisFormatCommand(&cmd,"SET key:{tag}:__rand_int__ %s",data);
|
len = redisFormatCommand(&cmd,"SET key%s:__rand_int__ %s",tag,data);
|
||||||
benchmark("SET",cmd,len);
|
benchmark("SET",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("get")) {
|
if (test_is_selected("get")) {
|
||||||
len = redisFormatCommand(&cmd,"GET key:{tag}:__rand_int__");
|
len = redisFormatCommand(&cmd,"GET key%s:__rand_int__",tag);
|
||||||
benchmark("GET",cmd,len);
|
benchmark("GET",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("incr")) {
|
if (test_is_selected("incr")) {
|
||||||
len = redisFormatCommand(&cmd,"INCR counter:{tag}:__rand_int__");
|
len = redisFormatCommand(&cmd,"INCR counter%s:__rand_int__",tag);
|
||||||
benchmark("INCR",cmd,len);
|
benchmark("INCR",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("lpush")) {
|
if (test_is_selected("lpush")) {
|
||||||
len = redisFormatCommand(&cmd,"LPUSH mylist:{tag} %s",data);
|
len = redisFormatCommand(&cmd,"LPUSH mylist%s %s",tag,data);
|
||||||
benchmark("LPUSH",cmd,len);
|
benchmark("LPUSH",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("rpush")) {
|
if (test_is_selected("rpush")) {
|
||||||
len = redisFormatCommand(&cmd,"RPUSH mylist:{tag} %s",data);
|
len = redisFormatCommand(&cmd,"RPUSH mylist%s %s",tag,data);
|
||||||
benchmark("RPUSH",cmd,len);
|
benchmark("RPUSH",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("lpop")) {
|
if (test_is_selected("lpop")) {
|
||||||
len = redisFormatCommand(&cmd,"LPOP mylist:{tag}");
|
len = redisFormatCommand(&cmd,"LPOP mylist%s",tag);
|
||||||
benchmark("LPOP",cmd,len);
|
benchmark("LPOP",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("rpop")) {
|
if (test_is_selected("rpop")) {
|
||||||
len = redisFormatCommand(&cmd,"RPOP mylist:{tag}");
|
len = redisFormatCommand(&cmd,"RPOP mylist%s",tag);
|
||||||
benchmark("RPOP",cmd,len);
|
benchmark("RPOP",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("sadd")) {
|
if (test_is_selected("sadd")) {
|
||||||
len = redisFormatCommand(&cmd,
|
len = redisFormatCommand(&cmd,
|
||||||
"SADD myset:{tag} element:__rand_int__");
|
"SADD myset%s element:__rand_int__",tag);
|
||||||
benchmark("SADD",cmd,len);
|
benchmark("SADD",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("hset")) {
|
if (test_is_selected("hset")) {
|
||||||
len = redisFormatCommand(&cmd,
|
len = redisFormatCommand(&cmd,
|
||||||
"HSET myhash:{tag} element:__rand_int__ %s",data);
|
"HSET myhash%s element:__rand_int__ %s",tag,data);
|
||||||
benchmark("HSET",cmd,len);
|
benchmark("HSET",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("spop")) {
|
if (test_is_selected("spop")) {
|
||||||
len = redisFormatCommand(&cmd,"SPOP myset:{tag}");
|
len = redisFormatCommand(&cmd,"SPOP myset%s",tag);
|
||||||
benchmark("SPOP",cmd,len);
|
benchmark("SPOP",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
@ -1738,13 +1743,13 @@ int main(int argc, const char **argv) {
|
|||||||
char *score = "0";
|
char *score = "0";
|
||||||
if (config.randomkeys) score = "__rand_int__";
|
if (config.randomkeys) score = "__rand_int__";
|
||||||
len = redisFormatCommand(&cmd,
|
len = redisFormatCommand(&cmd,
|
||||||
"ZADD myzset:{tag} %s element:__rand_int__",score);
|
"ZADD myzset%s %s element:__rand_int__",tag,score);
|
||||||
benchmark("ZADD",cmd,len);
|
benchmark("ZADD",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("zpopmin")) {
|
if (test_is_selected("zpopmin")) {
|
||||||
len = redisFormatCommand(&cmd,"ZPOPMIN myzset:{tag}");
|
len = redisFormatCommand(&cmd,"ZPOPMIN myzset%s",tag);
|
||||||
benchmark("ZPOPMIN",cmd,len);
|
benchmark("ZPOPMIN",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
@ -1755,45 +1760,47 @@ int main(int argc, const char **argv) {
|
|||||||
test_is_selected("lrange_500") ||
|
test_is_selected("lrange_500") ||
|
||||||
test_is_selected("lrange_600"))
|
test_is_selected("lrange_600"))
|
||||||
{
|
{
|
||||||
len = redisFormatCommand(&cmd,"LPUSH mylist:{tag} %s",data);
|
len = redisFormatCommand(&cmd,"LPUSH mylist%s %s",tag,data);
|
||||||
benchmark("LPUSH (needed to benchmark LRANGE)",cmd,len);
|
benchmark("LPUSH (needed to benchmark LRANGE)",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("lrange") || test_is_selected("lrange_100")) {
|
if (test_is_selected("lrange") || test_is_selected("lrange_100")) {
|
||||||
len = redisFormatCommand(&cmd,"LRANGE mylist:{tag} 0 99");
|
len = redisFormatCommand(&cmd,"LRANGE mylist%s 0 99",tag);
|
||||||
benchmark("LRANGE_100 (first 100 elements)",cmd,len);
|
benchmark("LRANGE_100 (first 100 elements)",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("lrange") || test_is_selected("lrange_300")) {
|
if (test_is_selected("lrange") || test_is_selected("lrange_300")) {
|
||||||
len = redisFormatCommand(&cmd,"LRANGE mylist:{tag} 0 299");
|
len = redisFormatCommand(&cmd,"LRANGE mylist%s 0 299",tag);
|
||||||
benchmark("LRANGE_300 (first 300 elements)",cmd,len);
|
benchmark("LRANGE_300 (first 300 elements)",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("lrange") || test_is_selected("lrange_500")) {
|
if (test_is_selected("lrange") || test_is_selected("lrange_500")) {
|
||||||
len = redisFormatCommand(&cmd,"LRANGE mylist:{tag} 0 449");
|
len = redisFormatCommand(&cmd,"LRANGE mylist%s 0 449",tag);
|
||||||
benchmark("LRANGE_500 (first 450 elements)",cmd,len);
|
benchmark("LRANGE_500 (first 450 elements)",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("lrange") || test_is_selected("lrange_600")) {
|
if (test_is_selected("lrange") || test_is_selected("lrange_600")) {
|
||||||
len = redisFormatCommand(&cmd,"LRANGE mylist:{tag} 0 599");
|
len = redisFormatCommand(&cmd,"LRANGE mylist%s 0 599",tag);
|
||||||
benchmark("LRANGE_600 (first 600 elements)",cmd,len);
|
benchmark("LRANGE_600 (first 600 elements)",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_is_selected("mset")) {
|
if (test_is_selected("mset")) {
|
||||||
const char *argv[21];
|
const char *cmd_argv[21];
|
||||||
argv[0] = "MSET";
|
cmd_argv[0] = "MSET";
|
||||||
|
sds key_placeholder = sdscatprintf(sdsnew(""),"key%s:__rand_int__",tag);
|
||||||
for (i = 1; i < 21; i += 2) {
|
for (i = 1; i < 21; i += 2) {
|
||||||
argv[i] = "key:{tag}:__rand_int__";
|
cmd_argv[i] = key_placeholder;
|
||||||
argv[i+1] = data;
|
cmd_argv[i+1] = data;
|
||||||
}
|
}
|
||||||
len = redisFormatCommandArgv(&cmd,21,argv,NULL);
|
len = redisFormatCommandArgv(&cmd,21,cmd_argv,NULL);
|
||||||
benchmark("MSET (10 keys)",cmd,len);
|
benchmark("MSET (10 keys)",cmd,len);
|
||||||
free(cmd);
|
free(cmd);
|
||||||
|
sdsfree(key_placeholder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.csv) printf("\n");
|
if (!config.csv) printf("\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user