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
9917c26f
Commit
9917c26f
authored
Jul 11, 2016
by
gquintard
Committed by
GitHub
Jul 11, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1997 from gquintard/advice
Tunable madvise for file storage
parents
eb0b073f
45150f2c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
mgt_main.c
bin/varnishd/mgt/mgt_main.c
+2
-0
storage_file.c
bin/varnishd/storage/storage_file.c
+15
-3
storage-backends.rst
doc/sphinx/users-guide/storage-backends.rst
+8
-1
No files found.
bin/varnishd/mgt/mgt_main.c
View file @
9917c26f
...
...
@@ -238,6 +238,8 @@ usage(void)
fprintf
(
stderr
,
FMT
,
""
,
" -s file,<dir_or_file>,<size>"
);
fprintf
(
stderr
,
FMT
,
""
,
" -s file,<dir_or_file>,<size>,<granularity>"
);
fprintf
(
stderr
,
FMT
,
""
,
" -s file,<dir_or_file>,<size>,<granularity>,<advice>"
);
fprintf
(
stderr
,
FMT
,
""
,
" -s persistent (experimental)"
);
fprintf
(
stderr
,
FMT
,
"-T address:port"
,
"Telnet listen address and port"
);
...
...
bin/varnishd/storage/storage_file.c
View file @
9917c26f
...
...
@@ -96,6 +96,7 @@ struct smf_sc {
int
fd
;
unsigned
pagesize
;
uintmax_t
filesize
;
int
advice
;
struct
smfhead
order
;
struct
smfhead
free
[
NBUCKET
];
struct
smfhead
used
;
...
...
@@ -110,13 +111,14 @@ smf_init(struct stevedore *parent, int ac, char * const *av)
struct
smf_sc
*
sc
;
unsigned
u
;
uintmax_t
page_size
;
int
advice
=
MADV_RANDOM
;
AZ
(
av
[
ac
]);
size
=
NULL
;
page_size
=
getpagesize
();
if
(
ac
>
3
)
if
(
ac
>
4
)
ARGV_ERR
(
"(-sfile) too many arguments
\n
"
);
if
(
ac
<
1
||
*
av
[
0
]
==
'\0'
)
ARGV_ERR
(
"(-sfile) path is mandatory
\n
"
);
...
...
@@ -129,6 +131,16 @@ smf_init(struct stevedore *parent, int ac, char * const *av)
if
(
r
!=
NULL
)
ARGV_ERR
(
"(-sfile) granularity
\"
%s
\"
: %s
\n
"
,
av
[
2
],
r
);
}
if
(
ac
>
3
)
{
if
(
!
strcmp
(
av
[
3
],
"normal"
))
advice
=
MADV_NORMAL
;
else
if
(
!
strcmp
(
av
[
3
],
"random"
))
advice
=
MADV_RANDOM
;
else
if
(
!
strcmp
(
av
[
3
],
"sequential"
))
advice
=
MADV_SEQUENTIAL
;
else
ARGV_ERR
(
"(-s file) invalid advice:
\"
%s
\"
"
,
av
[
3
]);
}
AN
(
fn
);
...
...
@@ -139,7 +151,7 @@ smf_init(struct stevedore *parent, int ac, char * const *av)
VTAILQ_INIT
(
&
sc
->
free
[
u
]);
VTAILQ_INIT
(
&
sc
->
used
);
sc
->
pagesize
=
page_size
;
sc
->
advice
=
advice
;
parent
->
priv
=
sc
;
(
void
)
STV_GetFile
(
fn
,
&
sc
->
fd
,
&
sc
->
filename
,
"-sfile"
);
...
...
@@ -366,7 +378,7 @@ smf_open_chunk(struct smf_sc *sc, off_t sz, off_t off, off_t *fail, off_t *sum)
p
=
mmap
(
NULL
,
sz
,
PROT_READ
|
PROT_WRITE
,
MAP_NOCORE
|
MAP_NOSYNC
|
MAP_SHARED
,
sc
->
fd
,
off
);
if
(
p
!=
MAP_FAILED
)
{
(
void
)
madvise
(
p
,
sz
,
MADV_RANDOM
);
(
void
)
madvise
(
p
,
sz
,
sc
->
advice
);
(
*
sum
)
+=
sz
;
new_smf
(
sc
,
p
,
off
,
sz
);
return
;
...
...
doc/sphinx/users-guide/storage-backends.rst
View file @
9917c26f
...
...
@@ -48,7 +48,7 @@ depend on the operating systems ability to page effectively.
file
~~~~
syntax: file[,path[,size[,granularity]]]
syntax: file[,path[,size[,granularity
,[advice]
]]]
The file backend stores objects in memory backed by an unlinked file on disk
with `mmap`.
...
...
@@ -94,6 +94,13 @@ have many small objects.
File performance is typically limited to the write speed of the
device, and depending on use, the seek time.
'advice' dictates what Varnish tells the system to optimize reads. Depending
on your OS, disks and object sizes, it can be beneficial to tweak this. The
three possible values are "normal", "random" (default) and "sequential" and
correspond to MADV_NORMAL, MADV_RANDOM, MADV_SEQUENTIAL, respectively.
For example, large objects and rotational disk should profit from "sequential"
on Linux.
persistent (experimental)
~~~~~~~~~~~~~~~~~~~~~~~~~
...
...
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