Skip to content

Commit

Permalink
disable slab by default in metaservice (#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonYao287 authored Jun 29, 2024
1 parent 372f04a commit 1a0cef8
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 4 additions & 2 deletions src/lib/device/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/lib/device/device_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
10 changes: 6 additions & 4 deletions src/lib/device/virtual_dev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
}
Expand All @@ -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 */);
Expand All @@ -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++);
Expand Down
1 change: 1 addition & 0 deletions src/lib/device/virtual_dev.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 9 additions & 4 deletions src/lib/meta/meta_blk_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 1a0cef8

Please sign in to comment.