Skip to content
Snippets Groups Projects
Commit 1047bc11 authored by Nick Zavaritsky's avatar Nick Zavaritsky
Browse files

gh-885: Trim thread pool once recovery ends

parent 935cb311
No related branches found
No related tags found
No related merge requests found
......@@ -607,6 +607,25 @@ engine_init()
engine_register(sophia);
}
/**
* @brief Reduce the current number of threads in the thread pool to the
* bare minimum. Doesn't prevent the pool from spawning new threads later
* if demand mounts.
*/
static void
thread_pool_trim()
{
/*
* Trim OpenMP thread pool.
* Though we lack the direct control the workaround below works for
* GNU OpenMP library. The library stops surplus threads on entering
* a parallel region. Can't go below 2 threads due to the
* implementation quirk.
*/
#pragma omp parallel num_threads(2)
;
}
static inline void
box_init(void)
{
......@@ -677,6 +696,11 @@ box_init(void)
engine_end_recovery();
/*
* Recovery inflates the thread pool quite a bit (due to parallel sort).
*/
thread_pool_trim();
rmean_cleanup(rmean_box);
if (recovery_has_replica(recovery))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment