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
d60c17cb
Unverified
Commit
d60c17cb
authored
Sep 04, 2018
by
Salvatore Sanfilippo
Committed by
GitHub
Sep 04, 2018
Browse files
Merge pull request #5315 from soloestoy/optimize-parsing-large-bulk
networking: optimize parsing large bulk greater than 32k
parents
6c001bfc
247d2a73
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/networking.c
View file @
d60c17cb
...
@@ -1294,19 +1294,22 @@ int processMultibulkBuffer(client *c) {
...
@@ -1294,19 +1294,22 @@ int processMultibulkBuffer(client *c) {
c
->
qb_pos
=
newline
-
c
->
querybuf
+
2
;
c
->
qb_pos
=
newline
-
c
->
querybuf
+
2
;
if
(
ll
>=
PROTO_MBULK_BIG_ARG
)
{
if
(
ll
>=
PROTO_MBULK_BIG_ARG
)
{
size_t
qblen
;
/* If we are going to read a large object from network
/* If we are going to read a large object from network
* try to make it likely that it will start at c->querybuf
* try to make it likely that it will start at c->querybuf
* boundary so that we can optimize object creation
* boundary so that we can optimize object creation
* avoiding a large copy of data. */
* avoiding a large copy of data.
sdsrange
(
c
->
querybuf
,
c
->
qb_pos
,
-
1
);
*
c
->
qb_pos
=
0
;
* But only when the data we have not parsed is less than
qblen
=
sdslen
(
c
->
querybuf
);
* or equal to ll+2. If the data length is greater than
/* Hint the sds library about the amount of bytes this string is
* ll+2, trimming querybuf is just a waste of time, because
* going to contain. */
* at this time the querybuf contains not only our bulk. */
if
(
qblen
<
(
size_t
)
ll
+
2
)
if
(
sdslen
(
c
->
querybuf
)
-
c
->
qb_pos
<=
(
size_t
)
ll
+
2
)
{
c
->
querybuf
=
sdsMakeRoomFor
(
c
->
querybuf
,
ll
+
2
-
qblen
);
sdsrange
(
c
->
querybuf
,
c
->
qb_pos
,
-
1
);
c
->
qb_pos
=
0
;
/* Hint the sds library about the amount of bytes this string is
* going to contain. */
c
->
querybuf
=
sdsMakeRoomFor
(
c
->
querybuf
,
ll
+
2
);
}
}
}
c
->
bulklen
=
ll
;
c
->
bulklen
=
ll
;
}
}
...
...
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