]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: Randomize osd bench buffer data before submitting to objectstore 48138/head
authorSridhar Seshasayee <sseshasa@redhat.com>
Fri, 16 Sep 2022 11:20:46 +0000 (16:50 +0530)
committerSridhar Seshasayee <sseshasa@redhat.com>
Fri, 16 Sep 2022 11:44:38 +0000 (17:14 +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>
src/osd/OSD.cc

index acbfdf4667c22287db2ec1158c5f8890086c8436..b4bc95481e22ebe68d1a509b1179e9bf4103ab17 100644 (file)
@@ -3181,6 +3181,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) {
@@ -3262,12 +3263,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)) {
@@ -3275,10 +3270,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[34];
     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;
@@ -3293,6 +3293,7 @@ int OSD::run_osd_bench_test(
     if (!onum || !osize) {
       cleanupt.remove(coll_t::meta(), ghobject_t(soid));
     }
+    bl.clear();
   }
 
   {