Unverified Commit 9f30dd03 authored by filipe oliveira's avatar filipe oliveira Committed by GitHub
Browse files

Enable redis-benchmark to use RESP3 protocol mode (#10335)

Adds `-3` option to cause redis-benchmark to send a `HELLO 3`
to it can benchmark the effects of RESP3 on the server.
parent 35fccd87
...@@ -125,6 +125,7 @@ static struct config { ...@@ -125,6 +125,7 @@ static struct config {
int enable_tracking; int enable_tracking;
pthread_mutex_t liveclients_mutex; pthread_mutex_t liveclients_mutex;
pthread_mutex_t is_updating_slots_mutex; pthread_mutex_t is_updating_slots_mutex;
int resp3; /* use RESP3 */
} config; } config;
typedef struct _client { typedef struct _client {
...@@ -751,6 +752,15 @@ static client createClient(char *cmd, size_t len, client from, int thread_id) { ...@@ -751,6 +752,15 @@ static client createClient(char *cmd, size_t len, client from, int thread_id) {
(int)sdslen(config.input_dbnumstr),config.input_dbnumstr); (int)sdslen(config.input_dbnumstr),config.input_dbnumstr);
c->prefix_pending++; c->prefix_pending++;
} }
if (config.resp3) {
char *buf = NULL;
int len = redisFormatCommand(&buf, "HELLO 3");
c->obuf = sdscatlen(c->obuf, buf, len);
free(buf);
c->prefix_pending++;
}
c->prefixlen = sdslen(c->obuf); c->prefixlen = sdslen(c->obuf);
/* Append the request itself. */ /* Append the request itself. */
if (from) { if (from) {
...@@ -1443,6 +1453,8 @@ int parseOptions(int argc, char **argv) { ...@@ -1443,6 +1453,8 @@ int parseOptions(int argc, char **argv) {
} else if (!strcmp(argv[i],"-u") && !lastarg) { } else if (!strcmp(argv[i],"-u") && !lastarg) {
parseRedisUri(argv[++i],"redis-benchmark",&config.conn_info,&config.tls); parseRedisUri(argv[++i],"redis-benchmark",&config.conn_info,&config.tls);
config.input_dbnumstr = sdsfromlonglong(config.conn_info.input_dbnum); config.input_dbnumstr = sdsfromlonglong(config.conn_info.input_dbnum);
} else if (!strcmp(argv[i],"-3")) {
config.resp3 = 1;
} else if (!strcmp(argv[i],"-d")) { } else if (!strcmp(argv[i],"-d")) {
if (lastarg) goto invalid; if (lastarg) goto invalid;
config.datasize = atoi(argv[++i]); config.datasize = atoi(argv[++i]);
...@@ -1569,6 +1581,7 @@ usage: ...@@ -1569,6 +1581,7 @@ usage:
" -n <requests> Total number of requests (default 100000)\n" " -n <requests> Total number of requests (default 100000)\n"
" -d <size> Data size of SET/GET value in bytes (default 3)\n" " -d <size> Data size of SET/GET value in bytes (default 3)\n"
" --dbnum <db> SELECT the specified db number (default 0)\n" " --dbnum <db> SELECT the specified db number (default 0)\n"
" -3 Start session in RESP3 protocol mode.\n"
" --threads <num> Enable multi-thread mode.\n" " --threads <num> Enable multi-thread mode.\n"
" --cluster Enable cluster mode.\n" " --cluster Enable cluster mode.\n"
" If the command is supplied on the command line in cluster\n" " If the command is supplied on the command line in cluster\n"
...@@ -1742,6 +1755,7 @@ int main(int argc, char **argv) { ...@@ -1742,6 +1755,7 @@ int main(int argc, char **argv) {
config.is_updating_slots = 0; config.is_updating_slots = 0;
config.slots_last_update = 0; config.slots_last_update = 0;
config.enable_tracking = 0; config.enable_tracking = 0;
config.resp3 = 0;
i = parseOptions(argc,argv); i = parseOptions(argc,argv);
argc -= i; argc -= i;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment