Mirror von
https://github.com/tkuschel/bees.git
synchronisiert 2026-05-08 04:59:37 +02:00
crucible: reduce buffer size and CPU overhead for BtrfsIoctlSearchKey
We really do need some large buffers for BtrfsIoctlSearchKey in some cases, but we don't need to zero them out first. Don't do that so we save some CPU. Reduce the default buffer size to 4K because most BISK users don't get need much more than 1K. Set the buffer size explicitly to the product of the number of items and the desired item size in the places that really need a lot of items.
Dieser Commit ist enthalten in:
@@ -156,7 +156,7 @@ namespace crucible {
|
||||
ostream & operator<<(ostream &os, const BtrfsIoctlSearchHeader &hdr);
|
||||
|
||||
struct BtrfsIoctlSearchKey : public btrfs_ioctl_search_key {
|
||||
BtrfsIoctlSearchKey(size_t buf_size = 16 * 1024);
|
||||
BtrfsIoctlSearchKey(size_t buf_size = 4096);
|
||||
virtual bool do_ioctl_nothrow(int fd);
|
||||
virtual void do_ioctl(int fd);
|
||||
|
||||
|
||||
@@ -468,7 +468,7 @@ namespace crucible {
|
||||
BtrfsExtentWalker::Vec
|
||||
BtrfsExtentWalker::get_extent_map(off_t pos)
|
||||
{
|
||||
BtrfsIoctlSearchKey sk;
|
||||
BtrfsIoctlSearchKey sk(sc_extent_fetch_max * (sizeof(btrfs_file_extent_item) + sizeof(btrfs_ioctl_search_header)));
|
||||
if (!m_root_fd) {
|
||||
m_root_fd = m_fd;
|
||||
}
|
||||
|
||||
+3
-1
@@ -711,7 +711,9 @@ namespace crucible {
|
||||
BtrfsIoctlSearchKey::do_ioctl_nothrow(int fd)
|
||||
{
|
||||
vector<char> ioctl_arg = vector_copy_struct<btrfs_ioctl_search_key>(this);
|
||||
ioctl_arg.resize(sizeof(btrfs_ioctl_search_args_v2) + m_buf_size, 0);
|
||||
// Normally we like to be paranoid and fill empty bytes with zero,
|
||||
// but these buffers can be huge. 80% of a 4GHz CPU huge.
|
||||
ioctl_arg.resize(sizeof(btrfs_ioctl_search_args_v2) + m_buf_size);
|
||||
btrfs_ioctl_search_args_v2 *ioctl_ptr = reinterpret_cast<btrfs_ioctl_search_args_v2 *>(ioctl_arg.data());
|
||||
|
||||
ioctl_ptr->buf_size = m_buf_size;
|
||||
|
||||
@@ -644,7 +644,7 @@ BeesCrawl::fetch_extents()
|
||||
|
||||
Timer crawl_timer;
|
||||
|
||||
BtrfsIoctlSearchKey sk;
|
||||
BtrfsIoctlSearchKey sk(BEES_MAX_CRAWL_SIZE * (sizeof(btrfs_file_extent_item) + sizeof(btrfs_ioctl_search_header)));
|
||||
sk.tree_id = old_state.m_root;
|
||||
sk.min_objectid = old_state.m_objectid;
|
||||
sk.min_type = sk.max_type = BTRFS_EXTENT_DATA_KEY;
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren