Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PageStorage V3 GC add metrics. #4397

Merged
merged 3 commits into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions dbms/src/Common/TiFlashMetrics.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,16 @@ namespace DB
M(tiflash_storage_write_stall_duration_seconds, "The write stall duration of storage, in seconds", Histogram, /**/ \
F(type_write, {{"type", "write"}}, ExpBuckets{0.0005, 2, 20}), /**/ \
F(type_delete_range, {{"type", "delete_range"}}, ExpBuckets{0.0005, 2, 20})) /**/ \
M(tiflash_storage_page_gc_count, "Total number of page's gc execution.", Counter, F(type_exec, {"type", "exec"}), \
F(type_low_write, {"type", "low_write"})) \
M(tiflash_storage_page_gc_count, "Total number of page's gc execution.", Counter, \
F(type_exec, {"type", "exec"}), \
F(type_low_write, {"type", "low_write"}), \
F(type_v3, {"type", "v3"}), \
F(type_v3_mvcc_dumped, {"type", "v3_mvcc_dumped"}), \
F(type_v3_bs_full_gc, {"type", "v3_bs_full_gc"})) \
M(tiflash_storage_page_gc_duration_seconds, "Bucketed histogram of page's gc task duration", Histogram, \
F(type_exec, {{"type", "exec"}}, ExpBuckets{0.0005, 2, 20}), F(type_migrate, {{"type", "migrate"}}, ExpBuckets{0.0005, 2, 20})) \
F(type_exec, {{"type", "exec"}}, ExpBuckets{0.0005, 2, 20}), \
F(type_migrate, {{"type", "migrate"}}, ExpBuckets{0.0005, 2, 20}), \
F(type_v3, {{"type", "v3"}}, ExpBuckets{0.0005, 2, 20})) \
M(tiflash_storage_logical_throughput_bytes, "The logical throughput of read tasks of storage in bytes", Histogram, \
F(type_read, {{"type", "read"}}, EqualWidthBuckets{1 * 1024 * 1024, 60, 50 * 1024 * 1024})) \
M(tiflash_storage_io_limiter, "Storage I/O limiter metrics", Counter, F(type_fg_read_req_bytes, {"type", "fg_read_req_bytes"}), \
Expand Down
1 change: 1 addition & 0 deletions dbms/src/Storages/Page/V3/BlobStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <Common/Logger.h>
#include <Common/ProfileEvents.h>
#include <Common/StringUtils/StringUtils.h>
#include <Common/TiFlashMetrics.h>
#include <Poco/File.h>
#include <Storages/Page/PageDefines.h>
#include <Storages/Page/V3/BlobStore.h>
Expand Down
14 changes: 13 additions & 1 deletion dbms/src/Storages/Page/V3/PageStorageImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <Common/TiFlashMetrics.h>
#include <Encryption/FileProvider.h>
#include <Storages/Page/PageStorage.h>
#include <Storages/Page/V3/PageDirectory.h>
Expand Down Expand Up @@ -204,7 +205,10 @@ bool PageStorageImpl::gc(bool /*not_skip*/, const WriteLimiterPtr & write_limite
if (!gc_is_running.compare_exchange_strong(v, true))
return false;

Stopwatch watch;
SCOPE_EXIT({
GET_METRIC(tiflash_storage_page_gc_count, type_v3).Increment();
jiaqizho marked this conversation as resolved.
Show resolved Hide resolved
GET_METRIC(tiflash_storage_page_gc_duration_seconds, type_v3).Observe(watch.elapsedSeconds());
bool is_running = true;
gc_is_running.compare_exchange_strong(is_running, false);
});
Expand All @@ -225,7 +229,10 @@ bool PageStorageImpl::gc(bool /*not_skip*/, const WriteLimiterPtr & write_limite

// 1. Do the MVCC gc, clean up expired snapshot.
// And get the expired entries.
[[maybe_unused]] bool is_snapshot_dumped = page_directory->tryDumpSnapshot(write_limiter);
if (page_directory->tryDumpSnapshot(write_limiter))
{
GET_METRIC(tiflash_storage_page_gc_count, type_v3_mvcc_dumped).Increment();
}
const auto & del_entries = page_directory->gcInMemEntries();
LOG_FMT_DEBUG(log, "Remove entries from memory [num_entries={}]", del_entries.size());

Expand All @@ -242,6 +249,10 @@ bool PageStorageImpl::gc(bool /*not_skip*/, const WriteLimiterPtr & write_limite
clean_external_page();
return false;
}
else
{
GET_METRIC(tiflash_storage_page_gc_count, type_v3_bs_full_gc).Increment(blob_need_gc.size());
}

// Execute full gc
// 4. Filter out entries in MVCC by BlobId.
Expand Down Expand Up @@ -273,6 +284,7 @@ bool PageStorageImpl::gc(bool /*not_skip*/, const WriteLimiterPtr & write_limite
page_directory->gcApply(std::move(gc_edit), write_limiter);

clean_external_page();

return true;
}

Expand Down