From 79d951bac3462b2d12f322a42f43bacf6de831e7 Mon Sep 17 00:00:00 2001 From: lidezhu Date: Tue, 23 Aug 2022 14:55:35 +0800 Subject: [PATCH] add metric(wip) --- dbms/src/Common/TiFlashMetrics.h | 2 ++ dbms/src/Storages/Page/V3/BlobStore.cpp | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dbms/src/Common/TiFlashMetrics.h b/dbms/src/Common/TiFlashMetrics.h index 90a2ff3aa0c..dfba0fd1b13 100644 --- a/dbms/src/Common/TiFlashMetrics.h +++ b/dbms/src/Common/TiFlashMetrics.h @@ -150,6 +150,8 @@ namespace DB 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_page_write_batch_size, "The size of each write batch in bytes", Histogram, \ + F(type_v3, {{"type", "v3"}}, EqualWidthBuckets{1 * 1024 * 1024, 100, 10 * 1024 * 1024})) \ 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"}), \ diff --git a/dbms/src/Storages/Page/V3/BlobStore.cpp b/dbms/src/Storages/Page/V3/BlobStore.cpp index 865e5573521..6a1a035e0c5 100644 --- a/dbms/src/Storages/Page/V3/BlobStore.cpp +++ b/dbms/src/Storages/Page/V3/BlobStore.cpp @@ -240,13 +240,6 @@ PageEntriesEdit BlobStore::write(DB::WriteBatch & wb, const WriteLimiterPtr & wr const size_t all_page_data_size = wb.getTotalDataSize(); - // If the WriteBatch is too big, we will split the Writes in the WriteBatch to different `BlobFile`. - // This can avoid allocating a big buffer for writing data and can smooth memory usage. - if (all_page_data_size > config.file_limit_size) - { - return handleLargeWrite(wb, write_limiter); - } - PageEntriesEdit edit; auto ns_id = wb.getNamespaceId(); @@ -282,6 +275,15 @@ PageEntriesEdit BlobStore::write(DB::WriteBatch & wb, const WriteLimiterPtr & wr return edit; } + GET_METRIC(tiflash_storage_page_write_batch_size).Observe(all_page_data_size); + + // If the WriteBatch is too big, we will split the Writes in the WriteBatch to different `BlobFile`. + // This can avoid allocating a big buffer for writing data and can smooth memory usage. + if (all_page_data_size > config.file_limit_size) + { + return handleLargeWrite(wb, write_limiter); + } + char * buffer = static_cast(alloc(all_page_data_size)); SCOPE_EXIT({ free(buffer, all_page_data_size);