提交 7054f2a0 编写于 作者: A antirez

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.
上级 7a20f096
......@@ -2236,14 +2236,21 @@ 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.sentinel_mode) mode = "sentinel";
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"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册