Skip to content

Instantly share code, notes, and snippets.

@cbodley
Created August 9, 2019 21:02
Show Gist options
  • Save cbodley/183f9819d33afdc06fe36359ceab74f9 to your computer and use it in GitHub Desktop.
Save cbodley/183f9819d33afdc06fe36359ceab74f9 to your computer and use it in GitHub Desktop.
cls_log benchmark
diff --git a/src/test/cls_log/test_cls_log.cc b/src/test/cls_log/test_cls_log.cc
index 868afcaf65..e23322ff25 100644
--- a/src/test/cls_log/test_cls_log.cc
+++ b/src/test/cls_log/test_cls_log.cc
@@ -381,3 +381,34 @@ TEST_F(cls_log, trim_by_marker)
ASSERT_EQ(-ENODATA, do_log_trim(ioctx, oid, from, to));
}
}
+
+static void create_remove(librados::IoCtx& ioctx, std::string& oid, int count)
+{
+ ASSERT_EQ(0, ioctx.create(oid, true));
+
+ const utime_t t0 = ceph_clock_now();
+
+ utime_t time = t0;
+ for (int i = 0; i < count/1000; i++) {
+ generate_log(ioctx, oid, 1000, time, true);
+ time.sec_ref() += 1000;
+ }
+
+ const utime_t t1 = ceph_clock_now();
+ std::cout << oid << " created entries in " << (t1 - t0) << std::endl;
+
+ ASSERT_EQ(0, do_log_trim(ioctx, oid, "", "9"));
+
+ const utime_t t2 = ceph_clock_now();
+ std::cout << oid << " trimmed entries in " << (t2 - t1) << std::endl;
+
+ ASSERT_EQ(-ENODATA, do_log_trim(ioctx, oid, "", "9"));
+}
+
+TEST_F(cls_log, trim_many)
+{
+ create_remove(ioctx, "10k", 10000);
+ create_remove(ioctx, "100k", 100000);
+ create_remove(ioctx, "1m", 1000000);
+ create_remove(ioctx, "10m", 10000000);
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment