Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
c6f20e47
Commit
c6f20e47
authored
Aug 08, 2014
by
arianna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Varnishstat hitrate implementation
parent
6699df59
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
6 deletions
+76
-6
varnishstat_curses.c
bin/varnishstat/varnishstat_curses.c
+76
-6
No files found.
bin/varnishstat/varnishstat_curses.c
View file @
c6f20e47
...
@@ -91,6 +91,15 @@ struct pt {
...
@@ -91,6 +91,15 @@ struct pt {
struct
ma
ma_10
,
ma_100
,
ma_1000
;
struct
ma
ma_10
,
ma_100
,
ma_1000
;
};
};
struct
hitrate
{
double
lt
;
uint64_t
lhit
,
lmiss
;
struct
ma
hr_10
;
struct
ma
hr_100
;
struct
ma
hr_1000
;
};
static
struct
hitrate
hitrate
;
static
VTAILQ_HEAD
(,
pt
)
ptlist
=
VTAILQ_HEAD_INITIALIZER
(
ptlist
);
static
VTAILQ_HEAD
(,
pt
)
ptlist
=
VTAILQ_HEAD_INITIALIZER
(
ptlist
);
static
int
n_ptlist
=
0
;
static
int
n_ptlist
=
0
;
static
int
n_ptarray
=
0
;
static
int
n_ptarray
=
0
;
...
@@ -118,6 +127,19 @@ static int sample = 0;
...
@@ -118,6 +127,19 @@ static int sample = 0;
static
double
t_sample
=
0
.;
static
double
t_sample
=
0
.;
static
double
interval
=
1
.;
static
double
interval
=
1
.;
static
void
init_hitrate
(
void
)
{
memset
(
&
hitrate
,
0
,
sizeof
(
struct
hitrate
));
if
(
VSC_C_main
!=
NULL
)
{
hitrate
.
lhit
=
VSC_C_main
->
cache_hit
;
hitrate
.
lmiss
=
VSC_C_main
->
cache_miss
;
}
hitrate
.
hr_10
.
nmax
=
10
;
hitrate
.
hr_100
.
nmax
=
100
;
hitrate
.
hr_1000
.
nmax
=
1000
;
}
static
void
static
void
update_ma
(
struct
ma
*
ma
,
double
val
)
update_ma
(
struct
ma
*
ma
,
double
val
)
{
{
...
@@ -348,10 +370,6 @@ sample_points(void)
...
@@ -348,10 +370,6 @@ sample_points(void)
{
{
struct
pt
*
pt
;
struct
pt
*
pt
;
t_sample
=
VTIM_mono
();
sample
=
0
;
redraw
=
1
;
VTAILQ_FOREACH
(
pt
,
&
ptlist
,
list
)
{
VTAILQ_FOREACH
(
pt
,
&
ptlist
,
list
)
{
AN
(
pt
->
vpt
);
AN
(
pt
->
vpt
);
AN
(
pt
->
ptr
);
AN
(
pt
->
ptr
);
...
@@ -389,6 +407,46 @@ sample_points(void)
...
@@ -389,6 +407,46 @@ sample_points(void)
}
}
}
}
static
void
sample_hitrate
(
void
)
{
double
tv
,
dt
;
double
hr
,
mr
,
ratio
;
uint64_t
hit
,
miss
;
if
(
VSC_C_mgt
==
NULL
)
return
;
tv
=
VTIM_mono
();
dt
=
tv
-
hitrate
.
lt
;
hitrate
.
lt
=
tv
;
hit
=
VSC_C_main
->
cache_hit
;
miss
=
VSC_C_main
->
cache_miss
;
hr
=
(
hit
-
hitrate
.
lhit
)
/
dt
;
mr
=
(
miss
-
hitrate
.
lmiss
)
/
dt
;
hitrate
.
lhit
=
hit
;
hitrate
.
lmiss
=
miss
;
if
(
hr
+
mr
!=
0
)
ratio
=
hr
/
(
hr
+
mr
);
else
ratio
=
0
;
update_ma
(
&
hitrate
.
hr_10
,
ratio
);
update_ma
(
&
hitrate
.
hr_100
,
ratio
);
update_ma
(
&
hitrate
.
hr_1000
,
ratio
);
}
static
void
sample_data
(
void
)
{
t_sample
=
VTIM_mono
();
sample
=
0
;
redraw
=
1
;
sample_points
();
sample_hitrate
();
}
static
void
static
void
make_windows
(
void
)
make_windows
(
void
)
{
{
...
@@ -489,8 +547,18 @@ draw_status(void)
...
@@ -489,8 +547,18 @@ draw_status(void)
AN
(
w_status
);
AN
(
w_status
);
werase
(
w_status
);
werase
(
w_status
);
if
(
VSC_C_mgt
!=
NULL
)
if
(
VSC_C_mgt
!=
NULL
)
{
up_mgt
=
VSC_C_mgt
->
uptime
;
up_mgt
=
VSC_C_mgt
->
uptime
;
if
(
COLS
>
70
)
{
mvwprintw
(
w_status
,
0
,
(
getmaxx
(
w_status
)
-
37
),
"Hitrate n: %8u %8u %8u"
,
hitrate
.
hr_10
.
n
,
hitrate
.
hr_100
.
n
,
hitrate
.
hr_1000
.
n
);
mvwprintw
(
w_status
,
1
,
(
getmaxx
(
w_status
)
-
37
),
" avg(n): %8.4f %8.4f %8.4f"
,
hitrate
.
hr_10
.
acc
,
hitrate
.
hr_100
.
acc
,
hitrate
.
hr_1000
.
acc
);
}
}
if
(
VSC_C_main
!=
NULL
)
if
(
VSC_C_main
!=
NULL
)
up_chld
=
VSC_C_main
->
uptime
;
up_chld
=
VSC_C_main
->
uptime
;
...
@@ -866,8 +934,10 @@ do_curses(struct VSM_data *vd, int delay)
...
@@ -866,8 +934,10 @@ do_curses(struct VSM_data *vd, int delay)
VSC_C_mgt
=
VSC_Mgt
(
vd
,
&
f_mgt
);
VSC_C_mgt
=
VSC_Mgt
(
vd
,
&
f_mgt
);
VSC_C_main
=
VSC_Main
(
vd
,
&
f_main
);
VSC_C_main
=
VSC_Main
(
vd
,
&
f_main
);
init_hitrate
();
while
(
keep_running
)
{
while
(
keep_running
)
{
if
(
VSM_Abandoned
(
vd
))
{
if
(
VSM_Abandoned
(
vd
))
{
init_hitrate
();
delete_pt_list
();
delete_pt_list
();
VSM_Close
(
vd
);
VSM_Close
(
vd
);
VSM_Open
(
vd
);
VSM_Open
(
vd
);
...
@@ -881,7 +951,7 @@ do_curses(struct VSM_data *vd, int delay)
...
@@ -881,7 +951,7 @@ do_curses(struct VSM_data *vd, int delay)
if
(
now
-
t_sample
>
interval
)
if
(
now
-
t_sample
>
interval
)
sample
=
1
;
sample
=
1
;
if
(
sample
)
if
(
sample
)
sample_
points
();
sample_
data
();
if
(
rebuild
)
if
(
rebuild
)
build_pt_array
();
build_pt_array
();
if
(
redraw
)
if
(
redraw
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment