diff --git a/cmake/options.cmake b/cmake/options.cmake index ac49511efca..2551ec72140 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -49,6 +49,7 @@ endif() option(WITH_WARNINGS "Show all warnings during compile" 0) 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(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 3acb939f318..66cec73089b 100644 --- a/cmake/showoptions.cmake +++ b/cmake/showoptions.cmake @@ -143,6 +143,13 @@ if(PERFORMANCE_PROFILING) add_definitions(-DPERFORMANCE_PROFILING) endif() +if(WITHOUT_METRICS) + message("") + message(" *** WITHOUT_METRICS - WARNING!") + message(" *** Please note that this will disable all metrics output (i.e. InfluxDB and Grafana)") + add_definitions(-DWITHOUT_METRICS) +endif() + if(WITH_STRICT_DATABASE_TYPE_CHECKS) message("") message(" *** WITH_STRICT_DATABASE_TYPE_CHECKS - WARNING!") diff --git a/contrib/grafana/4_Performance_profiling.json b/contrib/grafana/4_Performance_profiling.json new file mode 100644 index 00000000000..a92fade9e1b --- /dev/null +++ b/contrib/grafana/4_Performance_profiling.json @@ -0,0 +1,854 @@ +{ + "annotations": { + "list": [ + { + "builtIn": 1, + "datasource": "-- Grafana --", + "enable": true, + "hide": true, + "iconColor": "rgba(0, 211, 255, 1)", + "name": "Annotations & Alerts", + "type": "dashboard" + }, + { + "datasource": "Influx", + "enable": true, + "hide": false, + "iconColor": "#c0c6be", + "limit": 100, + "name": "Global Events", + "query": "select title, text from events where $timeFilter and realm =~ /$realm$/", + "showIn": 0, + "tags": [], + "textColumn": "text", + "type": "tags" + } + ] + }, + "editable": true, + "gnetId": null, + "graphTooltip": 0, + "id": 15, + "iteration": 1595439203259, + "links": [], + "panels": [ + { + "aliasColors": {}, + "bars": false, + "dashLength": 10, + "dashes": false, + "datasource": "Influx", + "editable": true, + "error": false, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "grid": { + "leftLogBase": 1, + "leftMax": null, + "leftMin": null, + "rightLogBase": 1, + "rightMax": null, + "rightMin": null + }, + "gridPos": { + "h": 7, + "w": 24, + "x": 0, + "y": 0 + }, + "hiddenSeries": false, + "id": 4, + "isNew": true, + "legend": { + "avg": false, + "current": false, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 2, + "links": [], + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 5, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": false, + "steppedLine": false, + "targets": [ + { + "alias": "Update diff", + "dsType": "influxdb", + "groupBy": [ + { + "params": [ + "$interval" + ], + "type": "time" + }, + { + "params": [ + "null" + ], + "type": "fill" + } + ], + "measurement": "update_time_diff", + "orderByTime": "ASC", + "policy": "default", + "query": "SELECT max(\"value\") FROM \"update_time_diff\" WHERE (\"realm\" =~ /$realm$/) AND $timeFilter GROUP BY time($interval) fill(null)", + "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 diff", + "tooltip": { + "msResolution": false, + "shared": true, + "sort": 0, + "value_type": "cumulative" + }, + "type": "graph", + "x-axis": true, + "xaxis": { + "buckets": null, + "mode": "time", + "name": null, + "show": true, + "values": [] + }, + "y-axis": true, + "y_formats": [ + "ms", + "short" + ], + "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": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 7 + }, + "hiddenSeries": false, + "id": 6, + "legend": { + "avg": false, + "current": false, + "hideEmpty": false, + "hideZero": true, + "max": false, + "min": false, + "show": true, + "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": "Total", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "world_update_time_total", + "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": "B", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "max" + } + ] + ], + "tags": [ + { + "key": "realm", + "operator": "=~", + "value": "/^$realm$/" + } + ] + }, + { + "alias": "$tag_type", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "type" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "world_update_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": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "max" + } + ] + ], + "tags": [ + { + "key": "realm", + "operator": "=~", + "value": "/^$realm$/" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "World Update - Split", + "tooltip": { + "shared": true, + "sort": 0, + "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": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 10, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 7 + }, + "hiddenSeries": false, + "id": 7, + "legend": { + "avg": false, + "current": false, + "hideEmpty": false, + "hideZero": true, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 0, + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "alias": "$tag_type", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "type" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "world_update_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": "C", + "resultFormat": "time_series", + "select": [ + [ + { + "params": [ + "value" + ], + "type": "field" + }, + { + "params": [], + "type": "max" + } + ] + ], + "tags": [ + { + "key": "realm", + "operator": "=~", + "value": "/^$realm$/" + } + ] + } + ], + "thresholds": [], + "timeFrom": null, + "timeRegions": [], + "timeShift": null, + "title": "World Update - Stacked", + "tooltip": { + "shared": true, + "sort": 0, + "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": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 1, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 15 + }, + "hiddenSeries": false, + "id": 2, + "legend": { + "avg": false, + "current": false, + "hideEmpty": false, + "hideZero": true, + "max": false, + "min": false, + "show": true, + "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": "Map $tag_map_id", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "map_id" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "map_update_time_diff", + "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": "Map update - Split", + "tooltip": { + "shared": true, + "sort": 0, + "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": false, + "dashLength": 10, + "dashes": false, + "datasource": null, + "fieldConfig": { + "defaults": { + "custom": {} + }, + "overrides": [] + }, + "fill": 10, + "fillGradient": 0, + "gridPos": { + "h": 8, + "w": 12, + "x": 12, + "y": 15 + }, + "hiddenSeries": false, + "id": 5, + "legend": { + "alignAsTable": false, + "avg": false, + "current": false, + "hideEmpty": false, + "hideZero": true, + "max": false, + "min": false, + "show": true, + "total": false, + "values": false + }, + "lines": true, + "linewidth": 0, + "nullPointMode": "connected", + "options": { + "dataLinks": [] + }, + "percentage": false, + "pointradius": 2, + "points": false, + "renderer": "flot", + "seriesOverrides": [], + "spaceLength": 10, + "stack": true, + "steppedLine": false, + "targets": [ + { + "alias": "Map $tag_map_id", + "groupBy": [ + { + "params": [ + "$__interval" + ], + "type": "time" + }, + { + "params": [ + "map_id" + ], + "type": "tag" + }, + { + "params": [ + "none" + ], + "type": "fill" + } + ], + "measurement": "map_update_time_diff", + "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": "Map update - Stacked", + "tooltip": { + "shared": true, + "sort": 0, + "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", + "schemaVersion": 25, + "style": "dark", + "tags": [], + "templating": { + "list": [ + { + "allValue": null, + "current": { + "selected": true, + "text": "Trinity", + "value": "Trinity" + }, + "datasource": "Influx", + "definition": "show tag values from events with key = realm", + "hide": 0, + "includeAll": false, + "label": null, + "multi": false, + "name": "realm", + "options": [], + "query": "show tag values from events with key = realm", + "refresh": 1, + "regex": "", + "skipUrlSync": false, + "sort": 0, + "tagValuesQuery": "", + "tags": [], + "tagsQuery": "", + "type": "query", + "useTags": false + } + ] + }, + "time": { + "from": "now-6h", + "to": "now" + }, + "timepicker": { + "refresh_intervals": [ + "10s", + "30s", + "1m", + "5m", + "15m", + "30m", + "1h", + "2h", + "1d" + ] + }, + "timezone": "", + "title": "Performance profiling", + "uid": "IRRL03nMk", + "version": 1 +} \ No newline at end of file diff --git a/sql/updates/world/master/2022_01_23_03_world_2020_07_24_00_world.sql b/sql/updates/world/master/2022_01_23_03_world_2020_07_24_00_world.sql new file mode 100644 index 00000000000..7a6b7b4a7ab --- /dev/null +++ b/sql/updates/world/master/2022_01_23_03_world_2020_07_24_00_world.sql @@ -0,0 +1,2 @@ +-- +DELETE FROM command WHERE NAME = 'server set difftime'; diff --git a/src/common/Metric/Metric.cpp b/src/common/Metric/Metric.cpp index 07db8e83f4d..d22839e8a79 100644 --- a/src/common/Metric/Metric.cpp +++ b/src/common/Metric/Metric.cpp @@ -137,7 +137,7 @@ void Metric::SendBatch() batchedData << ",realm=" << _realmName; for (MetricTag const& tag : data->Tags) - batchedData << "," << tag.first << "=" << tag.second; + batchedData << "," << tag.first << "=" << FormatInfluxDBTagValue(tag.second); batchedData << " "; diff --git a/src/common/Metric/Metric.h b/src/common/Metric/Metric.h index 5038338421c..33bdf3b4ed7 100644 --- a/src/common/Metric/Metric.h +++ b/src/common/Metric/Metric.h @@ -158,21 +158,27 @@ MetricStopWatch MakeMetricStopWatch(LoggerType&& loggerFunc) #define TC_METRIC_TAG(name, value) { name, value } -#ifdef PERFORMANCE_PROFILING +#define TC_METRIC_DO_CONCAT(a, b) a##b +#define TC_METRIC_CONCAT(a, b) TC_METRIC_DO_CONCAT(a, b) +#define TC_METRIC_UNIQUE_NAME(name) TC_METRIC_CONCAT(name, __LINE__) + +#if defined PERFORMANCE_PROFILING || defined WITHOUT_METRICS #define TC_METRIC_EVENT(category, title, description) ((void)0) #define TC_METRIC_VALUE(category, value) ((void)0) -#elif TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS -#define TC_METRIC_EVENT(category, title, description) \ - do { \ - if (sMetric->IsEnabled()) \ - sMetric->LogEvent(category, title, description); \ - } while (0) -#define TC_METRIC_VALUE(category, value, ...) \ - do { \ - if (sMetric->IsEnabled()) \ - sMetric->LogValue(category, value, { __VA_ARGS__ }); \ - } while (0) +#define TC_METRIC_TIMER(category, ...) ((void)0) #else +# if TRINITY_PLATFORM != TRINITY_PLATFORM_WINDOWS +#define TC_METRIC_EVENT(category, title, description) \ + do { \ + if (sMetric->IsEnabled()) \ + sMetric->LogEvent(category, title, description); \ + } while (0) +#define TC_METRIC_VALUE(category, value, ...) \ + do { \ + if (sMetric->IsEnabled()) \ + sMetric->LogValue(category, value, { __VA_ARGS__ }); \ + } while (0) +# else #define TC_METRIC_EVENT(category, title, description) \ __pragma(warning(push)) \ __pragma(warning(disable:4127)) \ @@ -189,11 +195,12 @@ MetricStopWatch MakeMetricStopWatch(LoggerType&& loggerFunc) sMetric->LogValue(category, value, { __VA_ARGS__ }); \ } while (0) \ __pragma(warning(pop)) -#endif +# endif #define TC_METRIC_TIMER(category, ...) \ - MetricStopWatch __tc_metric_stop_watch = MakeMetricStopWatch([&](TimePoint start) \ + MetricStopWatch TC_METRIC_UNIQUE_NAME(__tc_metric_stop_watch) = MakeMetricStopWatch([&](TimePoint start) \ { \ sMetric->LogValue(category, std::chrono::steady_clock::now() - start, { __VA_ARGS__ }); \ }); +#endif #endif // METRIC_H__ diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h index 27f00464483..355af8cb740 100644 --- a/src/server/game/Accounts/RBAC.h +++ b/src/server/game/Accounts/RBAC.h @@ -636,7 +636,7 @@ enum RBACPermissions RBAC_PERM_COMMAND_SERVER_RESTART_CANCEL = 728, RBAC_PERM_COMMAND_SERVER_SET = 729, RBAC_PERM_COMMAND_SERVER_SET_CLOSED = 730, - RBAC_PERM_COMMAND_SERVER_SET_DIFFTIME = 731, + RBAC_PERM_COMMAND_SERVER_SET_DIFFTIME = 731, // reserved RBAC_PERM_COMMAND_SERVER_SET_LOGLEVEL = 732, RBAC_PERM_COMMAND_SERVER_SET_MOTD = 733, RBAC_PERM_COMMAND_SERVER_SHUTDOWN = 734, diff --git a/src/server/game/Time/UpdateTime.cpp b/src/server/game/Time/UpdateTime.cpp index c4dada2853e..8e72e2c6c75 100644 --- a/src/server/game/Time/UpdateTime.cpp +++ b/src/server/game/Time/UpdateTime.cpp @@ -31,7 +31,6 @@ UpdateTime::UpdateTime() _maxUpdateTime = 0; _maxUpdateTimeOfLastTable = 0; _maxUpdateTimeOfCurrentTable = 0; - _recordedTime = 0; _updateTimeDataTable = { }; } @@ -92,47 +91,3 @@ void UpdateTime::UpdateWithDiff(uint32 diff) else if (_updateTimeTableIndex) _averageUpdateTime = _totalUpdateTime / _updateTimeTableIndex; } - -void UpdateTime::RecordUpdateTimeReset() -{ - _recordedTime = getMSTime(); -} - -void UpdateTime::_RecordUpdateTimeDuration(std::string const& text, uint32 minUpdateTime) -{ - uint32 thisTime = getMSTime(); - uint32 diff = getMSTimeDiff(_recordedTime, thisTime); - - if (diff > minUpdateTime) - TC_LOG_INFO("misc", "Recored Update Time of %s: %u.", text.c_str(), diff); - - _recordedTime = thisTime; -} - -void WorldUpdateTime::LoadFromConfig() -{ - _recordUpdateTimeInverval = sConfigMgr->GetIntDefault("RecordUpdateTimeDiffInterval", 60000); - _recordUpdateTimeMin = sConfigMgr->GetIntDefault("MinRecordUpdateTimeDiff", 100); -} - -void WorldUpdateTime::SetRecordUpdateTimeInterval(uint32 t) -{ - _recordUpdateTimeInverval = t; -} - -void WorldUpdateTime::RecordUpdateTime(uint32 gameTimeMs, uint32 diff, uint32 sessionCount) -{ - if (_recordUpdateTimeInverval > 0 && diff > _recordUpdateTimeMin) - { - if (getMSTimeDiff(_lastRecordTime, gameTimeMs) > _recordUpdateTimeInverval) - { - TC_LOG_DEBUG("misc", "Update time diff: %u. Players online: %u.", GetAverageUpdateTime(), sessionCount); - _lastRecordTime = gameTimeMs; - } - } -} - -void WorldUpdateTime::RecordUpdateTimeDuration(std::string const& text) -{ - _RecordUpdateTimeDuration(text, _recordUpdateTimeMin); -} diff --git a/src/server/game/Time/UpdateTime.h b/src/server/game/Time/UpdateTime.h index 139566fd468..ab51c08fdd9 100644 --- a/src/server/game/Time/UpdateTime.h +++ b/src/server/game/Time/UpdateTime.h @@ -37,13 +37,9 @@ class TC_GAME_API UpdateTime void UpdateWithDiff(uint32 diff); - void RecordUpdateTimeReset(); - protected: UpdateTime(); - void _RecordUpdateTimeDuration(std::string const& text, uint32 minUpdateTime); - private: DiffTableArray _updateTimeDataTable; uint32 _averageUpdateTime; @@ -52,23 +48,12 @@ class TC_GAME_API UpdateTime uint32 _maxUpdateTime; uint32 _maxUpdateTimeOfLastTable; uint32 _maxUpdateTimeOfCurrentTable; - - uint32 _recordedTime; }; class TC_GAME_API WorldUpdateTime : public UpdateTime { public: - WorldUpdateTime() : UpdateTime(), _recordUpdateTimeInverval(0), _recordUpdateTimeMin(0), _lastRecordTime(0) { } - void LoadFromConfig(); - void SetRecordUpdateTimeInterval(uint32 t); - void RecordUpdateTime(uint32 gameTimeMs, uint32 diff, uint32 sessionCount); - void RecordUpdateTimeDuration(std::string const& text); - - private: - uint32 _recordUpdateTimeInverval; - uint32 _recordUpdateTimeMin; - uint32 _lastRecordTime; + WorldUpdateTime() : UpdateTime() { } }; TC_GAME_API extern WorldUpdateTime sWorldUpdateTime; diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 7848c80f0f1..38438911af5 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -554,9 +554,6 @@ void World::LoadConfigSettings(bool reload) TC_LOG_INFO("server.loading", "Using %s DBC Locale", localeNames[m_defaultDbcLocale]); - // load update time related configs - sWorldUpdateTime.LoadFromConfig(); - ///- Read the player limit and the Message of the day from the config file SetPlayerAmountLimit(sConfigMgr->GetIntDefault("PlayerLimit", 100)); SetMotd(sConfigMgr->GetStringDefault("Motd", "Welcome to a Trinity Core Server.")); @@ -2511,15 +2508,13 @@ void World::LoadAutobroadcasts() /// Update the World ! void World::Update(uint32 diff) { + TC_METRIC_TIMER("world_update_time_total"); ///- Update the game time and check for shutdown time _UpdateGameTime(); time_t currentGameTime = GameTime::GetGameTime(); sWorldUpdateTime.UpdateWithDiff(diff); - // Record update if recording set in log and diff is greater then minimum set in log - sWorldUpdateTime.RecordUpdateTime(GameTime::GetGameTimeMS(), diff, GetActiveSessionCount()); - ///- Update the different timers for (int i = 0; i < WUPDATE_COUNT; ++i) { @@ -2532,6 +2527,7 @@ void World::Update(uint32 diff) ///- Update Who List Storage if (m_timers[WUPDATE_WHO_LIST].Passed()) { + TC_METRIC_TIMER("world_update_time", TC_METRIC_TAG("type", "Update who list")); m_timers[WUPDATE_WHO_LIST].Reset(); sWhoListStorageMgr->Update(); } @@ -2542,6 +2538,7 @@ void World::Update(uint32 diff) if (sWorld->getBoolConfig(CONFIG_PRESERVE_CUSTOM_CHANNELS)) { + TC_METRIC_TIMER("world_update_time", TC_METRIC_TAG("type", "Save custom channels")); ChannelMgr* mgr1 = ASSERT_NOTNULL(ChannelMgr::ForTeam(ALLIANCE)); mgr1->SaveToDB(); ChannelMgr* mgr2 = ASSERT_NOTNULL(ChannelMgr::ForTeam(HORDE)); @@ -2550,23 +2547,39 @@ void World::Update(uint32 diff) } } - CheckScheduledResetTimes(); + { + TC_METRIC_TIMER("world_update_time", TC_METRIC_TAG("type", "Check daily reset times")); + CheckScheduledResetTimes(); + } if (currentGameTime > m_NextRandomBGReset) + { + TC_METRIC_TIMER("world_update_time", TC_METRIC_TAG("type", "Reset random BG")); ResetRandomBG(); + } if (currentGameTime > m_NextCalendarOldEventsDeletionTime) + { + TC_METRIC_TIMER("world_update_time", TC_METRIC_TAG("type", "Delete old calendar events")); CalendarDeleteOldEvents(); + } if (currentGameTime > m_NextGuildReset) + { + TC_METRIC_TIMER("world_update_time", TC_METRIC_TAG("type", "Reset guild cap")); ResetGuildCap(); + } if (currentGameTime > m_NextCurrencyReset) + { + TC_METRIC_TIMER("world_update_time", TC_METRIC_TAG("type", "Reset currency weekly cap")); ResetCurrencyWeekCap(); + } ///