From 09635a1e9dbfd2142e9d39ff728865d287da1a78 Mon Sep 17 00:00:00 2001 From: JaySon-Huang Date: Mon, 14 Oct 2024 15:15:06 +0800 Subject: [PATCH 1/4] Cleanup useless include --- dbms/src/DataStreams/AsynchronousBlockInputStream.h | 1 - dbms/src/DataStreams/ParallelInputsProcessor.h | 1 - dbms/src/Flash/FlashService.cpp | 1 - dbms/src/Server/MetricsPrometheus.cpp | 1 - dbms/src/Storages/KVStore/Decode/PartitionStreams.cpp | 1 - dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp | 1 - dbms/src/Storages/KVStore/Read/ReadIndexWorkerImpl.h | 1 - dbms/src/Storages/KVStore/Read/ReadIndexWorkerManager.cpp | 3 ++- 8 files changed, 2 insertions(+), 8 deletions(-) diff --git a/dbms/src/DataStreams/AsynchronousBlockInputStream.h b/dbms/src/DataStreams/AsynchronousBlockInputStream.h index ce55e048309..8b2b56b0a17 100644 --- a/dbms/src/DataStreams/AsynchronousBlockInputStream.h +++ b/dbms/src/DataStreams/AsynchronousBlockInputStream.h @@ -16,7 +16,6 @@ #include #include -#include #include #include #include diff --git a/dbms/src/DataStreams/ParallelInputsProcessor.h b/dbms/src/DataStreams/ParallelInputsProcessor.h index 4c114e01e1e..2265e28f14f 100644 --- a/dbms/src/DataStreams/ParallelInputsProcessor.h +++ b/dbms/src/DataStreams/ParallelInputsProcessor.h @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/dbms/src/Flash/FlashService.cpp b/dbms/src/Flash/FlashService.cpp index 2dbdedd6f5c..60f44c4f8b5 100644 --- a/dbms/src/Flash/FlashService.cpp +++ b/dbms/src/Flash/FlashService.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/dbms/src/Server/MetricsPrometheus.cpp b/dbms/src/Server/MetricsPrometheus.cpp index f030f7902de..045ad4b4f14 100644 --- a/dbms/src/Server/MetricsPrometheus.cpp +++ b/dbms/src/Server/MetricsPrometheus.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/dbms/src/Storages/KVStore/Decode/PartitionStreams.cpp b/dbms/src/Storages/KVStore/Decode/PartitionStreams.cpp index 4497f1e9c49..0e2e7076cdf 100644 --- a/dbms/src/Storages/KVStore/Decode/PartitionStreams.cpp +++ b/dbms/src/Storages/KVStore/Decode/PartitionStreams.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp b/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp index 5509cd7dd54..ae9598cc271 100644 --- a/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp +++ b/dbms/src/Storages/KVStore/MultiRaft/RaftCommandsKVS.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/dbms/src/Storages/KVStore/Read/ReadIndexWorkerImpl.h b/dbms/src/Storages/KVStore/Read/ReadIndexWorkerImpl.h index 0b3f2551b2c..88457c154fe 100644 --- a/dbms/src/Storages/KVStore/Read/ReadIndexWorkerImpl.h +++ b/dbms/src/Storages/KVStore/Read/ReadIndexWorkerImpl.h @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/dbms/src/Storages/KVStore/Read/ReadIndexWorkerManager.cpp b/dbms/src/Storages/KVStore/Read/ReadIndexWorkerManager.cpp index 912e372247f..dafa6522fb9 100644 --- a/dbms/src/Storages/KVStore/Read/ReadIndexWorkerManager.cpp +++ b/dbms/src/Storages/KVStore/Read/ReadIndexWorkerManager.cpp @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include #include namespace DB @@ -252,4 +253,4 @@ BatchReadIndexRes ReadIndexWorkerManager::batchReadIndex( } return resps; } -} // namespace DB \ No newline at end of file +} // namespace DB From e8dcbe76bd0dcecad0414395faedc45e63ca0340 Mon Sep 17 00:00:00 2001 From: JaySon-Huang Date: Mon, 14 Oct 2024 15:18:34 +0800 Subject: [PATCH 2/4] Set thread name for local index worker --- dbms/src/Storages/DeltaMerge/LocalIndexerScheduler.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dbms/src/Storages/DeltaMerge/LocalIndexerScheduler.cpp b/dbms/src/Storages/DeltaMerge/LocalIndexerScheduler.cpp index 01866ec5c8e..8ef29a9795e 100644 --- a/dbms/src/Storages/DeltaMerge/LocalIndexerScheduler.cpp +++ b/dbms/src/Storages/DeltaMerge/LocalIndexerScheduler.cpp @@ -261,6 +261,9 @@ bool LocalIndexerScheduler::tryAddTaskToPool(std::unique_lock & lock } auto real_job = [task, this]() { + const auto old_thread_name = getThreadName(); + setThreadName("LocalIndexPool"); + SCOPE_EXIT({ std::unique_lock lock(mutex); pool_current_memory -= task->user_task.request_memory; @@ -270,6 +273,7 @@ bool LocalIndexerScheduler::tryAddTaskToPool(std::unique_lock & lock scheduler_need_wakeup = true; scheduler_notifier.notify_all(); + setThreadName(old_thread_name.c_str()); }); task->scheduled_at.start(); From f395ea22fbb1c601a65d212c5d5db100112a9382 Mon Sep 17 00:00:00 2001 From: JaySon-Huang Date: Mon, 14 Oct 2024 17:23:50 +0800 Subject: [PATCH 3/4] Add grafana panel --- metrics/grafana/tiflash_summary.json | 147 ++++++++++++++++++++++++++- 1 file changed, 142 insertions(+), 5 deletions(-) diff --git a/metrics/grafana/tiflash_summary.json b/metrics/grafana/tiflash_summary.json index 747f92163df..e1a00b06e25 100644 --- a/metrics/grafana/tiflash_summary.json +++ b/metrics/grafana/tiflash_summary.json @@ -52,7 +52,7 @@ "gnetId": null, "graphTooltip": 1, "id": null, - "iteration": 1718272201438, + "iteration": 1728897014230, "links": [], "panels": [ { @@ -2869,6 +2869,147 @@ "alignLevel": null } }, + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "${DS_TEST-CLUSTER}", + "decimals": null, + "description": "", + "editable": true, + "error": false, + "fieldConfig": { + "defaults": {}, + "overrides": [] + }, + "fill": 0, + "fillGradient": 0, + "grid": {}, + "gridPos": { + "h": 7, + "w": 12, + "x": 0, + "y": 51 + }, + "hiddenSeries": false, + "id": 295, + "legend": { + "alignAsTable": true, + "avg": false, + "current": true, + "max": true, + "min": false, + "rightSide": true, + "show": true, + "sideWidth": 250, + "sort": "max", + "sortDesc": true, + "total": false, + "values": true + }, + "lines": true, + "linewidth": 1, + "links": [], + "nullPointMode": "null", + "options": { + "alertThreshold": true + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [ + { + "alias": "Limit", + "color": "#F2495C", + "hideTooltip": true, + "legend": false, + "linewidth": 2, + "nullPointMode": "connected" + } + ], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "exemplar": true, + "expr": "sum by (instance) (rate(tiflash_proxy_thread_cpu_seconds_total{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", name=~\"LocalIndexPool*\"}[1m]))", + "format": "time_series", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 2, + "legendFormat": "pool-{{instance}}", + "refId": "A", + "step": 40 + }, + { + "exemplar": true, + "expr": "count by (instance) (tiflash_proxy_thread_cpu_seconds_total{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", name=~\"LocalIndexPool*\"})", + "hide": true, + "interval": "", + "intervalFactor": 2, + "legendFormat": "Limit", + "refId": "B" + }, + { + "exemplar": true, + "expr": "sum by (instance) (rate(tiflash_proxy_thread_cpu_seconds_total{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", name=~\"LocalIndexSched*\"}[1m]))", + "format": "time_series", + "hide": false, + "instant": false, + "interval": "", + "intervalFactor": 2, + "legendFormat": "sched-{{instance}}", + "refId": "C", + "step": 40 + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "Local Index Pool", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "individual" + }, + "type": "graph", + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "yaxes": [ + { + "decimals": 1, + "format": "percentunit", + "label": null, + "logBase": 1, + "max": null, + "min": "0", + "show": true + }, + { + "format": "short", + "label": null, + "logBase": 1, + "max": null, + "min": null, + "show": false + } + ], + "yaxis": { + "align": false, + "alignLevel": null + } + }, { "aliasColors": {}, "bars": false, @@ -8661,7 +8802,6 @@ }, "yaxes": [ { - "$$hashKey": "object:222", "format": "µs", "label": null, "logBase": 1, @@ -8670,7 +8810,6 @@ "show": true }, { - "$$hashKey": "object:223", "format": "short", "label": null, "logBase": 1, @@ -9413,7 +9552,6 @@ }, "yaxes": [ { - "$$hashKey": "object:304", "format": "short", "label": null, "logBase": 1, @@ -9422,7 +9560,6 @@ "show": true }, { - "$$hashKey": "object:305", "format": "short", "label": null, "logBase": 1, From cb496293b5634eda031561f7958e329c362eb722 Mon Sep 17 00:00:00 2001 From: JaySon-Huang Date: Mon, 14 Oct 2024 17:29:38 +0800 Subject: [PATCH 4/4] Add comments --- dbms/src/Storages/DeltaMerge/LocalIndexerScheduler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dbms/src/Storages/DeltaMerge/LocalIndexerScheduler.cpp b/dbms/src/Storages/DeltaMerge/LocalIndexerScheduler.cpp index 8ef29a9795e..d513d146868 100644 --- a/dbms/src/Storages/DeltaMerge/LocalIndexerScheduler.cpp +++ b/dbms/src/Storages/DeltaMerge/LocalIndexerScheduler.cpp @@ -261,6 +261,8 @@ bool LocalIndexerScheduler::tryAddTaskToPool(std::unique_lock & lock } auto real_job = [task, this]() { + // The task is executed by a thread that is created by UniThreadPool. We need to set the thread name + // before executing and reset it after the task is done. const auto old_thread_name = getThreadName(); setThreadName("LocalIndexPool");