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:
parent
a59a02174f
commit
099ad2ce7c
@ -197,6 +197,10 @@ namespace crucible {
|
|||||||
|
|
||||||
size_t m_buf_size;
|
size_t m_buf_size;
|
||||||
set<BtrfsIoctlSearchHeader> m_result;
|
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);
|
ostream & operator<<(ostream &os, const btrfs_ioctl_search_key &key);
|
||||||
|
@ -754,6 +754,10 @@ namespace crucible {
|
|||||||
return offset + len;
|
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
|
bool
|
||||||
BtrfsIoctlSearchKey::do_ioctl_nothrow(int fd)
|
BtrfsIoctlSearchKey::do_ioctl_nothrow(int fd)
|
||||||
{
|
{
|
||||||
@ -774,6 +778,7 @@ namespace crucible {
|
|||||||
ioctl_ptr->buf_size = buf_size;
|
ioctl_ptr->buf_size = buf_size;
|
||||||
// Don't bother supporting V1. Kernels that old have other problems.
|
// Don't bother supporting V1. Kernels that old have other problems.
|
||||||
int rv = ioctl(fd, BTRFS_IOC_TREE_SEARCH_V2, ioctl_arg.data());
|
int rv = ioctl(fd, BTRFS_IOC_TREE_SEARCH_V2, ioctl_arg.data());
|
||||||
|
++s_calls;
|
||||||
if (rv != 0 && errno == ENOENT) {
|
if (rv != 0 && errno == ENOENT) {
|
||||||
// If we are searching a tree that is deleted or no longer exists, just return an empty list
|
// If we are searching a tree that is deleted or no longer exists, just return an empty list
|
||||||
nr_items = 0;
|
nr_items = 0;
|
||||||
@ -800,6 +805,10 @@ namespace crucible {
|
|||||||
buf_size *= 2;
|
buf_size *= 2;
|
||||||
}
|
}
|
||||||
// don't automatically raise the buf size higher than 64K, the largest possible btrfs item
|
// 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);
|
} while (buf_size < 65536);
|
||||||
|
|
||||||
// ioctl changes nr_items, this has to be copied back
|
// ioctl changes nr_items, this has to be copied back
|
||||||
|
Loading…
x
Reference in New Issue
Block a user