]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
objclass: don't do costly string formatting when not needed 60763/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 16 Oct 2024 12:37:48 +0000 (12:37 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 18 Nov 2024 21:57:05 +0000 (21:57 +0000)
Special thanks and credits to Mark Kogan for profiling
ceph-osd under the RGW list workload.

In this particular workload the change is worth around 4.2%
of CPU cycles [1]. However, it's not restricted to RGW's
bucket listing nor `cls_rgw`; I think it affects every single
cls plugin in the system.

Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
[1]: https://github.com/ceph/ceph/pull/60278#issuecomment-2416582108

src/osd/objclass.cc

index af6d76efa825d8f3d3a2649ae31b1e4440f19491..cc3109b246df03e6a2fff7edcea8026e8086255c 100644 (file)
@@ -765,6 +765,11 @@ int cls_cxx_get_gathered_data(cls_method_context_t hctx, std::map<std::string, b
 // crimson-osd, it's different b/c of how the dout macro expands.
 int cls_log(int level, const char *format, ...)
 {
+   if (!ClassHandler::get_instance().cct->_conf->subsys.should_gather(dout_subsys, level)) {
+     // if this early exit becomes visible in profiling, switch to
+     // the static, compile-time check as the dout does.
+     return 0;
+   }
    size_t size = 256;
    va_list ap;
    while (1) {