Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
T
titan
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fangzongwu
titan
Commits
144e20f0
Unverified
Commit
144e20f0
authored
Sep 12, 2019
by
Wu Jiayu
Committed by
GitHub
Sep 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc breakdown metrics (#73)
parent
715dbd69
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
2 deletions
+42
-2
blob_gc_job.cc
src/blob_gc_job.cc
+9
-0
blob_gc_job.h
src/blob_gc_job.h
+3
-0
titan_stats.cc
src/titan_stats.cc
+13
-2
titan_stats.h
src/titan_stats.h
+17
-0
No files found.
src/blob_gc_job.cc
View file @
144e20f0
...
@@ -151,6 +151,7 @@ Status BlobGCJob::Run() {
...
@@ -151,6 +151,7 @@ Status BlobGCJob::Run() {
}
}
Status
BlobGCJob
::
SampleCandidateFiles
()
{
Status
BlobGCJob
::
SampleCandidateFiles
()
{
TitanStopWatch
sw
(
env_
,
metrics_
.
blob_db_gc_sampling_micros
);
std
::
vector
<
BlobFileMeta
*>
result
;
std
::
vector
<
BlobFileMeta
*>
result
;
for
(
const
auto
&
file
:
blob_gc_
->
inputs
())
{
for
(
const
auto
&
file
:
blob_gc_
->
inputs
())
{
bool
selected
=
false
;
bool
selected
=
false
;
...
@@ -400,6 +401,7 @@ Status BlobGCJob::BuildIterator(
...
@@ -400,6 +401,7 @@ Status BlobGCJob::BuildIterator(
Status
BlobGCJob
::
DiscardEntry
(
const
Slice
&
key
,
const
BlobIndex
&
blob_index
,
Status
BlobGCJob
::
DiscardEntry
(
const
Slice
&
key
,
const
BlobIndex
&
blob_index
,
bool
*
discardable
)
{
bool
*
discardable
)
{
TitanStopWatch
sw
(
env_
,
metrics_
.
blob_db_gc_read_lsm_micros
);
assert
(
discardable
!=
nullptr
);
assert
(
discardable
!=
nullptr
);
PinnableSlice
index_entry
;
PinnableSlice
index_entry
;
bool
is_blob_index
=
false
;
bool
is_blob_index
=
false
;
...
@@ -523,6 +525,7 @@ Status BlobGCJob::InstallOutputBlobFiles() {
...
@@ -523,6 +525,7 @@ Status BlobGCJob::InstallOutputBlobFiles() {
}
}
Status
BlobGCJob
::
RewriteValidKeyToLSM
()
{
Status
BlobGCJob
::
RewriteValidKeyToLSM
()
{
TitanStopWatch
sw
(
env_
,
metrics_
.
blob_db_gc_update_lsm_micros
);
Status
s
;
Status
s
;
auto
*
db_impl
=
reinterpret_cast
<
DBImpl
*>
(
this
->
base_db_
);
auto
*
db_impl
=
reinterpret_cast
<
DBImpl
*>
(
this
->
base_db_
);
...
@@ -620,6 +623,12 @@ void BlobGCJob::UpdateInternalOpStats() {
...
@@ -620,6 +623,12 @@ void BlobGCJob::UpdateInternalOpStats() {
metrics_
.
blob_db_gc_num_files
);
metrics_
.
blob_db_gc_num_files
);
AddStats
(
internal_op_stats
,
InternalOpStatsType
::
OUTPUT_FILE_NUM
,
AddStats
(
internal_op_stats
,
InternalOpStatsType
::
OUTPUT_FILE_NUM
,
metrics_
.
blob_db_gc_num_new_files
);
metrics_
.
blob_db_gc_num_new_files
);
AddStats
(
internal_op_stats
,
InternalOpStatsType
::
GC_SAMPLING_MICROS
,
metrics_
.
blob_db_gc_sampling_micros
);
AddStats
(
internal_op_stats
,
InternalOpStatsType
::
GC_READ_LSM_MICROS
,
metrics_
.
blob_db_gc_read_lsm_micros
);
AddStats
(
internal_op_stats
,
InternalOpStatsType
::
GC_UPDATE_LSM_MICROS
,
metrics_
.
blob_db_gc_update_lsm_micros
);
}
}
}
// namespace titandb
}
// namespace titandb
...
...
src/blob_gc_job.h
View file @
144e20f0
...
@@ -72,6 +72,9 @@ class BlobGCJob {
...
@@ -72,6 +72,9 @@ class BlobGCJob {
uint64_t
blob_db_gc_bytes_relocated
=
0
;
uint64_t
blob_db_gc_bytes_relocated
=
0
;
uint64_t
blob_db_gc_num_new_files
=
0
;
uint64_t
blob_db_gc_num_new_files
=
0
;
uint64_t
blob_db_gc_num_files
=
0
;
uint64_t
blob_db_gc_num_files
=
0
;
uint64_t
blob_db_gc_sampling_micros
=
0
;
uint64_t
blob_db_gc_read_lsm_micros
=
0
;
uint64_t
blob_db_gc_update_lsm_micros
=
0
;
}
metrics_
;
}
metrics_
;
uint64_t
prev_bytes_read_
=
0
;
uint64_t
prev_bytes_read_
=
0
;
...
...
src/titan_stats.cc
View file @
144e20f0
...
@@ -50,6 +50,7 @@ const std::array<std::string,
...
@@ -50,6 +50,7 @@ const std::array<std::string,
void
TitanInternalStats
::
DumpAndResetInternalOpStats
(
LogBuffer
*
log_buffer
)
{
void
TitanInternalStats
::
DumpAndResetInternalOpStats
(
LogBuffer
*
log_buffer
)
{
constexpr
double
GB
=
1.0
*
1024
*
1024
*
1024
;
constexpr
double
GB
=
1.0
*
1024
*
1024
*
1024
;
constexpr
double
SECOND
=
1.0
*
1000000
;
LogToBuffer
(
log_buffer
,
LogToBuffer
(
log_buffer
,
"OP COUNT READ(GB) WRITE(GB) IO_READ(GB) IO_WRITE(GB) "
"OP COUNT READ(GB) WRITE(GB) IO_READ(GB) IO_WRITE(GB) "
" FILE_IN FILE_OUT"
);
" FILE_IN FILE_OUT"
);
...
@@ -59,7 +60,8 @@ void TitanInternalStats::DumpAndResetInternalOpStats(LogBuffer* log_buffer) {
...
@@ -59,7 +60,8 @@ void TitanInternalStats::DumpAndResetInternalOpStats(LogBuffer* log_buffer) {
for
(
int
op
=
0
;
op
<
static_cast
<
int
>
(
InternalOpType
::
INTERNAL_OP_ENUM_MAX
);
for
(
int
op
=
0
;
op
<
static_cast
<
int
>
(
InternalOpType
::
INTERNAL_OP_ENUM_MAX
);
op
++
)
{
op
++
)
{
LogToBuffer
(
LogToBuffer
(
log_buffer
,
"%s %5d %10.1f %10.1f %10.1f %10.1f %8d %8d"
,
log_buffer
,
"%s %5d %10.1f %10.1f %10.1f %10.1f %8d %8d %10.1f %10.1f %10.1f"
,
internal_op_names
[
op
].
c_str
(),
internal_op_names
[
op
].
c_str
(),
GetAndResetStats
(
&
internal_op_stats_
[
op
],
InternalOpStatsType
::
COUNT
),
GetAndResetStats
(
&
internal_op_stats_
[
op
],
InternalOpStatsType
::
COUNT
),
GetAndResetStats
(
&
internal_op_stats_
[
op
],
GetAndResetStats
(
&
internal_op_stats_
[
op
],
...
@@ -77,7 +79,16 @@ void TitanInternalStats::DumpAndResetInternalOpStats(LogBuffer* log_buffer) {
...
@@ -77,7 +79,16 @@ void TitanInternalStats::DumpAndResetInternalOpStats(LogBuffer* log_buffer) {
GetAndResetStats
(
&
internal_op_stats_
[
op
],
GetAndResetStats
(
&
internal_op_stats_
[
op
],
InternalOpStatsType
::
INPUT_FILE_NUM
),
InternalOpStatsType
::
INPUT_FILE_NUM
),
GetAndResetStats
(
&
internal_op_stats_
[
op
],
GetAndResetStats
(
&
internal_op_stats_
[
op
],
InternalOpStatsType
::
OUTPUT_FILE_NUM
));
InternalOpStatsType
::
OUTPUT_FILE_NUM
),
GetAndResetStats
(
&
internal_op_stats_
[
op
],
InternalOpStatsType
::
GC_SAMPLING_MICROS
)
/
SECOND
,
GetAndResetStats
(
&
internal_op_stats_
[
op
],
InternalOpStatsType
::
GC_READ_LSM_MICROS
)
/
SECOND
,
GetAndResetStats
(
&
internal_op_stats_
[
op
],
InternalOpStatsType
::
GC_UPDATE_LSM_MICROS
)
/
SECOND
);
}
}
}
}
...
...
src/titan_stats.h
View file @
144e20f0
...
@@ -23,6 +23,10 @@ enum class InternalOpStatsType : int {
...
@@ -23,6 +23,10 @@ enum class InternalOpStatsType : int {
IO_BYTES_WRITTEN
,
IO_BYTES_WRITTEN
,
INPUT_FILE_NUM
,
INPUT_FILE_NUM
,
OUTPUT_FILE_NUM
,
OUTPUT_FILE_NUM
,
GC_SAMPLING_MICROS
,
GC_READ_LSM_MICROS
,
// Update lsm and write callback
GC_UPDATE_LSM_MICROS
,
INTERNAL_OP_STATS_ENUM_MAX
,
INTERNAL_OP_STATS_ENUM_MAX
,
};
};
...
@@ -262,5 +266,18 @@ inline void UpdateIOBytes(uint64_t prev_bytes_read, uint64_t prev_bytes_written,
...
@@ -262,5 +266,18 @@ inline void UpdateIOBytes(uint64_t prev_bytes_read, uint64_t prev_bytes_written,
}
}
}
}
class
TitanStopWatch
{
public
:
TitanStopWatch
(
Env
*
env
,
uint64_t
&
stats
)
:
env_
(
env
),
stats_
(
stats
),
start_
(
env_
->
NowMicros
())
{}
~
TitanStopWatch
()
{
stats_
+=
env_
->
NowMicros
()
-
start_
;
}
private
:
Env
*
env_
;
uint64_t
&
stats_
;
uint64_t
start_
;
};
}
// namespace titandb
}
// namespace titandb
}
// namespace rocksdb
}
// namespace rocksdb
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment