Skip to content

Commit

Permalink
Merge pull request #38 from shosseinimotlagh/take_fiber_nums
Browse files Browse the repository at this point in the history
SDSTOR-11538 : Take number of fibers from callers when iomgr starts
  • Loading branch information
shosseinimotlagh authored Aug 9, 2023
2 parents b2e5867 + 1eb4641 commit bedc7fa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 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 IOMgrConan(ConanFile):
name = "iomgr"
version = "9.2.1"
version = "9.2.2"
homepage = "https://github.com/eBay/IOManager"
description = "Asynchronous event manager"
topics = ("ebay", "nublox", "aio")
Expand Down
4 changes: 2 additions & 2 deletions src/include/iomgr/iomgr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ENUM(iomgr_state, uint16_t,
struct iomgr_params {
size_t num_threads{0};
bool is_spdk{false};
uint32_t num_fibers{4};
uint32_t num_fibers{0};
uint32_t app_mem_size_mb{0};
uint32_t hugepage_size_mb{0};
};
Expand Down Expand Up @@ -300,7 +300,7 @@ class IOManager {
~IOManager();

void foreach_interface(const interface_cb_t& iface_cb);
void create_worker_reactors();
void create_worker_reactors(uint32_t num_fibers);
void _run_io_loop(int iomgr_slot_num, loop_type_t loop_type, uint32_t num_fibers, const std::string& name,
const iodev_selector_t& iodev_selector, thread_state_notifier_t&& addln_notifier);

Expand Down
9 changes: 6 additions & 3 deletions src/lib/iomgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ void IOManager::start(const iomgr_params& params, const thread_state_notifier_t&

// Start all reactor threads
set_state(iomgr_state::reactor_init);
create_worker_reactors();


// Caller can override the number of fibers per thread; o.w., it is taken from dynamic config
create_worker_reactors((0 < params.num_fibers) ? params.num_fibers : IM_DYNAMIC_CONFIG(thread.num_fibers));
wait_for_state(iomgr_state::sys_init);

// Start the global timer
Expand Down Expand Up @@ -226,7 +229,7 @@ void IOManager::stop() {
LOGINFO("IOManager Stopped and all IO threads are relinquished");
}

void IOManager::create_worker_reactors() {
void IOManager::create_worker_reactors(uint32_t num_fibers) {
// First populate the full sparse vector of m_worker_reactors before starting workers.
for (uint32_t i{0}; i < m_num_workers; ++i) {
m_worker_reactors.push_back(nullptr);
Expand All @@ -235,7 +238,7 @@ void IOManager::create_worker_reactors() {
for (uint32_t i{0}; i < m_num_workers; ++i) {
m_worker_threads.emplace_back(
m_impl->create_reactor_impl(fmt::format("iomgr_thread_{}", i), m_is_spdk ? TIGHT_LOOP : INTERRUPT_LOOP,
IM_DYNAMIC_CONFIG(thread.num_fibers), (int)i, nullptr));
num_fibers, (int)i, nullptr));
LOGDEBUGMOD(iomgr, "Created iomanager worker reactor thread {}...", i);
}
}
Expand Down

0 comments on commit bedc7fa

Please sign in to comment.