From 1a0cef88db0131aabbf5f52f567d354b8638e8f4 Mon Sep 17 00:00:00 2001 From: Jie Yao Date: Sat, 29 Jun 2024 08:53:55 +0800 Subject: [PATCH] disable slab by default in metaservice (#459) --- conanfile.py | 2 +- src/lib/device/device.h | 6 ++++-- src/lib/device/device_manager.cpp | 1 + src/lib/device/virtual_dev.cpp | 10 ++++++---- src/lib/device/virtual_dev.hpp | 1 + src/lib/meta/meta_blk_service.cpp | 13 +++++++++---- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/conanfile.py b/conanfile.py index 683f93982..b5f6e83f8 100644 --- a/conanfile.py +++ b/conanfile.py @@ -5,7 +5,7 @@ class HomestoreConan(ConanFile): name = "homestore" - version = "6.4.23" + version = "6.4.24" homepage = "https://github.com/eBay/Homestore" description = "HomeStore Storage Engine" topics = ("ebay", "nublox") diff --git a/src/lib/device/device.h b/src/lib/device/device.h index 8bc9c11aa..16442e82f 100644 --- a/src/lib/device/device.h +++ b/src/lib/device/device.h @@ -52,8 +52,9 @@ struct vdev_info { uint16_t checksum{0}; // 97: Checksum of this entire Block uint8_t alloc_type; // 98: Allocator type of this vdev uint8_t chunk_sel_type; // 99: Chunk Selector type of this vdev_id - uint8_t padding[155]{}; // 100: Pad to make it 256 bytes total - uint8_t user_private[user_private_size]{}; // 128: User specific information + uint8_t use_slab_allocator{0}; // 100: Use slab allocator for this vdev + uint8_t padding[154]{}; // 101: Padding to make it 256 bytes + uint8_t user_private[user_private_size]{}; // 128: User sepcific information uint32_t get_vdev_id() const { return vdev_id; } uint64_t get_size() const { return vdev_size; } @@ -108,6 +109,7 @@ struct vdev_parameters { chunk_selector_type_t chunk_sel_type; // which chunk selector type this vdev wants to be with; vdev_multi_pdev_opts_t multi_pdev_opts; // How data to be placed on multiple vdevs sisl::blob context_data; // Context data about this vdev + bool use_slab_allocator{false}; // Use slab allocator for this vdev }; class VirtualDev; diff --git a/src/lib/device/device_manager.cpp b/src/lib/device/device_manager.cpp index 3fe811de5..5d16fc601 100644 --- a/src/lib/device/device_manager.cpp +++ b/src/lib/device/device_manager.cpp @@ -539,6 +539,7 @@ static void populate_vdev_info(const vdev_parameters& vparam, uint32_t vdev_id, out_info->alloc_type = s_cast< uint8_t >(vparam.alloc_type); out_info->chunk_sel_type = s_cast< uint8_t >(vparam.chunk_sel_type); out_info->size_type = vparam.size_type; + out_info->use_slab_allocator = vparam.use_slab_allocator ? 1 : 0; out_info->compute_checksum(); } diff --git a/src/lib/device/virtual_dev.cpp b/src/lib/device/virtual_dev.cpp index 79aaf0475..ae4cf5d18 100644 --- a/src/lib/device/virtual_dev.cpp +++ b/src/lib/device/virtual_dev.cpp @@ -54,7 +54,8 @@ namespace homestore { static std::shared_ptr< BlkAllocator > create_blk_allocator(blk_allocator_type_t btype, uint32_t vblock_size, uint32_t ppage_sz, uint32_t align_sz, uint64_t size, - bool is_auto_recovery, uint32_t unique_id, bool is_init) { + bool is_auto_recovery, uint32_t unique_id, bool is_init, + bool use_slab_in_blk_allocator) { switch (btype) { case blk_allocator_type_t::fixed: { BlkAllocConfig cfg{vblock_size, align_sz, size, is_auto_recovery, @@ -68,7 +69,7 @@ static std::shared_ptr< BlkAllocator > create_blk_allocator(blk_allocator_type_t size, is_auto_recovery, std::string("varsize_chunk_") + std::to_string(unique_id), - is_data_drive_hdd() ? false : true /* use_slabs */}; + !is_data_drive_hdd() && use_slab_in_blk_allocator /* use_slabs */}; // HS_DBG_ASSERT_EQ((size % MIN_DATA_CHUNK_SIZE(ppage_sz)), 0); return std::make_shared< VarsizeBlkAllocator >(cfg, is_init, unique_id); } @@ -92,7 +93,8 @@ VirtualDev::VirtualDev(DeviceManager& dmgr, vdev_info const& vinfo, vdev_event_c m_metrics{vinfo.name}, m_allocator_type{vinfo.alloc_type}, m_chunk_selector_type{vinfo.chunk_sel_type}, - m_auto_recovery{is_auto_recovery} { + m_auto_recovery{is_auto_recovery}, + m_use_slab_in_blk_allocator{vinfo.use_slab_allocator ? true : false} { switch (m_chunk_selector_type) { case chunk_selector_type_t::ROUND_ROBIN: { m_chunk_selector = std::make_shared< RoundRobinChunkSelector >(false /* dynamically add chunk */); @@ -117,7 +119,7 @@ void VirtualDev::add_chunk(cshared< Chunk >& chunk, bool is_fresh_chunk) { std::unique_lock lg{m_mgmt_mutex}; auto ba = create_blk_allocator(m_allocator_type, block_size(), chunk->physical_dev()->optimal_page_size(), chunk->physical_dev()->align_size(), chunk->size(), m_auto_recovery, - chunk->chunk_id(), is_fresh_chunk); + chunk->chunk_id(), is_fresh_chunk, m_use_slab_in_blk_allocator); chunk->set_block_allocator(std::move(ba)); // TODO: when vdev_ordinal is used, revisit here to make sure it is set correctly; chunk->set_vdev_ordinal(m_total_chunk_num++); diff --git a/src/lib/device/virtual_dev.hpp b/src/lib/device/virtual_dev.hpp index cba4d826e..6901be0f4 100644 --- a/src/lib/device/virtual_dev.hpp +++ b/src/lib/device/virtual_dev.hpp @@ -99,6 +99,7 @@ class VirtualDev { blk_allocator_type_t m_allocator_type; chunk_selector_type_t m_chunk_selector_type; bool m_auto_recovery; + bool m_use_slab_in_blk_allocator; public: VirtualDev(DeviceManager& dmgr, const vdev_info& vinfo, vdev_event_cb_t event_cb, bool is_auto_recovery, diff --git a/src/lib/meta/meta_blk_service.cpp b/src/lib/meta/meta_blk_service.cpp index acc48ccf3..1b93dc203 100644 --- a/src/lib/meta/meta_blk_service.cpp +++ b/src/lib/meta/meta_blk_service.cpp @@ -465,7 +465,9 @@ void MetaBlkService::write_ovf_blk_to_disk(meta_blk_ovf_hdr* ovf_hdr, const uint size_t write_size = ovf_hdr->h.context_sz; uint8_t* context_data_aligned{nullptr}; if (!hs_utils::is_ptr_aligned(write_context_data, align_sz) || !hs_utils::mod_aligned_sz(write_size, align_sz)) { - HS_LOG_EVERY_N(WARN, metablk, 50, "[type={}] Unaligned address found for input context_data, ptr {}, size {}, align {} ", type, (void *)write_context_data, write_size, align_sz); + HS_LOG_EVERY_N(WARN, metablk, 50, + "[type={}] Unaligned address found for input context_data, ptr {}, size {}, align {} ", type, + (void*)write_context_data, write_size, align_sz); const size_t aligned_write_size = uint64_cast(sisl::round_up(write_size, align_sz)); context_data_aligned = hs_utils::iobuf_alloc(aligned_write_size, sisl::buftag::metablk, align_size()); std::memcpy(context_data_aligned, write_context_data, write_size); @@ -507,7 +509,9 @@ void MetaBlkService::write_ovf_blk_to_disk(meta_blk_ovf_hdr* ovf_hdr, const uint } // check if the buffer is aligned - HS_REL_ASSERT(hs_utils::is_ptr_aligned(cur_ptr, align_sz) || hs_utils::mod_aligned_sz(cur_size, align_sz), "Unaligned address found for input context_data, ptr {}, size {}, align {} ", (void *)cur_ptr, cur_size, align_sz); + HS_REL_ASSERT(hs_utils::is_ptr_aligned(cur_ptr, align_sz) || hs_utils::mod_aligned_sz(cur_size, align_sz), + "Unaligned address found for input context_data, ptr {}, size {}, align {} ", (void*)cur_ptr, + cur_size, align_sz); auto error = m_sb_vdev->sync_write(r_cast< const char* >(cur_ptr), cur_size, data_bid[i]); if (error.value()) { // the offset and buffer length is printed in the error messages of iomgr. @@ -611,8 +615,9 @@ void MetaBlkService::write_meta_blk_ovf(BlkId& out_obid, const uint8_t* context_ context_data_blkids.clear(); alloc_meta_blks(sisl::round_up(sz, block_size()), context_data_blkids); - HS_LOG(DEBUG, metablk, "Context data size {}, rounded up to {}, block_size {}, allocated {} blkIDs, mstore used size: {}", sz, sisl::round_up(sz, block_size()), block_size(), context_data_blkids.size(), - m_sb_vdev->used_size()); + HS_LOG(DEBUG, metablk, + "Context data size {}, rounded up to {}, block_size {}, allocated {} blkIDs, mstore used size: {}", sz, + sisl::round_up(sz, block_size()), block_size(), context_data_blkids.size(), m_sb_vdev->used_size()); // return the 1st ovf header blk id to caller; alloc_meta_blk(out_obid);