Print out thread ID while thread terminates for decreased pool size.

Summary: Per request from @nkg-, temporarily print thread ID when a thread terminates. It is a temp solution as we try to minimized stderr messages.

Test Plan: env_test

Reviewers: haobo, igor, dhruba

Reviewed By: igor

CC: nkg-, leveldb

Differential Revision: https://reviews.facebook.net/D18753
main
sdong 11 years ago
parent 3df07d1703
commit bd1105aa5a
  1. 10
      util/env_posix.cc

@ -1479,8 +1479,7 @@ class PosixEnv : public Env {
// Always terminate the running thread that is added last, even if there are // Always terminate the running thread that is added last, even if there are
// more than one thread to terminate. // more than one thread to terminate.
bool IsLastExcessiveThread(size_t thread_id) { bool IsLastExcessiveThread(size_t thread_id) {
return HasExcessiveThread() && return HasExcessiveThread() && thread_id == bgthreads_.size() - 1;
thread_id == bgthreads_.size() - 1;
} }
// Is one of the threads to terminate. // Is one of the threads to terminate.
@ -1505,13 +1504,18 @@ class PosixEnv : public Env {
// Current thread is the last generated one and is excessive. // Current thread is the last generated one and is excessive.
// We always terminate excessive thread in the reverse order of // We always terminate excessive thread in the reverse order of
// generation time. // generation time.
pthread_detach(bgthreads_.back()); auto terminating_thread = bgthreads_.back();
pthread_detach(terminating_thread);
bgthreads_.pop_back(); bgthreads_.pop_back();
if (HasExcessiveThread()) { if (HasExcessiveThread()) {
// There is still at least more excessive thread to terminate. // There is still at least more excessive thread to terminate.
WakeUpAllThreads(); WakeUpAllThreads();
} }
PthreadCall("unlock", pthread_mutex_unlock(&mu_)); PthreadCall("unlock", pthread_mutex_unlock(&mu_));
// TODO(sdong): temp logging. Need to help debugging. Remove it when
// the feature is proved to be stable.
fprintf(stdout, "Bg thread %zu terminates %llx\n", thread_id,
static_cast<long long unsigned int>(terminating_thread));
break; break;
} }
void (*function)(void*) = queue_.front().function; void (*function)(void*) = queue_.front().function;

Loading…
Cancel
Save