From 4fa3e23092d642f0c67116d9f7616f4f1173a1cf Mon Sep 17 00:00:00 2001 From: Wang Yuan Date: Mon, 28 Jun 2021 14:43:40 +0800 Subject: [PATCH] Remove unnecessary replication backlog memory copy (#9157) in the past, the reply list was a list of sds objects, so this didn't have any overhead, but now addReplySds just copies the data from the sds and frees it, so there's no need to make a copy of the buffer before copying again. this reduces an excessive allocation and free and a memcpy. --- src/replication.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/replication.c b/src/replication.c index b40d3f314..06934a7bb 100644 --- a/src/replication.c +++ b/src/replication.c @@ -463,7 +463,7 @@ long long addReplyReplicationBacklog(client *c, long long offset) { (server.repl_backlog_size - j) : len; serverLog(LL_DEBUG, "[PSYNC] addReply() length: %lld", thislen); - addReplySds(c,sdsnewlen(server.repl_backlog + j, thislen)); + addReplyProto(c,server.repl_backlog + j, thislen); len -= thislen; j = 0; }