-
Notifications
You must be signed in to change notification settings - Fork 411
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix metrics when unips is enabled under non-disagg
Signed-off-by: JaySon-Huang <[email protected]> Add flow by different types Signed-off-by: JaySon-Huang <[email protected]>
- Loading branch information
1 parent
2bc5605
commit 5efe631
Showing
11 changed files
with
354 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright 2023 PingCAP, Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include <Common/TiFlashMetrics.h> | ||
#include <Storages/Page/PageConstants.h> | ||
#include <Storages/Page/V3/CheckpointFile/CPDumpStat.h> | ||
#include <fmt/core.h> | ||
|
||
namespace DB::PS::V3 | ||
{ | ||
|
||
void SetMetrics(const CPDataDumpStats & stats) | ||
{ | ||
for (size_t i = 0; i < static_cast<size_t>(DB::StorageType::_MAX_STORAGE_TYPE_); ++i) | ||
{ | ||
auto type = static_cast<DB::StorageType>(i); | ||
switch (type) | ||
{ | ||
case DB::StorageType::Unknown: | ||
{ | ||
GET_METRIC(tiflash_storage_checkpoint_keys_by_types, type_unknown).Increment(stats.num_keys[i]); | ||
GET_METRIC(tiflash_storage_checkpoint_flow_by_types, type_unknown).Increment(stats.num_bytes[i]); | ||
break; | ||
} | ||
case DB::StorageType::RaftEngine: | ||
{ | ||
GET_METRIC(tiflash_storage_checkpoint_keys_by_types, type_raftengine).Increment(stats.num_keys[i]); | ||
GET_METRIC(tiflash_storage_checkpoint_flow_by_types, type_raftengine).Increment(stats.num_bytes[i]); | ||
break; | ||
} | ||
case DB::StorageType::KVEngine: | ||
{ | ||
GET_METRIC(tiflash_storage_checkpoint_keys_by_types, type_kvengine).Increment(stats.num_keys[i]); | ||
GET_METRIC(tiflash_storage_checkpoint_flow_by_types, type_kvengine).Increment(stats.num_bytes[i]); | ||
break; | ||
} | ||
case DB::StorageType::KVStore: | ||
{ | ||
GET_METRIC(tiflash_storage_checkpoint_keys_by_types, type_kvstore).Increment(stats.num_keys[i]); | ||
GET_METRIC(tiflash_storage_checkpoint_flow_by_types, type_kvstore).Increment(stats.num_bytes[i]); | ||
break; | ||
} | ||
case DB::StorageType::Data: | ||
{ | ||
GET_METRIC(tiflash_storage_checkpoint_keys_by_types, type_data).Increment(stats.num_keys[i]); | ||
GET_METRIC(tiflash_storage_checkpoint_flow_by_types, type_data).Increment(stats.num_bytes[i]); | ||
break; | ||
} | ||
case DB::StorageType::Log: | ||
{ | ||
GET_METRIC(tiflash_storage_checkpoint_keys_by_types, type_log).Increment(stats.num_keys[i]); | ||
GET_METRIC(tiflash_storage_checkpoint_flow_by_types, type_log).Increment(stats.num_bytes[i]); | ||
break; | ||
} | ||
case DB::StorageType::Meta: | ||
{ | ||
GET_METRIC(tiflash_storage_checkpoint_keys_by_types, type_meta).Increment(stats.num_keys[i]); | ||
GET_METRIC(tiflash_storage_checkpoint_flow_by_types, type_meta).Increment(stats.num_bytes[i]); | ||
break; | ||
} | ||
default: | ||
__builtin_unreachable(); | ||
} | ||
} | ||
} | ||
|
||
} // namespace DB::PS::V3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Copyright 2023 PingCAP, Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <Storages/Page/PageConstants.h> | ||
#include <fmt/format.h> | ||
|
||
#include <magic_enum.hpp> | ||
|
||
namespace DB::PS::V3 | ||
{ | ||
|
||
struct CPDataDumpStats | ||
{ | ||
bool has_new_data = false; | ||
|
||
size_t incremental_data_bytes = 0; | ||
size_t compact_data_bytes = 0; | ||
|
||
std::array<size_t, static_cast<size_t>(StorageType::_MAX_STORAGE_TYPE_)> num_keys{}; | ||
std::array<size_t, static_cast<size_t>(StorageType::_MAX_STORAGE_TYPE_)> num_bytes{}; | ||
|
||
// Total number of records in this checkpoint | ||
size_t num_records = 0; | ||
// Number of Pages that already uploaded to S3 | ||
// and is not changed in this checkpoint | ||
size_t num_pages_unchanged = 0; | ||
// Number of Pages that already uploaded to S3 | ||
// but picked by compaction in this checkpoint | ||
size_t num_pages_compact = 0; | ||
// Number of incremental Pages since last checkpoint | ||
size_t num_pages_incremental = 0; | ||
// Number of ExternalPages | ||
size_t num_ext_pages = 0; | ||
// Number of RefPages | ||
size_t num_ref_pages = 0; | ||
// Number of delete records | ||
size_t num_delete_records = 0; | ||
// Number of other records other than Pages/ExternalPages | ||
size_t num_other_records = 0; | ||
}; | ||
|
||
void SetMetrics(const CPDataDumpStats & stats); | ||
|
||
} // namespace DB::PS::V3 | ||
|
||
template <> | ||
struct fmt::formatter<DB::PS::V3::CPDataDumpStats> | ||
{ | ||
static constexpr auto parse(format_parse_context & ctx) { return ctx.begin(); } | ||
|
||
template <typename FormatContext> | ||
auto format(const DB::PS::V3::CPDataDumpStats & value, FormatContext & ctx) const -> decltype(ctx.out()) | ||
{ | ||
auto it = format_to( | ||
ctx.out(), | ||
"CPDataDumpStats{{" | ||
"incremental_data_bytes={} compact_data_bytes={}" | ||
" n_records{{total={}" | ||
" pages_unchanged={} pages_compact={} pages_incremental={} ext_pages={} ref_pages={}" | ||
" delete={} other={}}}", | ||
value.incremental_data_bytes, | ||
value.compact_data_bytes, | ||
value.num_records, | ||
value.num_pages_unchanged, | ||
value.num_pages_compact, | ||
value.num_pages_incremental, | ||
value.num_ext_pages, | ||
value.num_ref_pages, | ||
value.num_delete_records, | ||
value.num_other_records); | ||
it = format_to(it, " types["); | ||
for (size_t i = 0; i < static_cast<size_t>(DB::StorageType::_MAX_STORAGE_TYPE_); ++i) | ||
{ | ||
if (i != 0) | ||
it = format_to(it, " "); | ||
it = format_to( | ||
it, | ||
"{{type={} keys={} bytes={}}}", | ||
magic_enum::enum_name(static_cast<DB::StorageType>(i)), | ||
value.num_keys[i], | ||
value.num_bytes[i]); | ||
} | ||
return format_to( | ||
it, | ||
"]" // end of "keys" | ||
"}}" // end of "CPDataDumpStats" | ||
); | ||
} | ||
}; |
Oops, something went wrong.