1
0
mirror of https://github.com/Zygo/bees.git synced 2025-05-18 05:45:45 +02:00

fs: add some performance metrics for TREE_SEARCH_V2 calls

These give some visibility into how efficiently bees is using the
TREE_SEARCH_V2 ioctl.

Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
Zygo Blaxell 2021-10-24 15:17:43 -04:00
parent a59a02174f
commit 099ad2ce7c
2 changed files with 13 additions and 0 deletions

View 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);

View File

@ -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