This is an automated email from the ASF dual-hosted git repository.

twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new df3735e99 perf(repl): only calculate crc of fetched file when needed 
(#3161)
df3735e99 is described below

commit df3735e99ba622c633dfc2ced3fc24b9f769e9c9
Author: Jonah Gao <[email protected]>
AuthorDate: Thu Sep 4 17:23:57 2025 +0800

    perf(repl): only calculate crc of fetched file when needed (#3161)
    
    When fetching files, we verify the file checksum only if the expected
    CRC is not 0.
    
    
https://github.com/apache/kvrocks/blob/db0cbec060bb9d1e71a6942bba354b4b280a40f2/src/cluster/replication.cc#L1053-L1056
    
    
    So when the expected CRC is 0, there is no need to calculate the file’s
    CRC.
    Especially in the current implementation, the expected CRC is always 0.
---
 src/cluster/replication.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/cluster/replication.cc b/src/cluster/replication.cc
index f56593078..a54aaa600 100644
--- a/src/cluster/replication.cc
+++ b/src/cluster/replication.cc
@@ -1036,7 +1036,10 @@ Status ReplicationThread::fetchFile(int sock_fd, 
evbuffer *evbuf, const std::str
         return {Status::NotOK, "read sst file data error"};
       }
       tmp_file->Append(rocksdb::Slice(data, data_len));
-      tmp_crc = rocksdb::crc32c::Extend(tmp_crc, data, data_len);
+      // Only calculate crc when the expected crc is not 0
+      if (crc != 0) {
+        tmp_crc = rocksdb::crc32c::Extend(tmp_crc, data, data_len);
+      }
       remain -= data_len;
     } else {
       if (auto s = util::EvbufferRead(evbuf, sock_fd, -1, ssl); !s) {

Reply via email to