]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Randomize osd bench buffer data before submitting to objectstore 49323/head
authorSridhar Seshasayee <sseshasa@redhat.com>
Fri, 16 Sep 2022 11:20:46 +0000 (16:50 +0530)
committerSridhar Seshasayee <sseshasa@redhat.com>
Thu, 8 Dec 2022 07:55:36 +0000 (13:25 +0530)
Introduce randomization of buffer content for each osd bench write. This
is to prevent any possible optimizations that the backing device may use
for the writes. This should make the benchmark to be a bit more accurate.

Fixes: https://tracker.ceph.com/issues/57577
Signed-off-by: Sridhar Seshasayee <sseshasa@redhat.com>
(cherry picked from commit 51e4067c582f36b7ba80c67711c310aef2da36ea)

src/osd/OSD.cc

index 323d1edace30410c910a961164694038ea51c30d..7111fdbad6015d01184eb85ed0d3fab728a25ca3 100644 (file)
@@ -3171,6 +3171,7 @@ int OSD::run_osd_bench_test(
   ostream &ss)
 {
   int ret = 0;
+  srand(time(NULL) % (unsigned long) -1);
   uint32_t duration = cct->_conf->osd_bench_duration;
 
   if (bsize > (int64_t) cct->_conf->osd_bench_max_block_size) {
@@ -3252,12 +3253,6 @@ int OSD::run_osd_bench_test(
     }
   }
 
-  bufferlist bl;
-  bufferptr bp(bsize);
-  memset(bp.c_str(), 'a', bp.length());
-  bl.push_back(std::move(bp));
-  bl.rebuild_page_aligned();
-
   {
     C_SaferCond waiter;
     if (!service.meta_ch->flush_commit(&waiter)) {
@@ -3265,10 +3260,15 @@ int OSD::run_osd_bench_test(
     }
   }
 
+  bufferlist bl;
   utime_t start = ceph_clock_now();
   for (int64_t pos = 0; pos < count; pos += bsize) {
     char nm[30];
     unsigned offset = 0;
+    bufferptr bp(bsize);
+    memset(bp.c_str(), rand() & 0xff, bp.length());
+    bl.push_back(std::move(bp));
+    bl.rebuild_page_aligned();
     if (onum && osize) {
       snprintf(nm, sizeof(nm), "disk_bw_test_%d", (int)(rand() % onum));
       offset = rand() % (osize / bsize) * bsize;
@@ -3283,6 +3283,7 @@ int OSD::run_osd_bench_test(
     if (!onum || !osize) {
       cleanupt.remove(coll_t::meta(), ghobject_t(soid));
     }
+    bl.clear();
   }
 
   {