aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiacomo Pozzoni <giacomopoz@gmail.com>2020-07-27 12:00:28 +0000
committerShauren <shauren.trinity@gmail.com>2022-01-24 12:21:36 +0100
commit21e9fac8bd7c16f92d12c3df99536401f1209e58 (patch)
tree6601d77a2f53d085ca5be8627dfb71b4acd6e886
parent03e4c0d7bf22505c760c9a8c51baf739c60e5a81 (diff)
Core/Metric: Add new cmake option WITH_DETAILED_METRICS to enable more metrics (#25136)
* Core/Metric: Add new cmake option WITH_DETAILED_METRICS to enable more metrics Add more detailed metrics in World::UpdateSessions(). * Attempt using C++17 features * Fix cmake typo Co-authored-by: NoName <322016+Faq@users.noreply.github.com> * Fix build with WITHOUT_METRICS * Update Performance profiling dashboard with Update sessions panel * Add panel to show sessions with update time above 100 ms * Move legends on the right and add max update time diff in the legend of sessions Co-authored-by: NoName <322016+Faq@users.noreply.github.com> (cherry picked from commit 36ef487a90d0d14c4da8ce7e19b5916b8b15056c)
-rw-r--r--cmake/options.cmake1
-rw-r--r--cmake/showoptions.cmake5
-rw-r--r--contrib/grafana/4_Performance_profiling.json308
-rw-r--r--src/common/Metric/Metric.h17
-rw-r--r--src/server/game/World/World.cpp3
5 files changed, 327 insertions, 7 deletions
diff --git a/cmake/options.cmake b/cmake/options.cmake
index 0097df809be..ef7636549a9 100644
--- a/cmake/options.cmake
+++ b/cmake/options.cmake
@@ -50,6 +50,7 @@ option(WITH_WARNINGS "Show all warnings during compile"
option(WITH_COREDEBUG "Include additional debug-code in core" 0)
option(WITH_STRICT_DATABASE_TYPE_CHECKS "Enable strict checking of database field value accessors" 0)
option(WITHOUT_METRICS "Disable metrics reporting (i.e. InfluxDB and Grafana)" 0)
+option(WITH_DETAILED_METRICS "Enable detailed metrics reporting (i.e. time each session takes to update)" 0)
option(COPY_CONF "Copy authserver and worldserver .conf.dist files to the project dir" 1)
set(WITH_SOURCE_TREE "hierarchical" CACHE STRING "Build the source tree for IDE's.")
set_property(CACHE WITH_SOURCE_TREE PROPERTY STRINGS no flat hierarchical hierarchical-folders)
diff --git a/cmake/showoptions.cmake b/cmake/showoptions.cmake
index 8cf5d85b913..5a80136312d 100644
--- a/cmake/showoptions.cmake
+++ b/cmake/showoptions.cmake
@@ -154,6 +154,11 @@ if(WITHOUT_METRICS)
message(" *** WITHOUT_METRICS - WARNING!")
message(" *** Please note that this will disable all metrics output (i.e. InfluxDB and Grafana)")
add_definitions(-DWITHOUT_METRICS)
+elseif (WITH_DETAILED_METRICS)
+ message("")
+ message(" *** WITH_DETAILED_METRICS - WARNING!")
+ message(" *** Please note that this will enable detailed metrics output (i.e. time each session takes to update)")
+ add_definitions(-DWITH_DETAILED_METRICS)
endif()
if(WITH_STRICT_DATABASE_TYPE_CHECKS)
diff --git a/contrib/grafana/4_Performance_profiling.json b/contrib/grafana/4_Performance_profiling.json
index a92fade9e1b..14fa686f951 100644
--- a/contrib/grafana/4_Performance_profiling.json
+++ b/contrib/grafana/4_Performance_profiling.json
@@ -29,7 +29,7 @@
"gnetId": null,
"graphTooltip": 0,
"id": 15,
- "iteration": 1595439203259,
+ "iteration": 1595850767526,
"links": [],
"panels": [
{
@@ -208,12 +208,14 @@
"hiddenSeries": false,
"id": 6,
"legend": {
+ "alignAsTable": true,
"avg": false,
"current": false,
"hideEmpty": false,
"hideZero": true,
"max": false,
"min": false,
+ "rightSide": true,
"show": true,
"total": false,
"values": false
@@ -394,12 +396,14 @@
"hiddenSeries": false,
"id": 7,
"legend": {
+ "alignAsTable": true,
"avg": false,
"current": false,
"hideEmpty": false,
"hideZero": true,
"max": false,
"min": false,
+ "rightSide": true,
"show": true,
"total": false,
"values": false
@@ -535,12 +539,14 @@
"hiddenSeries": false,
"id": 2,
"legend": {
+ "alignAsTable": true,
"avg": false,
"current": false,
"hideEmpty": false,
"hideZero": true,
"max": false,
"min": false,
+ "rightSide": true,
"show": true,
"total": false,
"values": false
@@ -676,13 +682,14 @@
"hiddenSeries": false,
"id": 5,
"legend": {
- "alignAsTable": false,
+ "alignAsTable": true,
"avg": false,
"current": false,
"hideEmpty": false,
"hideZero": true,
"max": false,
"min": false,
+ "rightSide": true,
"show": true,
"total": false,
"values": false
@@ -794,6 +801,299 @@
"align": false,
"alignLevel": null
}
+ },
+ {
+ "aliasColors": {},
+ "bars": false,
+ "dashLength": 10,
+ "dashes": false,
+ "datasource": null,
+ "fieldConfig": {
+ "defaults": {
+ "custom": {}
+ },
+ "overrides": []
+ },
+ "fill": 1,
+ "fillGradient": 0,
+ "gridPos": {
+ "h": 8,
+ "w": 12,
+ "x": 0,
+ "y": 23
+ },
+ "hiddenSeries": false,
+ "id": 9,
+ "legend": {
+ "avg": false,
+ "current": false,
+ "hideEmpty": false,
+ "hideZero": true,
+ "max": false,
+ "min": false,
+ "show": false,
+ "total": false,
+ "values": false
+ },
+ "lines": true,
+ "linewidth": 2,
+ "nullPointMode": "connected",
+ "options": {
+ "dataLinks": []
+ },
+ "percentage": false,
+ "pointradius": 2,
+ "points": false,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "spaceLength": 10,
+ "stack": false,
+ "steppedLine": false,
+ "targets": [
+ {
+ "alias": "Account ID $tag_account_id",
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "account_id"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "world_update_sessions_time",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT max(\"value\") FROM \"map_update_time_diff\" WHERE (\"realm\" =~ /^$realm$/) AND $timeFilter GROUP BY time($__interval), \"map_id\" fill(none)",
+ "rawQuery": false,
+ "refId": "A",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "max"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "realm",
+ "operator": "=~",
+ "value": "/^$realm$/"
+ }
+ ]
+ }
+ ],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeRegions": [],
+ "timeShift": null,
+ "title": "Update sessions - Split",
+ "tooltip": {
+ "shared": true,
+ "sort": 2,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "buckets": null,
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [
+ {
+ "format": "ms",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ],
+ "yaxis": {
+ "align": false,
+ "alignLevel": null
+ }
+ },
+ {
+ "aliasColors": {},
+ "bars": true,
+ "dashLength": 10,
+ "dashes": false,
+ "datasource": null,
+ "description": "",
+ "fieldConfig": {
+ "defaults": {
+ "custom": {}
+ },
+ "overrides": []
+ },
+ "fill": 1,
+ "fillGradient": 0,
+ "gridPos": {
+ "h": 8,
+ "w": 12,
+ "x": 12,
+ "y": 23
+ },
+ "hiddenSeries": false,
+ "id": 10,
+ "legend": {
+ "alignAsTable": true,
+ "avg": false,
+ "current": false,
+ "hideEmpty": false,
+ "hideZero": true,
+ "max": true,
+ "min": false,
+ "rightSide": true,
+ "show": true,
+ "sort": "max",
+ "sortDesc": true,
+ "total": false,
+ "values": true
+ },
+ "lines": false,
+ "linewidth": 2,
+ "nullPointMode": "null",
+ "options": {
+ "dataLinks": []
+ },
+ "percentage": false,
+ "pointradius": 2,
+ "points": true,
+ "renderer": "flot",
+ "seriesOverrides": [],
+ "spaceLength": 10,
+ "stack": false,
+ "steppedLine": false,
+ "targets": [
+ {
+ "alias": "Account ID $tag_account_id",
+ "groupBy": [
+ {
+ "params": [
+ "$__interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "account_id"
+ ],
+ "type": "tag"
+ },
+ {
+ "params": [
+ "none"
+ ],
+ "type": "fill"
+ }
+ ],
+ "measurement": "world_update_sessions_time",
+ "orderByTime": "ASC",
+ "policy": "default",
+ "query": "SELECT max(\"value\") FROM \"map_update_time_diff\" WHERE (\"realm\" =~ /^$realm$/) AND $timeFilter GROUP BY time($__interval), \"map_id\" fill(none)",
+ "rawQuery": false,
+ "refId": "A",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "max"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "realm",
+ "operator": "=~",
+ "value": "/^$realm$/"
+ },
+ {
+ "condition": "AND",
+ "key": "value",
+ "operator": ">",
+ "value": "100"
+ }
+ ]
+ }
+ ],
+ "thresholds": [],
+ "timeFrom": null,
+ "timeRegions": [],
+ "timeShift": null,
+ "title": "Update sessions - Above 100 ms",
+ "tooltip": {
+ "shared": false,
+ "sort": 2,
+ "value_type": "individual"
+ },
+ "type": "graph",
+ "xaxis": {
+ "buckets": null,
+ "mode": "time",
+ "name": null,
+ "show": true,
+ "values": []
+ },
+ "yaxes": [
+ {
+ "format": "ms",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ },
+ {
+ "format": "short",
+ "label": null,
+ "logBase": 1,
+ "max": null,
+ "min": null,
+ "show": true
+ }
+ ],
+ "yaxis": {
+ "align": false,
+ "alignLevel": null
+ }
}
],
"refresh": "1m",
@@ -831,7 +1131,7 @@
]
},
"time": {
- "from": "now-6h",
+ "from": "now-1h",
"to": "now"
},
"timepicker": {
@@ -850,5 +1150,5 @@
"timezone": "",
"title": "Performance profiling",
"uid": "IRRL03nMk",
- "version": 1
+ "version": 4
} \ No newline at end of file
diff --git a/src/common/Metric/Metric.h b/src/common/Metric/Metric.h
index 33bdf3b4ed7..11c156653d0 100644
--- a/src/common/Metric/Metric.h
+++ b/src/common/Metric/Metric.h
@@ -166,6 +166,7 @@ MetricStopWatch<LoggerType> MakeMetricStopWatch(LoggerType&& loggerFunc)
#define TC_METRIC_EVENT(category, title, description) ((void)0)
#define TC_METRIC_VALUE(category, value) ((void)0)
#define TC_METRIC_TIMER(category, ...) ((void)0)
+#define TC_METRIC_DETAILED_TIMER(category, ...) ((void)0)
#else
# if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS
#define TC_METRIC_EVENT(category, title, description) \
@@ -196,11 +197,21 @@ MetricStopWatch<LoggerType> MakeMetricStopWatch(LoggerType&& loggerFunc)
} while (0) \
__pragma(warning(pop))
# endif
-#define TC_METRIC_TIMER(category, ...) \
+#define TC_METRIC_TIMER(category, ...) \
MetricStopWatch TC_METRIC_UNIQUE_NAME(__tc_metric_stop_watch) = MakeMetricStopWatch([&](TimePoint start) \
- { \
- sMetric->LogValue(category, std::chrono::steady_clock::now() - start, { __VA_ARGS__ }); \
+ { \
+ sMetric->LogValue(category, std::chrono::steady_clock::now() - start, { __VA_ARGS__ }); \
});
+# if defined WITH_DETAILED_METRICS
+#define TC_METRIC_DETAILED_TIMER(category, ...) \
+ MetricStopWatch TC_METRIC_UNIQUE_NAME(__tc_metric_stop_watch) = MakeMetricStopWatch([&](TimePoint start) \
+ { \
+ sMetric->LogValue(category, std::chrono::steady_clock::now() - start, { __VA_ARGS__ }); \
+ });
+# else
+#define TC_METRIC_DETAILED_TIMER(category, ...) ((void)0)
+# endif
+
#endif
#endif // METRIC_H__
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 38438911af5..fd2b5c2a557 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -3352,6 +3352,9 @@ void World::UpdateSessions(uint32 diff)
WorldSession* pSession = itr->second;
WorldSessionFilter updater(pSession);
+ [[maybe_unused]] uint32 currentSessionId = itr->first;
+ TC_METRIC_DETAILED_TIMER("world_update_sessions_time", TC_METRIC_TAG("account_id", std::to_string(currentSessionId)));
+
if (!pSession->Update(diff, updater)) // As interval = 0
{
if (!RemoveQueuedPlayer(itr->second) && itr->second && getIntConfig(CONFIG_INTERVAL_DISCONNECT_TOLERANCE))