]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // Copyright (c) 2011-present, Facebook, Inc. All rights reserved. |
11fdf7f2 TL |
2 | // This source code is licensed under both the GPLv2 (found in the |
3 | // COPYING file in the root directory) and Apache 2.0 License | |
4 | // (found in the LICENSE.Apache file in the root directory). | |
7c673cae FG |
5 | // |
6 | // This file defines the structures for thread operation and state. | |
7 | // Thread operations are used to describe high level action of a | |
8 | // thread such as doing compaction or flush, while thread state | |
9 | // are used to describe lower-level action such as reading / | |
10 | // writing a file or waiting for a mutex. Operations and states | |
11 | // are designed to be independent. Typically, a thread usually involves | |
12 | // in one operation and one state at any specific point in time. | |
13 | ||
14 | #pragma once | |
15 | ||
16 | #include "rocksdb/thread_status.h" | |
17 | ||
18 | #include <string> | |
19 | ||
f67539c2 | 20 | namespace ROCKSDB_NAMESPACE { |
7c673cae FG |
21 | |
22 | #ifdef ROCKSDB_USING_THREAD_STATUS | |
23 | ||
24 | // The structure that describes a major thread operation. | |
25 | struct OperationInfo { | |
26 | const ThreadStatus::OperationType type; | |
27 | const std::string name; | |
28 | }; | |
29 | ||
30 | // The global operation table. | |
31 | // | |
32 | // When updating a status of a thread, the pointer of the OperationInfo | |
33 | // of the current ThreadStatusData will be pointing to one of the | |
34 | // rows in this global table. | |
35 | // | |
36 | // Note that it's not designed to be constant as in the future we | |
37 | // might consider adding global count to the OperationInfo. | |
38 | static OperationInfo global_operation_table[] = { | |
39 | {ThreadStatus::OP_UNKNOWN, ""}, | |
40 | {ThreadStatus::OP_COMPACTION, "Compaction"}, | |
41 | {ThreadStatus::OP_FLUSH, "Flush"} | |
42 | }; | |
43 | ||
44 | struct OperationStageInfo { | |
45 | const ThreadStatus::OperationStage stage; | |
46 | const std::string name; | |
47 | }; | |
48 | ||
49 | // A table maintains the mapping from stage type to stage string. | |
50 | // Note that the string must be changed accordingly when the | |
51 | // associated function name changed. | |
52 | static OperationStageInfo global_op_stage_table[] = { | |
53 | {ThreadStatus::STAGE_UNKNOWN, ""}, | |
54 | {ThreadStatus::STAGE_FLUSH_RUN, | |
55 | "FlushJob::Run"}, | |
56 | {ThreadStatus::STAGE_FLUSH_WRITE_L0, | |
57 | "FlushJob::WriteLevel0Table"}, | |
58 | {ThreadStatus::STAGE_COMPACTION_PREPARE, | |
59 | "CompactionJob::Prepare"}, | |
60 | {ThreadStatus::STAGE_COMPACTION_RUN, | |
61 | "CompactionJob::Run"}, | |
62 | {ThreadStatus::STAGE_COMPACTION_PROCESS_KV, | |
63 | "CompactionJob::ProcessKeyValueCompaction"}, | |
64 | {ThreadStatus::STAGE_COMPACTION_INSTALL, | |
65 | "CompactionJob::Install"}, | |
66 | {ThreadStatus::STAGE_COMPACTION_SYNC_FILE, | |
67 | "CompactionJob::FinishCompactionOutputFile"}, | |
68 | {ThreadStatus::STAGE_PICK_MEMTABLES_TO_FLUSH, | |
69 | "MemTableList::PickMemtablesToFlush"}, | |
70 | {ThreadStatus::STAGE_MEMTABLE_ROLLBACK, | |
71 | "MemTableList::RollbackMemtableFlush"}, | |
72 | {ThreadStatus::STAGE_MEMTABLE_INSTALL_FLUSH_RESULTS, | |
494da23a | 73 | "MemTableList::TryInstallMemtableFlushResults"}, |
7c673cae FG |
74 | }; |
75 | ||
76 | // The structure that describes a state. | |
77 | struct StateInfo { | |
78 | const ThreadStatus::StateType type; | |
79 | const std::string name; | |
80 | }; | |
81 | ||
82 | // The global state table. | |
83 | // | |
84 | // When updating a status of a thread, the pointer of the StateInfo | |
85 | // of the current ThreadStatusData will be pointing to one of the | |
86 | // rows in this global table. | |
87 | static StateInfo global_state_table[] = { | |
88 | {ThreadStatus::STATE_UNKNOWN, ""}, | |
89 | {ThreadStatus::STATE_MUTEX_WAIT, "Mutex Wait"}, | |
90 | }; | |
91 | ||
92 | struct OperationProperty { | |
93 | int code; | |
94 | std::string name; | |
95 | }; | |
96 | ||
97 | static OperationProperty compaction_operation_properties[] = { | |
98 | {ThreadStatus::COMPACTION_JOB_ID, "JobID"}, | |
99 | {ThreadStatus::COMPACTION_INPUT_OUTPUT_LEVEL, "InputOutputLevel"}, | |
100 | {ThreadStatus::COMPACTION_PROP_FLAGS, "Manual/Deletion/Trivial"}, | |
101 | {ThreadStatus::COMPACTION_TOTAL_INPUT_BYTES, "TotalInputBytes"}, | |
102 | {ThreadStatus::COMPACTION_BYTES_READ, "BytesRead"}, | |
103 | {ThreadStatus::COMPACTION_BYTES_WRITTEN, "BytesWritten"}, | |
104 | }; | |
105 | ||
106 | static OperationProperty flush_operation_properties[] = { | |
107 | {ThreadStatus::FLUSH_JOB_ID, "JobID"}, | |
108 | {ThreadStatus::FLUSH_BYTES_MEMTABLES, "BytesMemtables"}, | |
109 | {ThreadStatus::FLUSH_BYTES_WRITTEN, "BytesWritten"} | |
110 | }; | |
111 | ||
112 | #else | |
113 | ||
114 | struct OperationInfo { | |
115 | }; | |
116 | ||
117 | struct StateInfo { | |
118 | }; | |
119 | ||
120 | #endif // ROCKSDB_USING_THREAD_STATUS | |
f67539c2 | 121 | } // namespace ROCKSDB_NAMESPACE |