]>
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 | ||
7c673cae FG |
16 | #include <string> |
17 | ||
1e59de90 TL |
18 | #include "rocksdb/thread_status.h" |
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[] = { | |
1e59de90 TL |
39 | {ThreadStatus::OP_UNKNOWN, ""}, |
40 | {ThreadStatus::OP_COMPACTION, "Compaction"}, | |
41 | {ThreadStatus::OP_FLUSH, "Flush"}}; | |
7c673cae FG |
42 | |
43 | struct OperationStageInfo { | |
44 | const ThreadStatus::OperationStage stage; | |
45 | const std::string name; | |
46 | }; | |
47 | ||
48 | // A table maintains the mapping from stage type to stage string. | |
49 | // Note that the string must be changed accordingly when the | |
50 | // associated function name changed. | |
51 | static OperationStageInfo global_op_stage_table[] = { | |
1e59de90 TL |
52 | {ThreadStatus::STAGE_UNKNOWN, ""}, |
53 | {ThreadStatus::STAGE_FLUSH_RUN, "FlushJob::Run"}, | |
54 | {ThreadStatus::STAGE_FLUSH_WRITE_L0, "FlushJob::WriteLevel0Table"}, | |
55 | {ThreadStatus::STAGE_COMPACTION_PREPARE, "CompactionJob::Prepare"}, | |
56 | {ThreadStatus::STAGE_COMPACTION_RUN, "CompactionJob::Run"}, | |
57 | {ThreadStatus::STAGE_COMPACTION_PROCESS_KV, | |
58 | "CompactionJob::ProcessKeyValueCompaction"}, | |
59 | {ThreadStatus::STAGE_COMPACTION_INSTALL, "CompactionJob::Install"}, | |
60 | {ThreadStatus::STAGE_COMPACTION_SYNC_FILE, | |
61 | "CompactionJob::FinishCompactionOutputFile"}, | |
62 | {ThreadStatus::STAGE_PICK_MEMTABLES_TO_FLUSH, | |
63 | "MemTableList::PickMemtablesToFlush"}, | |
64 | {ThreadStatus::STAGE_MEMTABLE_ROLLBACK, | |
65 | "MemTableList::RollbackMemtableFlush"}, | |
66 | {ThreadStatus::STAGE_MEMTABLE_INSTALL_FLUSH_RESULTS, | |
67 | "MemTableList::TryInstallMemtableFlushResults"}, | |
7c673cae FG |
68 | }; |
69 | ||
70 | // The structure that describes a state. | |
71 | struct StateInfo { | |
72 | const ThreadStatus::StateType type; | |
73 | const std::string name; | |
74 | }; | |
75 | ||
76 | // The global state table. | |
77 | // | |
78 | // When updating a status of a thread, the pointer of the StateInfo | |
79 | // of the current ThreadStatusData will be pointing to one of the | |
80 | // rows in this global table. | |
81 | static StateInfo global_state_table[] = { | |
1e59de90 TL |
82 | {ThreadStatus::STATE_UNKNOWN, ""}, |
83 | {ThreadStatus::STATE_MUTEX_WAIT, "Mutex Wait"}, | |
7c673cae FG |
84 | }; |
85 | ||
86 | struct OperationProperty { | |
87 | int code; | |
88 | std::string name; | |
89 | }; | |
90 | ||
91 | static OperationProperty compaction_operation_properties[] = { | |
1e59de90 TL |
92 | {ThreadStatus::COMPACTION_JOB_ID, "JobID"}, |
93 | {ThreadStatus::COMPACTION_INPUT_OUTPUT_LEVEL, "InputOutputLevel"}, | |
94 | {ThreadStatus::COMPACTION_PROP_FLAGS, "Manual/Deletion/Trivial"}, | |
95 | {ThreadStatus::COMPACTION_TOTAL_INPUT_BYTES, "TotalInputBytes"}, | |
96 | {ThreadStatus::COMPACTION_BYTES_READ, "BytesRead"}, | |
97 | {ThreadStatus::COMPACTION_BYTES_WRITTEN, "BytesWritten"}, | |
7c673cae FG |
98 | }; |
99 | ||
100 | static OperationProperty flush_operation_properties[] = { | |
1e59de90 TL |
101 | {ThreadStatus::FLUSH_JOB_ID, "JobID"}, |
102 | {ThreadStatus::FLUSH_BYTES_MEMTABLES, "BytesMemtables"}, | |
103 | {ThreadStatus::FLUSH_BYTES_WRITTEN, "BytesWritten"}}; | |
7c673cae FG |
104 | |
105 | #else | |
106 | ||
1e59de90 | 107 | struct OperationInfo {}; |
7c673cae | 108 | |
1e59de90 | 109 | struct StateInfo {}; |
7c673cae FG |
110 | |
111 | #endif // ROCKSDB_USING_THREAD_STATUS | |
f67539c2 | 112 | } // namespace ROCKSDB_NAMESPACE |