]> git.hungrycats.org Git - bees/commitdiff
fs: add some performance metrics for TREE_SEARCH_V2 calls
authorZygo Blaxell <bees@furryterror.org>
Sun, 24 Oct 2021 19:17:43 +0000 (15:17 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sun, 1 Dec 2024 04:30:33 +0000 (23:30 -0500)
These give some visibility into how efficiently bees is using the
TREE_SEARCH_V2 ioctl.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
include/crucible/fs.h
lib/fs.cc

index 6d1780b4cc733d3637b727296f8696fe9e45fa1e..da624e532d9e8adb145a8197db0dd80205ef870d 100644 (file)
@@ -197,6 +197,10 @@ namespace crucible {
 
                size_t m_buf_size;
                set<BtrfsIoctlSearchHeader> m_result;
+
+               static thread_local size_t s_calls;
+               static thread_local size_t s_loops;
+               static thread_local size_t s_loops_empty;
        };
 
        ostream & operator<<(ostream &os, const btrfs_ioctl_search_key &key);
index e75a92038c2b0c72a8b78e658ee5bebf39f2195a..dc9a2eb1355e5ba1627e40237f119827d20f8f95 100644 (file)
--- a/lib/fs.cc
+++ b/lib/fs.cc
@@ -754,6 +754,10 @@ namespace crucible {
                return offset + len;
        }
 
+       thread_local size_t BtrfsIoctlSearchKey::s_calls = 0;
+       thread_local size_t BtrfsIoctlSearchKey::s_loops = 0;
+       thread_local size_t BtrfsIoctlSearchKey::s_loops_empty = 0;
+
        bool
        BtrfsIoctlSearchKey::do_ioctl_nothrow(int fd)
        {
@@ -774,6 +778,7 @@ namespace crucible {
                        ioctl_ptr->buf_size = buf_size;
                        // Don't bother supporting V1.  Kernels that old have other problems.
                        int rv = ioctl(fd, BTRFS_IOC_TREE_SEARCH_V2, ioctl_arg.data());
+                       ++s_calls;
                        if (rv != 0 && errno == ENOENT) {
                                // If we are searching a tree that is deleted or no longer exists, just return an empty list
                                nr_items = 0;
@@ -800,6 +805,10 @@ namespace crucible {
                                buf_size *= 2;
                        }
                        // don't automatically raise the buf size higher than 64K, the largest possible btrfs item
+                       ++s_loops;
+                       if (ioctl_ptr->key.nr_items == 0) {
+                               ++s_loops_empty;
+                       }
                } while (buf_size < 65536);
 
                // ioctl changes nr_items, this has to be copied back