include thread-pool priority in thread names
Summary: Previously threads were named "rocksdb:bg\<index in thread pool\>", so the first thread in all thread pools would be named "rocksdb:bg0". Users want to be able to distinguish threads used for flush (high-pri) vs regular compaction (low-pri) vs compaction to bottom-level (bottom-pri). So I changed the thread naming convention to include the thread-pool priority. Closes https://github.com/facebook/rocksdb/pull/3702 Differential Revision: D7581415 Pulled By: ajkr fbshipit-source-id: ce04482b6acd956a401ef22dc168b84f76f7d7c1
This commit is contained in:
parent
6d06be22c0
commit
3cea61392f
@ -2,6 +2,7 @@
|
||||
## Unreleased
|
||||
### Public API Change
|
||||
* Add a BlockBasedTableOption to align uncompressed data blocks on the smaller of block size or page size boundary, to reduce flash reads by avoiding reads spanning 4K pages.
|
||||
* The background thread naming convention changed (on supporting platforms) to "rocksdb:<thread pool priority><thread number>", e.g., "rocksdb:low0".
|
||||
|
||||
### New Features
|
||||
* Introduce TTL for level compaction so that all files older than ttl go through the compaction process to get rid of old data.
|
||||
|
14
env/env.cc
vendored
14
env/env.cc
vendored
@ -22,6 +22,20 @@ namespace rocksdb {
|
||||
Env::~Env() {
|
||||
}
|
||||
|
||||
std::string Env::PriorityToString(Env::Priority priority) {
|
||||
switch (priority) {
|
||||
case Env::Priority::BOTTOM:
|
||||
return "Bottom";
|
||||
case Env::Priority::LOW:
|
||||
return "Low";
|
||||
case Env::Priority::HIGH:
|
||||
return "High";
|
||||
case Env::Priority::TOTAL:
|
||||
assert(false);
|
||||
}
|
||||
return "Invalid";
|
||||
}
|
||||
|
||||
uint64_t Env::GetThreadID() const {
|
||||
std::hash<std::thread::id> hasher;
|
||||
return hasher(std::this_thread::get_id());
|
||||
|
@ -302,6 +302,8 @@ class Env {
|
||||
// Priority for scheduling job in thread pool
|
||||
enum Priority { BOTTOM, LOW, HIGH, TOTAL };
|
||||
|
||||
static std::string PriorityToString(Priority priority);
|
||||
|
||||
// Priority for requesting bytes in rate limiter scheduler
|
||||
enum IOPriority {
|
||||
IO_LOW = 0,
|
||||
|
@ -20,11 +20,12 @@
|
||||
# include <sys/syscall.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <stdlib.h>
|
||||
#include <sstream>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
@ -313,11 +314,14 @@ void ThreadPoolImpl::Impl::StartBGThreads() {
|
||||
#if defined(_GNU_SOURCE) && defined(__GLIBC_PREREQ)
|
||||
#if __GLIBC_PREREQ(2, 12)
|
||||
auto th_handle = p_t.native_handle();
|
||||
char name_buf[16];
|
||||
snprintf(name_buf, sizeof name_buf, "rocksdb:bg%" ROCKSDB_PRIszt,
|
||||
bgthreads_.size());
|
||||
name_buf[sizeof name_buf - 1] = '\0';
|
||||
pthread_setname_np(th_handle, name_buf);
|
||||
std::string thread_priority = Env::PriorityToString(GetThreadPriority());
|
||||
std::ostringstream thread_name_stream;
|
||||
thread_name_stream << "rocksdb:";
|
||||
for (char c : thread_priority) {
|
||||
thread_name_stream << static_cast<char>(tolower(c));
|
||||
}
|
||||
thread_name_stream << bgthreads_.size();
|
||||
pthread_setname_np(th_handle, thread_name_stream.str().c_str());
|
||||
#endif
|
||||
#endif
|
||||
bgthreads_.push_back(std::move(p_t));
|
||||
|
Loading…
Reference in New Issue
Block a user