From: Sage Weil Date: Sat, 28 Sep 2013 04:07:17 +0000 (-0700) Subject: common/buffer: pass NULL buffer instead of a zero-filled one X-Git-Tag: v0.72-rc1~42^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d9e30775c08ecef79ff692fff39ada5bc98bfe90;p=ceph.git common/buffer: pass NULL buffer instead of a zero-filled one This is about 2x faster on my box using the sctp code. Signed-off-by: Sage Weil --- diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 064775d29931..4aa03ae41317 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -31,18 +31,6 @@ 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(); }