]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/buffer: pass NULL buffer instead of a zero-filled one
authorSage Weil <sage@inktank.com>
Sat, 28 Sep 2013 04:07:17 +0000 (21:07 -0700)
committerSage Weil <sage@inktank.com>
Wed, 16 Oct 2013 16:28:14 +0000 (09:28 -0700)
This is about 2x faster on my box using the sctp code.

Signed-off-by: Sage Weil <sage@inktank.com>
src/common/buffer.cc

index 064775d2993121eca2e08d98c91c54e73e0bf474..4aa03ae413173cec222b980ba919c95fa9d8f96f 100644 (file)
 
 namespace ceph {
 
-  // some zeros; used when concatenating buffers with cached crc
-  static unsigned char zbuf[128] = {
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
-    };
-
 #ifdef BUFFER_DEBUG
 static uint32_t simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
 # define bdout { simple_spin_lock(&buffer_debug_lock); std::cout
@@ -1346,14 +1334,7 @@ __u32 buffer::list::crc32c(__u32 crc) const
           * http://crcutil.googlecode.com/files/crc-doc.1.0.pdf
           * note, u for our crc32c implementation is 0
           */
-         int64_t adjustment = ccrc.first ^ crc;
-         size_t remaining = it->length();
-         for (; remaining > sizeof(zbuf); remaining -= sizeof(zbuf)) {
-           adjustment = ceph_crc32c(adjustment, zbuf, sizeof(zbuf));
-         }
-         if (remaining)
-           adjustment = ceph_crc32c(adjustment, zbuf, remaining);
-         crc = ccrc.second ^ adjustment;
+         crc = ccrc.second ^ ceph_crc32c(ccrc.first ^ crc, NULL, it->length());
          if (buffer_track_crc)
            buffer_cached_crc_adjusted.inc();
        }