From: Laura Flores Date: Fri, 24 Dec 2021 01:18:13 +0000 (+0000) Subject: os/bluestore: detect unnecessary zeros in _do_write_big() X-Git-Tag: v17.1.0~159^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=914debdd4a5c3dd8f7b7762cd138e971a44cfdc3;p=ceph.git os/bluestore: detect unnecessary zeros in _do_write_big() Bluestore's `_do_write()` method handles writing data from bufferlists. Currently, it writes data from bufferlists without checking for unnecessary zeros. The lack zero detection may negatively impact performance. In _do_write_big, we also check if a bufferlist is made up of zeros and avoid writing it if so. Two new counters, `l_bluestore_write_big_skipped_blobs` and `l_bluestore_write_big_skipped_bytes`, have been introduced to help us count how many zero blocks and bytes from _do_write_big() have been skipped. Signed-off-by: Laura Flores --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 8cf3bef1165c..dfb74df41420 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -5091,6 +5091,12 @@ void BlueStore::_init_logger() PerfCountersBuilder::PRIO_DEBUGONLY, unit_t(UNIT_BYTES)); + b.add_u64_counter(l_bluestore_write_big_skipped_blobs, + "write_big_skipped_blobs", + "Large aligned writes into fresh blobs skipped due to zero detection (blobs)"); + b.add_u64_counter(l_bluestore_write_big_skipped_bytes, + "write_big_skipped_bytes", + "Large aligned writes into fresh blobs skipped due to zero detection (bytes)"); b.add_u64_counter(l_bluestore_write_small_skipped, "write_small_skipped", "Small writes into existing or sparse small blobs skipped due to zero detection"); @@ -14968,14 +14974,28 @@ void BlueStore::_do_write_big( } bufferlist t; blp.copy(l, t); - wctx->write(offset, b, l, b_off, t, b_off, l, false, new_blob); - dout(20) << __func__ << " schedule write big: 0x" + + // Zero detection -- big block + if (!t.is_zero()) { + wctx->write(offset, b, l, b_off, t, b_off, l, false, new_blob); + + dout(20) << __func__ << " schedule write big: 0x" << std::hex << offset << "~" << l << std::dec << (new_blob ? " new " : " reuse ") << *b << dendl; + + logger->inc(l_bluestore_write_big_blobs); + } else { // if (!t.is_zero()) + dout(20) << __func__ << " skip big zero block " << std::hex + << " (0x" << b_off << "~" << t.length() << ")" + << " (0x" << b_off << "~" << l << ")" + << std::dec << dendl; + logger->inc(l_bluestore_write_big_skipped_blobs); + logger->inc(l_bluestore_write_big_skipped_bytes, l); + } + offset += l; length -= l; - logger->inc(l_bluestore_write_big_blobs); } } diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index d6ab76019656..f96b82b34c46 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -142,6 +142,8 @@ enum { l_bluestore_submitted_deferred_writes, l_bluestore_submitted_deferred_write_bytes, + l_bluestore_write_big_skipped_blobs, + l_bluestore_write_big_skipped_bytes, l_bluestore_write_small_skipped, l_bluestore_write_small_skipped_bytes, //****************************************