mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Speedup INFO server section.
This commit is contained in:
parent
f49f0a6f72
commit
758b39be99
@ -32,6 +32,7 @@
|
||||
* files using this functions. */
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "release.h"
|
||||
#include "version.h"
|
||||
@ -50,3 +51,16 @@ uint64_t redisBuildId(void) {
|
||||
|
||||
return crc64(0,(unsigned char*)buildid,strlen(buildid));
|
||||
}
|
||||
|
||||
/* Return a cached value of the build string in order to avoid recomputing
|
||||
* and converting it in hex every time: this string is shown in the INFO
|
||||
* output that should be fast. */
|
||||
char *redisBuildIdString(void) {
|
||||
static char buf[32];
|
||||
static int cached = 0;
|
||||
if (!cached) {
|
||||
snprintf(buf,sizeof(buf),"%llx",(unsigned long long) redisBuildId());
|
||||
cached = 1;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
34
src/server.c
34
src/server.c
@ -3892,32 +3892,32 @@ sds genRedisInfoString(char *section) {
|
||||
call_uname = 0;
|
||||
}
|
||||
|
||||
info = sdscatprintf(info,
|
||||
info = sdscatfmt(info,
|
||||
"# Server\r\n"
|
||||
"redis_version:%s\r\n"
|
||||
"redis_git_sha1:%s\r\n"
|
||||
"redis_git_dirty:%d\r\n"
|
||||
"redis_build_id:%llx\r\n"
|
||||
"redis_git_dirty:%i\r\n"
|
||||
"redis_build_id:%s\r\n"
|
||||
"redis_mode:%s\r\n"
|
||||
"os:%s %s %s\r\n"
|
||||
"arch_bits:%d\r\n"
|
||||
"arch_bits:%i\r\n"
|
||||
"multiplexing_api:%s\r\n"
|
||||
"atomicvar_api:%s\r\n"
|
||||
"gcc_version:%d.%d.%d\r\n"
|
||||
"process_id:%ld\r\n"
|
||||
"gcc_version:%i.%i.%i\r\n"
|
||||
"process_id:%I\r\n"
|
||||
"run_id:%s\r\n"
|
||||
"tcp_port:%d\r\n"
|
||||
"uptime_in_seconds:%jd\r\n"
|
||||
"uptime_in_days:%jd\r\n"
|
||||
"hz:%d\r\n"
|
||||
"configured_hz:%d\r\n"
|
||||
"lru_clock:%ld\r\n"
|
||||
"tcp_port:%i\r\n"
|
||||
"uptime_in_seconds:%I\r\n"
|
||||
"uptime_in_days:%I\r\n"
|
||||
"hz:%i\r\n"
|
||||
"configured_hz:%i\r\n"
|
||||
"lru_clock:%u\r\n"
|
||||
"executable:%s\r\n"
|
||||
"config_file:%s\r\n",
|
||||
REDIS_VERSION,
|
||||
redisGitSHA1(),
|
||||
strtol(redisGitDirty(),NULL,10) > 0,
|
||||
(unsigned long long) redisBuildId(),
|
||||
redisBuildIdString(),
|
||||
mode,
|
||||
name.sysname, name.release, name.machine,
|
||||
server.arch_bits,
|
||||
@ -3928,14 +3928,14 @@ sds genRedisInfoString(char *section) {
|
||||
#else
|
||||
0,0,0,
|
||||
#endif
|
||||
(long) getpid(),
|
||||
(int64_t) getpid(),
|
||||
server.runid,
|
||||
server.port,
|
||||
(intmax_t)uptime,
|
||||
(intmax_t)(uptime/(3600*24)),
|
||||
(int64_t)uptime,
|
||||
(int64_t)(uptime/(3600*24)),
|
||||
server.hz,
|
||||
server.config_hz,
|
||||
(unsigned long) server.lruclock,
|
||||
server.lruclock,
|
||||
server.executable ? server.executable : "",
|
||||
server.configfile ? server.configfile : "");
|
||||
}
|
||||
|
@ -2140,6 +2140,7 @@ void dictSdsDestructor(void *privdata, void *val);
|
||||
char *redisGitSHA1(void);
|
||||
char *redisGitDirty(void);
|
||||
uint64_t redisBuildId(void);
|
||||
char *redisBuildIdString(void);
|
||||
|
||||
/* Commands prototypes */
|
||||
void authCommand(client *c);
|
||||
|
Loading…
Reference in New Issue
Block a user