diff options
-rw-r--r-- | cmake/options.cmake | 1 | ||||
-rw-r--r-- | cmake/showoptions.cmake | 5 | ||||
-rw-r--r-- | contrib/grafana/4_Performance_profiling.json | 308 | ||||
-rw-r--r-- | src/common/Metric/Metric.h | 17 | ||||
-rw-r--r-- | src/server/game/World/World.cpp | 3 |
5 files changed, 327 insertions, 7 deletions
diff --git a/cmake/options.cmake b/cmake/options.cmake index 0d73085b212..8e7031a683a 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 45e06b3321e..f9bfa1f33fa 100644 --- a/cmake/showoptions.cmake +++ b/cmake/showoptions.cmake @@ -134,6 +134,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 fe1abc71094..0e050c110b0 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -3074,6 +3074,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)) |