diff options
author | Yueh-Hsuan Chiang <yhchiang@fb.com> | 2015-05-06 22:50:35 -0700 |
---|---|---|
committer | Yueh-Hsuan Chiang <yhchiang@fb.com> | 2015-05-06 22:51:06 -0700 |
commit | 77a5a543a59aa38018e9e8f3535d888ee5275d49 (patch) | |
tree | b23b96fb2c08464cf21a7a67b6d8aba987ee8540 /include | |
parent | 65fe1cfbb397a580b4ca25999a5b39c66a029a83 (diff) |
Allow GetThreadList() to report basic compaction operation properties.
Summary:
Now we're able to show more details about a compaction in
GetThreadList() :)
This patch allows GetThreadList() to report basic compaction
operation properties. Basic compaction properties include:
1. job id
2. compaction input / output level
3. compaction property flags (is_manual, is_deletion, .. etc)
4. total input bytes
5. the number of bytes has been read currently.
6. the number of bytes has been written currently.
Flush operation properties will be done in a seperate diff.
Test Plan:
/db_bench --threads=30 --num=1000000 --benchmarks=fillrandom --thread_status_per_interval=1
Sample output of tracking same job:
ThreadID ThreadType cfName Operation ElapsedTime Stage State OperationProperties
140664171987072 Low Pri default Compaction 31.357 ms CompactionJob::FinishCompactionOutputFile BaseInputLevel 1 | BytesRead 2264663 | BytesWritten 1934241 | IsDeletion 0 | IsManual 0 | IsTrivialMove 0 | JobID 277 | OutputLevel 2 | TotalInputBytes 3964158 |
ThreadID ThreadType cfName Operation ElapsedTime Stage State OperationProperties
140664171987072 Low Pri default Compaction 59.440 ms CompactionJob::FinishCompactionOutputFile BaseInputLevel 1 | BytesRead 2264663 | BytesWritten 1934241 | IsDeletion 0 | IsManual 0 | IsTrivialMove 0 | JobID 277 | OutputLevel 2 | TotalInputBytes 3964158 |
ThreadID ThreadType cfName Operation ElapsedTime Stage State OperationProperties
140664171987072 Low Pri default Compaction 226.375 ms CompactionJob::Install BaseInputLevel 1 | BytesRead 3958013 | BytesWritten 3621940 | IsDeletion 0 | IsManual 0 | IsTrivialMove 0 | JobID 277 | OutputLevel 2 | TotalInputBytes 3964158 |
Reviewers: sdong, rven, igor
Reviewed By: igor
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D37653
Diffstat (limited to 'include')
-rw-r--r-- | include/rocksdb/thread_status.h | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/include/rocksdb/thread_status.h b/include/rocksdb/thread_status.h index 9767fa3bb..7bb304c2b 100644 --- a/include/rocksdb/thread_status.h +++ b/include/rocksdb/thread_status.h @@ -14,7 +14,10 @@ #pragma once #include <cstddef> +#include <map> #include <string> +#include <utility> +#include <vector> #ifndef ROCKSDB_USING_THREAD_STATUS #define ROCKSDB_USING_THREAD_STATUS \ @@ -64,6 +67,28 @@ struct ThreadStatus { NUM_OP_STAGES }; + // The maximum number of properties of an operation. + // This number should be set to the biggest NUM_XXX_PROPERTIES. + static const int kNumOperationProperties = 6; + + enum CompactionPropertyType : int { + COMPACTION_JOB_ID = 0, + COMPACTION_INPUT_OUTPUT_LEVEL, + COMPACTION_PROP_FLAGS, + COMPACTION_TOTAL_INPUT_BYTES, + COMPACTION_BYTES_READ, + COMPACTION_BYTES_WRITTEN, + NUM_COMPACTION_PROPERTIES + }; + + enum FlushPropertyType : int { + FLUSH_JOB_ID = 0, + FLUSH_BYTES_READ, + FLUSH_BYTES_REMAIN, + FLUSH_BYTES_WRITTEN, + NUM_FLUSH_PROPERTIES + }; + // The type used to refer to a thread state. // A state describes lower-level action of a thread // such as reading / writing a file or waiting for a mutex. @@ -80,6 +105,7 @@ struct ThreadStatus { const OperationType _operation_type, const uint64_t _op_elapsed_micros, const OperationStage _operation_stage, + const uint64_t _op_props[], const StateType _state_type) : thread_id(_id), thread_type(_thread_type), db_name(_db_name), @@ -87,7 +113,11 @@ struct ThreadStatus { operation_type(_operation_type), op_elapsed_micros(_op_elapsed_micros), operation_stage(_operation_stage), - state_type(_state_type) {} + state_type(_state_type) { + for (int i = 0; i < kNumOperationProperties; ++i) { + op_properties[i] = _op_props[i]; + } + } // An unique ID for the thread. const uint64_t thread_id; @@ -116,6 +146,11 @@ struct ThreadStatus { // in the current operation. const OperationStage operation_stage; + // A list of properties that describe some details about the current + // operation. Same field in op_properties[] might have different + // meanings for different operations. + uint64_t op_properties[kNumOperationProperties]; + // The state (lower-level action) that the current thread is involved. const StateType state_type; @@ -133,6 +168,17 @@ struct ThreadStatus { static const std::string& GetOperationStageName( OperationStage stage); + // Obtain the name of the "i"th operation property of the + // specified operation. + static const std::string& GetOperationPropertyName( + OperationType op_type, int i); + + // Translate the "i"th property of the specified operation given + // a property value. + static std::map<std::string, uint64_t> + InterpretOperationProperties( + OperationType op_type, uint64_t* op_properties); + // Obtain the name of a state given its type. static const std::string& GetStateName(StateType state_type); }; |