Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
f990782f
Commit
f990782f
authored
Aug 18, 2011
by
Pieter Noordhuis
Committed by
antirez
Sep 13, 2011
Browse files
Re-use AOF buffer when it is small enough
parent
a57225c2
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/aof.c
View file @
f990782f
...
@@ -81,10 +81,17 @@ void flushAppendOnlyFile(void) {
...
@@ -81,10 +81,17 @@ void flushAppendOnlyFile(void) {
}
}
exit
(
1
);
exit
(
1
);
}
}
sdsfree
(
server
.
aofbuf
);
server
.
aofbuf
=
sdsempty
();
server
.
appendonly_current_size
+=
nwritten
;
server
.
appendonly_current_size
+=
nwritten
;
/* Re-use AOF buffer when it is small enough. The maximum comes from the
* arena size of 4k minus some overhead (but is otherwise arbitrary). */
if
((
sdslen
(
server
.
aofbuf
)
+
sdsavail
(
server
.
aofbuf
))
<
4000
)
{
sdsclear
(
server
.
aofbuf
);
}
else
{
sdsfree
(
server
.
aofbuf
);
server
.
aofbuf
=
sdsempty
();
}
/* Don't fsync if no-appendfsync-on-rewrite is set to yes and there are
/* Don't fsync if no-appendfsync-on-rewrite is set to yes and there are
* children doing I/O in the background. */
* children doing I/O in the background. */
if
(
server
.
no_appendfsync_on_rewrite
&&
if
(
server
.
no_appendfsync_on_rewrite
&&
...
...
src/sds.c
View file @
f990782f
...
@@ -94,6 +94,13 @@ void sdsupdatelen(sds s) {
...
@@ -94,6 +94,13 @@ void sdsupdatelen(sds s) {
sh
->
len
=
reallen
;
sh
->
len
=
reallen
;
}
}
void
sdsclear
(
sds
s
)
{
struct
sdshdr
*
sh
=
(
void
*
)
(
s
-
(
sizeof
(
struct
sdshdr
)));
sh
->
free
+=
sh
->
len
;
sh
->
len
=
0
;
sh
->
buf
[
0
]
=
'\0'
;
}
static
sds
sdsMakeRoomFor
(
sds
s
,
size_t
addlen
)
{
static
sds
sdsMakeRoomFor
(
sds
s
,
size_t
addlen
)
{
struct
sdshdr
*
sh
,
*
newsh
;
struct
sdshdr
*
sh
,
*
newsh
;
size_t
free
=
sdsavail
(
s
);
size_t
free
=
sdsavail
(
s
);
...
...
src/sds.h
View file @
f990782f
...
@@ -76,6 +76,7 @@ sds sdscatprintf(sds s, const char *fmt, ...);
...
@@ -76,6 +76,7 @@ sds sdscatprintf(sds s, const char *fmt, ...);
sds
sdstrim
(
sds
s
,
const
char
*
cset
);
sds
sdstrim
(
sds
s
,
const
char
*
cset
);
sds
sdsrange
(
sds
s
,
int
start
,
int
end
);
sds
sdsrange
(
sds
s
,
int
start
,
int
end
);
void
sdsupdatelen
(
sds
s
);
void
sdsupdatelen
(
sds
s
);
void
sdsclear
(
sds
s
);
int
sdscmp
(
sds
s1
,
sds
s2
);
int
sdscmp
(
sds
s1
,
sds
s2
);
sds
*
sdssplitlen
(
char
*
s
,
int
len
,
char
*
sep
,
int
seplen
,
int
*
count
);
sds
*
sdssplitlen
(
char
*
s
,
int
len
,
char
*
sep
,
int
seplen
,
int
*
count
);
void
sdsfreesplitres
(
sds
*
tokens
,
int
count
);
void
sdsfreesplitres
(
sds
*
tokens
,
int
count
);
...
...
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