Client side caching: redis-cli ability to enable tracking.
This is extremely useful in order to simulate an high load of requests about different keys, and force Redis to track a lot of informations about several clients, to simulate real world workloads.
This commit is contained in:
parent
436d02dd7b
commit
09c06698e9
@ -104,6 +104,7 @@ static struct config {
|
|||||||
int is_fetching_slots;
|
int is_fetching_slots;
|
||||||
int is_updating_slots;
|
int is_updating_slots;
|
||||||
int slots_last_update;
|
int slots_last_update;
|
||||||
|
int enable_tracking;
|
||||||
/* Thread mutexes to be used as fallbacks by atomicvar.h */
|
/* Thread mutexes to be used as fallbacks by atomicvar.h */
|
||||||
pthread_mutex_t requests_issued_mutex;
|
pthread_mutex_t requests_issued_mutex;
|
||||||
pthread_mutex_t requests_finished_mutex;
|
pthread_mutex_t requests_finished_mutex;
|
||||||
@ -255,7 +256,7 @@ static redisConfig *getRedisConfig(const char *ip, int port,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config.auth){
|
if(config.auth) {
|
||||||
void *authReply = NULL;
|
void *authReply = NULL;
|
||||||
redisAppendCommand(c, "AUTH %s", config.auth);
|
redisAppendCommand(c, "AUTH %s", config.auth);
|
||||||
if (REDIS_OK != redisGetReply(c, &authReply)) goto fail;
|
if (REDIS_OK != redisGetReply(c, &authReply)) goto fail;
|
||||||
@ -633,6 +634,14 @@ static client createClient(char *cmd, size_t len, client from, int thread_id) {
|
|||||||
c->prefix_pending++;
|
c->prefix_pending++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.enable_tracking) {
|
||||||
|
char *buf = NULL;
|
||||||
|
int len = redisFormatCommand(&buf, "CLIENT TRACKING on");
|
||||||
|
c->obuf = sdscatlen(c->obuf, buf, len);
|
||||||
|
free(buf);
|
||||||
|
c->prefix_pending++;
|
||||||
|
}
|
||||||
|
|
||||||
/* If a DB number different than zero is selected, prefix our request
|
/* If a DB number different than zero is selected, prefix our request
|
||||||
* buffer with the SELECT command, that will be discarded the first
|
* buffer with the SELECT command, that will be discarded the first
|
||||||
* time the replies are received, so if the client is reused the
|
* time the replies are received, so if the client is reused the
|
||||||
@ -1350,6 +1359,8 @@ int parseOptions(int argc, const char **argv) {
|
|||||||
} else if (config.num_threads < 0) config.num_threads = 0;
|
} else if (config.num_threads < 0) config.num_threads = 0;
|
||||||
} else if (!strcmp(argv[i],"--cluster")) {
|
} else if (!strcmp(argv[i],"--cluster")) {
|
||||||
config.cluster_mode = 1;
|
config.cluster_mode = 1;
|
||||||
|
} else if (!strcmp(argv[i],"--enable-tracking")) {
|
||||||
|
config.enable_tracking = 1;
|
||||||
} else if (!strcmp(argv[i],"--help")) {
|
} else if (!strcmp(argv[i],"--help")) {
|
||||||
exit_status = 0;
|
exit_status = 0;
|
||||||
goto usage;
|
goto usage;
|
||||||
@ -1380,6 +1391,7 @@ usage:
|
|||||||
" --dbnum <db> SELECT the specified db number (default 0)\n"
|
" --dbnum <db> SELECT the specified db number (default 0)\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"
|
||||||
|
" --enable-tracking Send CLIENT TRACKING on before starting benchmark.\n"
|
||||||
" -k <boolean> 1=keep alive 0=reconnect (default 1)\n"
|
" -k <boolean> 1=keep alive 0=reconnect (default 1)\n"
|
||||||
" -r <keyspacelen> Use random keys for SET/GET/INCR, random values for SADD\n"
|
" -r <keyspacelen> Use random keys for SET/GET/INCR, random values for SADD\n"
|
||||||
" Using this option the benchmark will expand the string __rand_int__\n"
|
" Using this option the benchmark will expand the string __rand_int__\n"
|
||||||
@ -1504,6 +1516,7 @@ int main(int argc, const char **argv) {
|
|||||||
config.is_fetching_slots = 0;
|
config.is_fetching_slots = 0;
|
||||||
config.is_updating_slots = 0;
|
config.is_updating_slots = 0;
|
||||||
config.slots_last_update = 0;
|
config.slots_last_update = 0;
|
||||||
|
config.enable_tracking = 0;
|
||||||
|
|
||||||
i = parseOptions(argc,argv);
|
i = parseOptions(argc,argv);
|
||||||
argc -= i;
|
argc -= i;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user