This commit is contained in:
charsyam 2026-05-27 01:19:30 +04:00 committed by GitHub
commit dbdb611548
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 7 deletions

View file

@ -1500,6 +1500,8 @@ void cronUpdateMemoryStats(void) {
NULL,
&server.cron_malloc_stats.allocator_muzzy,
&server.cron_malloc_stats.allocator_frag_smallbins_bytes);
getrusage(RUSAGE_SELF, &server.cron_rusage_self);
getrusage(RUSAGE_CHILDREN, &server.cron_rusage_children);
if (server.lua_arena != UINT_MAX) {
zmalloc_get_allocator_info_by_arena(server.lua_arena,
0,
@ -6324,6 +6326,7 @@ static sds sdscatHistograms(sds info, int dbnum, keysizesHist histogram, const c
* on memory corruption problems. */
sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
sds info = sdsempty();
info = sdsMakeRoomFor(info, 4096);
time_t uptime = server.unixtime-server.stat_starttime;
int j;
int sections = 0;
@ -6886,19 +6889,18 @@ sds genRedisInfoString(dict *section_dict, int all_sections, int everything) {
if (all_sections || (dictFind(section_dict,"cpu") != NULL)) {
if (sections++) info = sdscat(info,"\r\n");
struct rusage self_ru, c_ru;
getrusage(RUSAGE_SELF, &self_ru);
getrusage(RUSAGE_CHILDREN, &c_ru);
struct rusage *self_ru = &server.cron_rusage_self;
struct rusage *c_ru = &server.cron_rusage_children;
info = sdscatprintf(info,
"# CPU\r\n"
"used_cpu_sys:%ld.%06ld\r\n"
"used_cpu_user:%ld.%06ld\r\n"
"used_cpu_sys_children:%ld.%06ld\r\n"
"used_cpu_user_children:%ld.%06ld\r\n",
(long)self_ru.ru_stime.tv_sec, (long)self_ru.ru_stime.tv_usec,
(long)self_ru.ru_utime.tv_sec, (long)self_ru.ru_utime.tv_usec,
(long)c_ru.ru_stime.tv_sec, (long)c_ru.ru_stime.tv_usec,
(long)c_ru.ru_utime.tv_sec, (long)c_ru.ru_utime.tv_usec);
(long)self_ru->ru_stime.tv_sec, (long)self_ru->ru_stime.tv_usec,
(long)self_ru->ru_utime.tv_sec, (long)self_ru->ru_utime.tv_usec,
(long)c_ru->ru_stime.tv_sec, (long)c_ru->ru_stime.tv_usec,
(long)c_ru->ru_utime.tv_sec, (long)c_ru->ru_utime.tv_usec);
#ifdef RUSAGE_THREAD
struct rusage m_ru;
getrusage(RUSAGE_THREAD, &m_ru);

View file

@ -39,6 +39,7 @@
#include <sys/socket.h>
#include <lua.h>
#include <signal.h>
#include <sys/resource.h>
#ifdef HAVE_LIBSYSTEMD
#include <systemd/sd-daemon.h>
@ -2143,6 +2144,8 @@ struct redisServer {
long long stat_slowlog_time_us_sum; /* Sum of all slowlog entry durations (usec) */
long long stat_slowlog_time_us_max; /* Max slowlog entry duration (usec) */
struct malloc_stats cron_malloc_stats; /* sampled in serverCron(). */
struct rusage cron_rusage_self; /* sampled in serverCron(). */
struct rusage cron_rusage_children; /* sampled in serverCron(). */
redisAtomic long long stat_net_input_bytes; /* Bytes read from network. */
redisAtomic long long stat_net_output_bytes; /* Bytes written to network. */
redisAtomic long long stat_net_repl_input_bytes; /* Bytes read during replication, added to stat_net_input_bytes in 'info'. */