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
46dd9617
Commit
46dd9617
authored
May 20, 2014
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move the stat-summing from WRK to Pool where it mostly happens.
parent
b1ad9cd6
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
74 deletions
+66
-74
cache.h
bin/varnishd/cache/cache.h
+2
-4
cache_expire.c
bin/varnishd/cache/cache_expire.c
+2
-2
cache_hash.c
bin/varnishd/cache/cache_hash.c
+1
-1
cache_main.c
bin/varnishd/cache/cache_main.c
+0
-1
cache_pool.c
bin/varnishd/cache/cache_pool.c
+58
-4
cache_wrk.c
bin/varnishd/cache/cache_wrk.c
+1
-60
hash_critbit.c
bin/varnishd/hash/hash_critbit.c
+1
-1
storage_persistent_silo.c
bin/varnishd/storage/storage_persistent_silo.c
+1
-1
No files found.
bin/varnishd/cache/cache.h
View file @
46dd9617
...
...
@@ -1107,6 +1107,8 @@ void Pool_Init(void);
void
Pool_Accept
(
void
);
void
Pool_Work_Thread
(
void
*
priv
,
struct
worker
*
w
);
int
Pool_Task
(
struct
pool
*
pp
,
struct
pool_task
*
task
,
enum
pool_how
how
);
void
Pool_Sumstat
(
struct
worker
*
w
);
void
Pool_PurgeStat
(
unsigned
nobj
);
#define WRW_IsReleased(w) ((w)->wrw == NULL)
int
WRW_Error
(
const
struct
worker
*
w
);
...
...
@@ -1216,10 +1218,6 @@ void WAIT_Write_Session(struct sess *sp, int fd);
/* cache_wrk.c */
void
WRK_Init
(
void
);
int
WRK_TrySumStat
(
struct
worker
*
w
);
void
WRK_SumStat
(
struct
worker
*
w
);
void
WRK_PurgeStat
(
unsigned
nobj
);
void
*
WRK_thread
(
void
*
priv
);
typedef
void
*
bgthread_t
(
struct
worker
*
,
void
*
priv
);
void
WRK_BgThread
(
pthread_t
*
thr
,
const
char
*
name
,
bgthread_t
*
func
,
...
...
bin/varnishd/cache/cache_expire.c
View file @
46dd9617
...
...
@@ -404,7 +404,7 @@ EXP_NukeLRU(struct worker *wrk, struct vsl_log *vsl, struct lru *lru)
}
Lck_Unlock(&lru->mtx);
WRK_SumS
tat(wrk);
Pool_Sums
tat(wrk);
}
#endif
...
...
@@ -589,7 +589,7 @@ exp_thread(struct worker *wrk, void *priv)
tnext
=
0
;
}
else
if
(
tnext
>
t
)
{
VSL_Flush
(
&
ep
->
vsl
,
0
);
WRK_SumS
tat
(
wrk
);
Pool_Sums
tat
(
wrk
);
(
void
)
Lck_CondWait
(
&
ep
->
condvar
,
&
ep
->
mtx
,
tnext
);
}
Lck_Unlock
(
&
ep
->
mtx
);
...
...
bin/varnishd/cache/cache_hash.c
View file @
46dd9617
...
...
@@ -603,7 +603,7 @@ double keep)
(
void
)
HSH_DerefObj
(
&
wrk
->
stats
,
&
o
);
}
WS_Release
(
wrk
->
aws
,
0
);
WRK
_PurgeStat
(
nobj
);
Pool
_PurgeStat
(
nobj
);
}
...
...
bin/varnishd/cache/cache_main.c
View file @
46dd9617
...
...
@@ -217,7 +217,6 @@ child_main(void)
VBO_Init
();
VBE_InitCfg
();
VBP_Init
();
WRK_Init
();
Pool_Init
();
Pipe_Init
();
...
...
bin/varnishd/cache/cache_pool.c
View file @
46dd9617
...
...
@@ -78,6 +78,59 @@ static struct lock pool_mtx;
static
pthread_t
thr_pool_herder
;
static
unsigned
pool_accepting
=
0
;
static
struct
lock
wstat_mtx
;
/*--------------------------------------------------------------------*/
static
void
wrk_sumstat
(
const
struct
dstat
*
ds
)
{
Lck_AssertHeld
(
&
wstat_mtx
);
#define L0(n)
#define L1(n) (VSC_C_main->n += ds->n)
#define VSC_F(n, t, l, f, v, d, e) L##l(n);
#include "tbl/vsc_f_main.h"
#undef VSC_F
#undef L0
#undef L1
}
void
Pool_Sumstat
(
struct
worker
*
w
)
{
Lck_Lock
(
&
wstat_mtx
);
wrk_sumstat
(
&
w
->
stats
);
Lck_Unlock
(
&
wstat_mtx
);
memset
(
&
w
->
stats
,
0
,
sizeof
w
->
stats
);
}
static
int
Pool_TrySumstat
(
struct
worker
*
w
)
{
if
(
Lck_Trylock
(
&
wstat_mtx
))
return
(
0
);
wrk_sumstat
(
&
w
->
stats
);
Lck_Unlock
(
&
wstat_mtx
);
memset
(
&
w
->
stats
,
0
,
sizeof
w
->
stats
);
return
(
1
);
}
/*--------------------------------------------------------------------
* Helper function to update stats for purges under lock
*/
void
Pool_PurgeStat
(
unsigned
nobj
)
{
Lck_Lock
(
&
wstat_mtx
);
VSC_C_main
->
n_purges
++
;
VSC_C_main
->
n_obj_purged
+=
nobj
;
Lck_Unlock
(
&
wstat_mtx
);
}
/*--------------------------------------------------------------------
*/
...
...
@@ -148,7 +201,7 @@ pool_accept(struct worker *wrk, void *arg)
if
(
VCA_Accept
(
ps
->
lsock
,
wa
)
<
0
)
{
wrk
->
stats
.
sess_fail
++
;
/* We're going to pace in vca anyway... */
(
void
)
WRK_TrySumS
tat
(
wrk
);
(
void
)
Pool_TrySums
tat
(
wrk
);
continue
;
}
...
...
@@ -287,7 +340,7 @@ Pool_Work_Thread(void *priv, struct worker *wrk)
wrk
->
task
.
priv
=
wrk
;
VTAILQ_INSERT_HEAD
(
&
pp
->
idle_queue
,
&
wrk
->
task
,
list
);
if
(
stats_dirty
)
{
WRK_SumS
tat
(
wrk
);
Pool_Sums
tat
(
wrk
);
stats_dirty
=
0
;
}
do
{
...
...
@@ -307,9 +360,9 @@ Pool_Work_Thread(void *priv, struct worker *wrk)
tp
->
func
(
wrk
,
tp
->
priv
);
if
(
++
stats_dirty
>=
cache_param
->
wthread_stats_rate
)
{
WRK_SumS
tat
(
wrk
);
Pool_Sums
tat
(
wrk
);
stats_dirty
=
0
;
}
else
if
(
WRK_TrySumS
tat
(
wrk
))
}
else
if
(
Pool_TrySums
tat
(
wrk
))
stats_dirty
=
0
;
}
wrk
->
pool
=
NULL
;
...
...
@@ -531,6 +584,7 @@ void
Pool_Init
(
void
)
{
Lck_New
(
&
wstat_mtx
,
lck_wstat
);
Lck_New
(
&
pool_mtx
,
lck_wq
);
AZ
(
pthread_create
(
&
thr_pool_herder
,
NULL
,
pool_poolherder
,
NULL
));
}
bin/varnishd/cache/cache_wrk.c
View file @
46dd9617
...
...
@@ -37,59 +37,6 @@
#include "cache.h"
#include "hash/hash_slinger.h"
static
struct
lock
wstat_mtx
;
/*--------------------------------------------------------------------*/
static
void
wrk_sumstat
(
const
struct
dstat
*
ds
)
{
Lck_AssertHeld
(
&
wstat_mtx
);
#define L0(n)
#define L1(n) (VSC_C_main->n += ds->n)
#define VSC_F(n, t, l, f, v, d, e) L##l(n);
#include "tbl/vsc_f_main.h"
#undef VSC_F
#undef L0
#undef L1
}
void
WRK_SumStat
(
struct
worker
*
w
)
{
Lck_Lock
(
&
wstat_mtx
);
wrk_sumstat
(
&
w
->
stats
);
Lck_Unlock
(
&
wstat_mtx
);
memset
(
&
w
->
stats
,
0
,
sizeof
w
->
stats
);
}
int
WRK_TrySumStat
(
struct
worker
*
w
)
{
if
(
Lck_Trylock
(
&
wstat_mtx
))
return
(
0
);
wrk_sumstat
(
&
w
->
stats
);
Lck_Unlock
(
&
wstat_mtx
);
memset
(
&
w
->
stats
,
0
,
sizeof
w
->
stats
);
return
(
1
);
}
/*--------------------------------------------------------------------
* Helper function to update stats for purges under lock
*/
void
WRK_PurgeStat
(
unsigned
nobj
)
{
Lck_Lock
(
&
wstat_mtx
);
VSC_C_main
->
n_purges
++
;
VSC_C_main
->
n_obj_purged
+=
nobj
;
Lck_Unlock
(
&
wstat_mtx
);
}
/*--------------------------------------------------------------------
* Create and starte a back-ground thread which as its own worker and
* session data structures;
...
...
@@ -164,7 +111,7 @@ wrk_thread_real(void *priv, unsigned thread_workspace)
if
(
w
->
nbo
!=
NULL
)
VBO_Free
(
&
w
->
nbo
);
HSH_Cleanup
(
w
);
WRK_SumS
tat
(
w
);
Pool_Sums
tat
(
w
);
return
(
NULL
);
}
...
...
@@ -174,9 +121,3 @@ WRK_thread(void *priv)
return
(
wrk_thread_real
(
priv
,
cache_param
->
workspace_thread
));
}
void
WRK_Init
(
void
)
{
Lck_New
(
&
wstat_mtx
,
lck_wstat
);
}
bin/varnishd/hash/hash_critbit.c
View file @
46dd9617
...
...
@@ -369,7 +369,7 @@ hcb_cleaner(struct worker *wrk, void *priv)
VSTAILQ_CONCAT
(
&
dead_y
,
&
cool_y
);
VTAILQ_CONCAT
(
&
dead_h
,
&
cool_h
,
hoh_list
);
Lck_Unlock
(
&
hcb_mtx
);
WRK_SumS
tat
(
wrk
);
Pool_Sums
tat
(
wrk
);
VTIM_sleep
(
cache_param
->
critbit_cooloff
);
}
NEEDLESS_RETURN
(
NULL
);
...
...
bin/varnishd/storage/storage_persistent_silo.c
View file @
46dd9617
...
...
@@ -161,7 +161,7 @@ smp_load_seg(struct worker *wrk, const struct smp_sc *sc,
EXP_Inject
(
oc
,
sg
->
lru
,
so
->
ttl
);
sg
->
nobj
++
;
}
WRK_SumS
tat
(
wrk
);
Pool_Sums
tat
(
wrk
);
sg
->
flags
|=
SMP_SEG_LOADED
;
}
...
...
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