Skip to content

Commit bd1105a

Browse files
committed
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
1 parent 3df07d1 commit bd1105a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

util/env_posix.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,8 +1479,7 @@ class PosixEnv : public Env {
14791479
// Always terminate the running thread that is added last, even if there are
14801480
// more than one thread to terminate.
14811481
bool IsLastExcessiveThread(size_t thread_id) {
1482-
return HasExcessiveThread() &&
1483-
thread_id == bgthreads_.size() - 1;
1482+
return HasExcessiveThread() && thread_id == bgthreads_.size() - 1;
14841483
}
14851484

14861485
// Is one of the threads to terminate.
@@ -1505,13 +1504,18 @@ class PosixEnv : public Env {
15051504
// Current thread is the last generated one and is excessive.
15061505
// We always terminate excessive thread in the reverse order of
15071506
// generation time.
1508-
pthread_detach(bgthreads_.back());
1507+
auto terminating_thread = bgthreads_.back();
1508+
pthread_detach(terminating_thread);
15091509
bgthreads_.pop_back();
15101510
if (HasExcessiveThread()) {
15111511
// There is still at least more excessive thread to terminate.
15121512
WakeUpAllThreads();
15131513
}
15141514
PthreadCall("unlock", pthread_mutex_unlock(&mu_));
1515+
// TODO(sdong): temp logging. Need to help debugging. Remove it when
1516+
// the feature is proved to be stable.
1517+
fprintf(stdout, "Bg thread %zu terminates %llx\n", thread_id,
1518+
static_cast<long long unsigned int>(terminating_thread));
15151519
break;
15161520
}
15171521
void (*function)(void*) = queue_.front().function;

0 commit comments

Comments
 (0)