Add ZFS compressed ARC stats to top(1)
Provides: amount of compressed data logical size of compressed data (how much it would have taken uncompressed) compression ratio (logical size : total ARC size) Overhead (space consumed for compression headers) Example output: ARC: 31G Total, 18G MFU, 9067M MRU, 2236K Anon, 615M Header, 2947M Other 25G Compressed, 54G Uncompressed, 1.76:1 Ratio, 2265M Overhead Reviewed by: jpaetzel, smh, imp, jhb (previous version) MFC after: 2 week Relnotes: yes Sponsored by: ScaleEngine Inc. Differential Revision: https://reviews.freebsd.org/D9829
This commit is contained in:
parent
9dbf8c467e
commit
1dbfa4b530
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=315435
@ -69,6 +69,7 @@ static char **procstate_names;
|
||||
static char **cpustate_names;
|
||||
static char **memory_names;
|
||||
static char **arc_names;
|
||||
static char **carc_names;
|
||||
static char **swap_names;
|
||||
|
||||
static int num_procstates;
|
||||
@ -105,6 +106,8 @@ int x_mem = 5;
|
||||
int y_mem = 3;
|
||||
int x_arc = 5;
|
||||
int y_arc = 4;
|
||||
int x_carc = 5;
|
||||
int y_carc = 5;
|
||||
int x_swap = 6;
|
||||
int y_swap = 4;
|
||||
int y_message = 5;
|
||||
@ -222,6 +225,7 @@ struct statics *statics;
|
||||
lmemory = (int *)malloc(num_memory * sizeof(int));
|
||||
|
||||
arc_names = statics->arc_names;
|
||||
carc_names = statics->carc_names;
|
||||
|
||||
/* calculate starting columns where needed */
|
||||
cpustate_total_length = 0;
|
||||
@ -684,6 +688,47 @@ int *stats;
|
||||
line_update(arc_buffer, new, x_arc, y_arc);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* *_carc(stats) - print "Compressed ARC: " followed by the summary string
|
||||
*
|
||||
* Assumptions: cursor is on "lastline"
|
||||
* for i_carc ONLY: cursor is on the previous line
|
||||
*/
|
||||
char carc_buffer[MAX_COLS];
|
||||
|
||||
void
|
||||
i_carc(stats)
|
||||
|
||||
int *stats;
|
||||
|
||||
{
|
||||
if (carc_names == NULL)
|
||||
return;
|
||||
|
||||
fputs("\n ", stdout);
|
||||
lastline++;
|
||||
|
||||
/* format and print the memory summary */
|
||||
summary_format(carc_buffer, stats, carc_names);
|
||||
fputs(carc_buffer, stdout);
|
||||
}
|
||||
|
||||
void
|
||||
u_carc(stats)
|
||||
|
||||
int *stats;
|
||||
|
||||
{
|
||||
static char new[MAX_COLS];
|
||||
|
||||
if (carc_names == NULL)
|
||||
return;
|
||||
|
||||
/* format the new line */
|
||||
summary_format(new, stats, carc_names);
|
||||
line_update(carc_buffer, new, x_carc, y_carc);
|
||||
}
|
||||
|
||||
/*
|
||||
* *_swap(stats) - print "Swap: " followed by the swap summary string
|
||||
@ -1174,6 +1219,7 @@ register char **names;
|
||||
register int num;
|
||||
register char *thisname;
|
||||
register int useM = No;
|
||||
char rbuf[6];
|
||||
|
||||
/* format each number followed by its string */
|
||||
p = str;
|
||||
@ -1194,6 +1240,14 @@ register char **names;
|
||||
/* skip over the K, since it was included by format_k */
|
||||
p = strecpy(p, thisname+1);
|
||||
}
|
||||
/* is this number a ratio? */
|
||||
else if (thisname[0] == ':')
|
||||
{
|
||||
(void) snprintf(rbuf, sizeof(rbuf), "%.2f",
|
||||
(float)*(numbers - 2) / (float)num);
|
||||
p = strecpy(p, rbuf);
|
||||
p = strecpy(p, thisname);
|
||||
}
|
||||
else
|
||||
{
|
||||
p = strecpy(p, itoa(num));
|
||||
|
@ -16,6 +16,7 @@ char *cpustates_tag(void);
|
||||
void display_header(int t);
|
||||
int display_init(struct statics *statics);
|
||||
void i_arc(int *stats);
|
||||
void i_carc(int *stats);
|
||||
void i_cpustates(int *states);
|
||||
void i_loadave(int mpid, double *avenrun);
|
||||
void i_memory(int *stats);
|
||||
@ -29,6 +30,7 @@ void new_message();
|
||||
int readline(char *buffer, int size, int numeric);
|
||||
char *trim_header(char *text);
|
||||
void u_arc(int *stats);
|
||||
void u_carc(int *stats);
|
||||
void u_cpustates(int *states);
|
||||
void u_endscreen(int hi);
|
||||
void u_header(char *text);
|
||||
|
@ -21,6 +21,8 @@ extern int x_mem; /* 5 */
|
||||
extern int y_mem; /* 3 */
|
||||
extern int x_arc; /* 5 */
|
||||
extern int y_arc; /* 4 */
|
||||
extern int x_carc; /* 5 */
|
||||
extern int y_carc; /* 5 */
|
||||
extern int x_swap; /* 6 */
|
||||
extern int y_swap; /* 4 */
|
||||
extern int y_message; /* 5 */
|
||||
|
@ -21,6 +21,7 @@ struct statics
|
||||
char **cpustate_names;
|
||||
char **memory_names;
|
||||
char **arc_names;
|
||||
char **carc_names;
|
||||
char **swap_names;
|
||||
#ifdef ORDER
|
||||
char **order_names;
|
||||
@ -48,6 +49,7 @@ struct system_info
|
||||
int *cpustates;
|
||||
int *memory;
|
||||
int *arc;
|
||||
int *carc;
|
||||
int *swap;
|
||||
struct timeval boottime;
|
||||
int ncpus;
|
||||
|
@ -125,6 +125,7 @@ void (*d_procstates)() = i_procstates;
|
||||
void (*d_cpustates)() = i_cpustates;
|
||||
void (*d_memory)() = i_memory;
|
||||
void (*d_arc)() = i_arc;
|
||||
void (*d_carc)() = i_carc;
|
||||
void (*d_swap)() = i_swap;
|
||||
void (*d_message)() = i_message;
|
||||
void (*d_header)() = i_header;
|
||||
@ -658,6 +659,7 @@ char *argv[];
|
||||
/* display memory stats */
|
||||
(*d_memory)(system_info.memory);
|
||||
(*d_arc)(system_info.arc);
|
||||
(*d_carc)(system_info.carc);
|
||||
|
||||
/* display swap stats */
|
||||
(*d_swap)(system_info.swap);
|
||||
@ -724,6 +726,7 @@ char *argv[];
|
||||
d_cpustates = u_cpustates;
|
||||
d_memory = u_memory;
|
||||
d_arc = u_arc;
|
||||
d_carc = u_carc;
|
||||
d_swap = u_swap;
|
||||
d_message = u_message;
|
||||
d_header = u_header;
|
||||
@ -1190,6 +1193,7 @@ reset_display()
|
||||
d_cpustates = i_cpustates;
|
||||
d_memory = i_memory;
|
||||
d_arc = i_arc;
|
||||
d_carc = i_carc;
|
||||
d_swap = i_swap;
|
||||
d_message = i_message;
|
||||
d_header = i_header;
|
||||
|
@ -188,6 +188,12 @@ char *arcnames[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
int carc_stats[5];
|
||||
char *carcnames[] = {
|
||||
"K Compressed, ", "K Uncompressed, ", ":1 Ratio, ", "K Overhead",
|
||||
NULL
|
||||
};
|
||||
|
||||
int swap_stats[7];
|
||||
char *swapnames[] = {
|
||||
"K Total, ", "K Used, ", "K Free, ", "% Inuse, ", "K In, ", "K Out",
|
||||
@ -223,6 +229,7 @@ static long total_majflt;
|
||||
/* these are for getting the memory statistics */
|
||||
|
||||
static int arc_enabled;
|
||||
static int carc_enabled;
|
||||
static int pageshift; /* log base 2 of the pagesize */
|
||||
|
||||
/* define pagetok in terms of pageshift */
|
||||
@ -283,16 +290,18 @@ update_layout(void)
|
||||
|
||||
y_mem = 3;
|
||||
y_arc = 4;
|
||||
y_swap = 4 + arc_enabled;
|
||||
y_idlecursor = 5 + arc_enabled;
|
||||
y_message = 5 + arc_enabled;
|
||||
y_header = 6 + arc_enabled;
|
||||
y_procs = 7 + arc_enabled;
|
||||
Header_lines = 7 + arc_enabled;
|
||||
y_carc = 5;
|
||||
y_swap = 4 + arc_enabled + carc_enabled;
|
||||
y_idlecursor = 5 + arc_enabled + carc_enabled;
|
||||
y_message = 5 + arc_enabled + carc_enabled;
|
||||
y_header = 6 + arc_enabled + carc_enabled;
|
||||
y_procs = 7 + arc_enabled + carc_enabled;
|
||||
Header_lines = 7 + arc_enabled + carc_enabled;
|
||||
|
||||
if (pcpu_stats) {
|
||||
y_mem += ncpus - 1;
|
||||
y_arc += ncpus - 1;
|
||||
y_carc += ncpus - 1;
|
||||
y_swap += ncpus - 1;
|
||||
y_idlecursor += ncpus - 1;
|
||||
y_message += ncpus - 1;
|
||||
@ -319,6 +328,10 @@ machine_init(struct statics *statics, char do_unames)
|
||||
smpmode = 0;
|
||||
|
||||
size = sizeof(arc_size);
|
||||
if (sysctlbyname("vfs.zfs.compressed_arc_enabled", &arc_size, &size,
|
||||
NULL, 0) == 0 && arc_size == 1)
|
||||
carc_enabled = 1;
|
||||
size = sizeof(arc_size);
|
||||
if (sysctlbyname("kstat.zfs.misc.arcstats.size", &arc_size, &size,
|
||||
NULL, 0) == 0 && arc_size != 0)
|
||||
arc_enabled = 1;
|
||||
@ -368,6 +381,10 @@ machine_init(struct statics *statics, char do_unames)
|
||||
statics->arc_names = arcnames;
|
||||
else
|
||||
statics->arc_names = NULL;
|
||||
if (carc_enabled)
|
||||
statics->carc_names = carcnames;
|
||||
else
|
||||
statics->carc_names = NULL;
|
||||
statics->swap_names = swapnames;
|
||||
#ifdef ORDER
|
||||
statics->order_names = ordernames;
|
||||
@ -559,6 +576,16 @@ get_system_info(struct system_info *si)
|
||||
arc_stats[5] = arc_stat >> 10;
|
||||
si->arc = arc_stats;
|
||||
}
|
||||
if (carc_enabled) {
|
||||
GETSYSCTL("kstat.zfs.misc.arcstats.compressed_size", arc_stat);
|
||||
carc_stats[0] = arc_stat >> 10;
|
||||
GETSYSCTL("kstat.zfs.misc.arcstats.uncompressed_size", arc_stat);
|
||||
carc_stats[1] = arc_stat >> 10;
|
||||
carc_stats[2] = arc_stats[0]; /* ARC Total */
|
||||
GETSYSCTL("kstat.zfs.misc.arcstats.overhead_size", arc_stat);
|
||||
carc_stats[3] = arc_stat >> 10;
|
||||
si->carc = carc_stats;
|
||||
}
|
||||
|
||||
/* set arrays and strings */
|
||||
if (pcpu_stats) {
|
||||
|
Loading…
Reference in New Issue
Block a user