mirror of
https://github.com/fluencelabs/redis
synced 2025-03-17 16:10:50 +00:00
Cache uname() output across INFO calls.
Uname was profiled to be a slow syscall. It produces always the same output in the context of a single execution of Redis, so calling it at every INFO output generation does not make too much sense. The uname utsname structure was modified as a static variable. At the same time a static integer was added to check if we need to call uname the first time.
This commit is contained in:
parent
a9caca0424
commit
d3efe04c47
11
src/redis.c
11
src/redis.c
@ -2359,7 +2359,8 @@ sds genRedisInfoString(char *section) {
|
||||
|
||||
/* Server */
|
||||
if (allsections || defsections || !strcasecmp(section,"server")) {
|
||||
struct utsname name;
|
||||
static int call_uname = 1;
|
||||
static struct utsname name;
|
||||
char *mode;
|
||||
|
||||
if (server.cluster_enabled) mode = "cluster";
|
||||
@ -2367,7 +2368,13 @@ sds genRedisInfoString(char *section) {
|
||||
else mode = "standalone";
|
||||
|
||||
if (sections++) info = sdscat(info,"\r\n");
|
||||
uname(&name);
|
||||
|
||||
if (call_uname) {
|
||||
/* Uname can be slow and is always the same output. Cache it. */
|
||||
uname(&name);
|
||||
call_uname = 0;
|
||||
}
|
||||
|
||||
info = sdscatprintf(info,
|
||||
"# Server\r\n"
|
||||
"redis_version:%s\r\n"
|
||||
|
Loading…
x
Reference in New Issue
Block a user