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
1366473e
Commit
1366473e
authored
Feb 08, 2012
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allocate busyobj with a mempool, instead of a private one-item pool.
parent
2362e936
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
63 deletions
+58
-63
cache_busyobj.c
bin/varnishd/cache/cache_busyobj.c
+41
-37
cache_mempool.c
bin/varnishd/cache/cache_mempool.c
+2
-0
params.h
bin/varnishd/common/params.h
+1
-0
mgt_param.c
bin/varnishd/mgt/mgt_param.c
+14
-12
vsc_f_main.h
include/tbl/vsc_f_main.h
+0
-14
No files found.
bin/varnishd/cache/cache_busyobj.c
View file @
1366473e
...
...
@@ -38,6 +38,10 @@
#include "cache.h"
static
struct
mempool
*
vbopool
;
static
volatile
unsigned
vbosize
;
struct
vbo
{
unsigned
magic
;
#define VBO_MAGIC 0xde3d8223
...
...
@@ -48,13 +52,35 @@ struct vbo {
};
static
struct
lock
vbo_mtx
;
static
struct
vbo
*
nvbo
;
/*--------------------------------------------------------------------
*/
static
void
vbo_size_calc
(
volatile
unsigned
*
u
)
{
uint16_t
nhttp
;
ssize_t
http_space
;
assert
(
cache_param
->
http_max_hdr
<
65536
);
nhttp
=
(
uint16_t
)
cache_param
->
http_max_hdr
;
http_space
=
HTTP_estimate
(
nhttp
);
*
u
=
sizeof
(
struct
vbo
)
+
http_space
*
2L
;
}
/*--------------------------------------------------------------------
*/
void
VBO_Init
(
void
)
{
vbopool
=
MPL_New
(
"vbo"
,
&
cache_param
->
vbo_pool
,
&
vbosize
,
vbo_size_calc
);
AN
(
vbopool
);
Lck_New
(
&
vbo_mtx
,
lck_busyobj
);
nvbo
=
NULL
;
}
/*--------------------------------------------------------------------
...
...
@@ -67,16 +93,19 @@ vbo_New(void)
struct
vbo
*
vbo
;
uint16_t
nhttp
;
ssize_t
http_space
;
unsigned
sz
;
assert
(
cache_param
->
http_max_hdr
<
65536
);
vbo
=
MPL_Get
(
vbopool
,
&
sz
);
nhttp
=
(
uint16_t
)
cache_param
->
http_max_hdr
;
http_space
=
HTTP_estimate
(
nhttp
);
vbo
=
malloc
(
sizeof
*
vbo
+
2
*
http_space
);
if
(
sizeof
*
vbo
+
2
*
http_space
>
sz
)
{
/* Could be transient, try again */
MPL_Free
(
vbopool
,
vbo
);
vbo_size_calc
(
&
vbosize
);
vbo
=
MPL_Get
(
vbopool
,
&
sz
);
assert
(
sizeof
*
vbo
+
2
*
http_space
<=
sz
);
}
AN
(
vbo
);
memset
(
vbo
,
0
,
sizeof
*
vbo
);
vbo
->
magic
=
VBO_MAGIC
;
vbo
->
nhttp
=
nhttp
;
Lck_New
(
&
vbo
->
mtx
,
lck_busyobj
);
...
...
@@ -94,7 +123,7 @@ VBO_Free(struct vbo **vbop)
CHECK_OBJ_NOTNULL
(
vbo
,
VBO_MAGIC
);
AZ
(
vbo
->
refcount
);
Lck_Delete
(
&
vbo
->
mtx
);
FREE_OBJ
(
vbo
);
MPL_Free
(
vbopool
,
vbo
);
}
struct
busyobj
*
...
...
@@ -110,21 +139,6 @@ VBO_GetBusyObj(struct worker *wrk)
wrk
->
nvbo
=
NULL
;
}
if
(
vbo
==
NULL
)
{
Lck_Lock
(
&
vbo_mtx
);
vbo
=
nvbo
;
nvbo
=
NULL
;
if
(
vbo
==
NULL
)
VSC_C_main
->
busyobj_alloc
++
;
Lck_Unlock
(
&
vbo_mtx
);
}
if
(
vbo
!=
NULL
&&
vbo
->
nhttp
!=
cache_param
->
http_max_hdr
)
VBO_Free
(
&
vbo
);
if
(
vbo
==
NULL
)
vbo
=
vbo_New
();
...
...
@@ -181,19 +195,9 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo)
/* XXX: Sanity checks & cleanup */
memset
(
&
vbo
->
bo
,
0
,
sizeof
vbo
->
bo
);
if
(
cache_param
->
bo_cache
&&
wrk
->
nvbo
==
NULL
)
{
if
(
cache_param
->
bo_cache
&&
wrk
->
nvbo
==
NULL
)
wrk
->
nvbo
=
vbo
;
}
else
{
Lck_Lock
(
&
vbo_mtx
);
if
(
nvbo
==
NULL
)
{
nvbo
=
vbo
;
vbo
=
NULL
;
}
else
VSC_C_main
->
busyobj_free
++
;
Lck_Unlock
(
&
vbo_mtx
);
if
(
vbo
!=
NULL
)
VBO_Free
(
&
vbo
);
}
else
VBO_Free
(
&
vbo
);
}
}
bin/varnishd/cache/cache_mempool.c
View file @
1366473e
...
...
@@ -237,6 +237,8 @@ MPL_New(const char *name,
mpl
->
param
=
pp
;
mpl
->
cur_size
=
cur_size
;
mpl
->
poll_func
=
poll_f
;
if
(
poll_f
!=
NULL
)
poll_f
(
mpl
->
cur_size
);
VTAILQ_INIT
(
&
mpl
->
list
);
VTAILQ_INIT
(
&
mpl
->
surplus
);
Lck_New
(
&
mpl
->
mtx
,
lck_mempool
);
...
...
bin/varnishd/common/params.h
View file @
1366473e
...
...
@@ -201,4 +201,5 @@ struct params {
struct
poolparam
vbc_pool
;
struct
poolparam
req_pool
;
struct
poolparam
sess_pool
;
struct
poolparam
vbo_pool
;
};
bin/varnishd/mgt/mgt_param.c
View file @
1366473e
...
...
@@ -662,6 +662,12 @@ tweak_poolparam(struct cli *cli, const struct parspec *par, const char *arg)
"\nNB: Do not change this parameter, unless a developer tell " \
"you to do so."
#define MEMPOOL_TEXT \
"The three numbers are:\n" \
" min_pool -- minimum size of free pool.\n" \
" max_pool -- maximum size of free pool.\n" \
" max_age -- max age of free element.\n"
/*
* Remember to update varnishd.1 whenever you add / remove a parameter or
* change its default value.
...
...
@@ -1192,27 +1198,23 @@ static const struct parspec input_parspec[] = {
{
"pool_vbc"
,
tweak_poolparam
,
&
mgt_param
.
vbc_pool
,
0
,
10000
,
"Parameters for backend connection memory pool.
\n
"
"The three numbers are:
\n
"
" min_pool -- minimum size of free pool.
\n
"
" max_pool -- maximum size of free pool.
\n
"
" max_age -- max age of free element.
\n
"
,
MEMPOOL_TEXT
,
0
,
"10,100,10"
,
""
},
{
"pool_req"
,
tweak_poolparam
,
&
mgt_param
.
req_pool
,
0
,
10000
,
"Parameters for per worker pool request memory pool.
\n
"
"The three numbers are:
\n
"
" min_pool -- minimum size of free pool.
\n
"
" max_pool -- maximum size of free pool.
\n
"
" max_age -- max age of free element.
\n
"
,
MEMPOOL_TEXT
,
0
,
"10,100,10"
,
""
},
{
"pool_sess"
,
tweak_poolparam
,
&
mgt_param
.
sess_pool
,
0
,
10000
,
"Parameters for per worker pool session memory pool.
\n
"
"The three numbers are:
\n
"
" min_pool -- minimum size of free pool.
\n
"
" max_pool -- maximum size of free pool.
\n
"
" max_age -- max age of free element.
\n
"
,
MEMPOOL_TEXT
,
0
,
"10,100,10"
,
""
},
{
"pool_vbo"
,
tweak_poolparam
,
&
mgt_param
.
vbo_pool
,
0
,
10000
,
"Parameters for backend object fetch memory pool.
\n
"
MEMPOOL_TEXT
,
0
,
"10,100,10"
,
""
},
...
...
include/tbl/vsc_f_main.h
View file @
1366473e
...
...
@@ -206,20 +206,6 @@ VSC_F(sess_dropped, uint64_t, 0, 'c',
" See also param queue_max."
)
/*---------------------------------------------------------------------
* BusyObj
*/
VSC_F
(
busyobj_alloc
,
uint64_t
,
0
,
'c'
,
"Busyobj allocations"
,
"Number of busyobj structures allocated."
)
VSC_F
(
busyobj_free
,
uint64_t
,
0
,
'c'
,
"Busyobj freed"
,
"Number of busyobj structures freed."
)
/*---------------------------------------------------------------------*/
VSC_F
(
n_object
,
uint64_t
,
1
,
'i'
,
"N struct object"
,
""
)
...
...
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