Skip to content

Commit

Permalink
fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadim Sadokhov committed Aug 16, 2023
1 parent a6bb662 commit 88fe330
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion compiler/pipes/register-kphp-configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ void RegisterKphpConfiguration::handle_constant_runtime_options(const ClassMembe
register_net_dc_mask(opt_pair->value());
} else if (vk::any_of_equal(*opt_key,
warmup_workers_part_key_, warmup_instance_cache_elements_part_key_, warmup_timeout_sec_key_,
oom_handling_memory_ratio_key_/*, thread_pool_ratio_key_*/)) {
oom_handling_memory_ratio_key_, thread_pool_ratio_key_)) {
generic_register_simple_option(opt_pair->value(), *opt_key);
} else {
kphp_error(0, fmt_format("Got unexpected option {}::{}['{}']",
Expand Down
2 changes: 1 addition & 1 deletion compiler/pipes/register-kphp-configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class RegisterKphpConfiguration final : public SyncPipeF<FunctionPtr> {

const vk::string_view oom_handling_memory_ratio_key_{"--oom-handling-memory-ratio"};

// const vk::string_view thread_pool_ratio_key_{"--thread-pool-ratio"};
const vk::string_view thread_pool_ratio_key_{"--thread-pool-ratio"};

public:
void execute(FunctionPtr function, DataStream<FunctionPtr> &unused_os) final;
Expand Down
4 changes: 2 additions & 2 deletions runtime/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2369,7 +2369,7 @@ static void init_runtime_libs() {

init_interface_lib();

// vk::singleton<ThreadPool>::get().init();
vk::singleton<ThreadPool>::get().init();
}

static void free_shutdown_functions() {
Expand All @@ -2395,7 +2395,7 @@ static void free_interface_lib() {
static void free_runtime_libs() {
php_assert (dl::in_critical_section == 0);

// vk::singleton<ThreadPool>::get().stop();
vk::singleton<ThreadPool>::get().stop();

forcibly_stop_and_flush_profiler();
free_bcmath_lib();
Expand Down
3 changes: 1 addition & 2 deletions runtime/thread-pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
void ThreadPool::init() noexcept {
int thread_pool_size = static_cast<int>(std::thread::hardware_concurrency() * thread_pool_ratio);
if (thread_pool_size > 0 && !is_thread_pool_available()) {
new (&thread_pool_storage) BS::thread_pool(thread_pool_size);
thread_pool_ptr = reinterpret_cast<BS::thread_pool *>(&thread_pool_storage);
thread_pool_ptr = new BS::thread_pool(thread_pool_size);
}
}

Expand Down
6 changes: 3 additions & 3 deletions runtime/thread-pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class ThreadPool : vk::not_copyable {
/** Here we need to stop all running threads to ensure independence of requests
* todo find a way to kill threads. It can be done by pthread_kill
* */
thread_pool_ptr->wait_for_tasks();
if (thread_pool_ptr != nullptr) {
thread_pool_ptr->wait_for_tasks();
}
}


Expand All @@ -36,8 +38,6 @@ class ThreadPool : vk::not_copyable {
friend class vk::singleton<ThreadPool>;

BS::thread_pool * thread_pool_ptr{nullptr};

std::aligned_storage_t<sizeof(BS::thread_pool), alignof(BS::thread_pool)> thread_pool_storage;
};

extern double thread_pool_ratio;

0 comments on commit 88fe330

Please sign in to comment.