]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: detect unnecessary zeros in _do_write_big()
authorLaura Flores <lflores@redhat.com>
Fri, 24 Dec 2021 01:18:13 +0000 (01:18 +0000)
committerLaura Flores <lflores@redhat.com>
Fri, 24 Dec 2021 01:18:13 +0000 (01:18 +0000)
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 <lflores@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 8cf3bef1165cf8102ee648d4526ee4e70d7a6da1..dfb74df4142069c6df2c488accd4d05c8b9a1f86 100644 (file)
@@ -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);
   }
 }
 
index d6ab760196563eb30a6a537af52c865ad2d18b0e..f96b82b34c461de76500f1b17674172f309cb14b 100644 (file)
@@ -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,
   //****************************************