mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-02 02:43:44 +00:00
feat(servers): time the main loops' phases and the known heavy spots
Frames and phase scopes in the world, auth, chat and UGC loops (packets per type, entities, physics, ghosting, replica, spawners, log flush, saves, web requests by route). Scopes at LoadPlayer, CreateEntity, each component's construction, InventoryComponent::LoadXml, script timers and a world's zone load; game database queries in the query helpers; CDClient statements timed through sqlite3_trace_v2 as CDClient <table> (CppSQLite3DB gets a handle accessor). Task 96. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1152,6 +1152,7 @@ void Entity::Update(const float deltaTime) {
|
||||
// Remove the timer from the list of timers first so that scripts and events can remove timers without causing iterator invalidation
|
||||
auto timerName = timer.GetName();
|
||||
m_Timers.erase(m_Timers.begin() + timerPosition);
|
||||
Profiler::Scope profile("Script timer", Profiler::Phase::SCRIPTS);
|
||||
GetScript()->OnTimerDone(this, timerName);
|
||||
VanityUtilities::OnTimerDone(this, timerName);
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "LDFFormat.h"
|
||||
#include "eKillType.h"
|
||||
#include "Observable.h"
|
||||
#include "Profiler.h"
|
||||
|
||||
namespace GameMessages {
|
||||
struct GameMsg;
|
||||
@@ -589,6 +590,8 @@ T Entity::GetNetworkVar(const std::u16string& name) {
|
||||
template<typename ComponentType, typename... VaArgs>
|
||||
inline ComponentType* Entity::AddComponent(VaArgs... args) {
|
||||
static_assert(std::is_base_of_v<Component, ComponentType>, "ComponentType must be a Component");
|
||||
// Frame timing: each component type's construction (loading a character's XML is in some of them)
|
||||
Profiler::Scope profile(Profiler::COMPONENT, static_cast<uint64_t>(ComponentType::ComponentType));
|
||||
|
||||
// Get the component if it already exists, or default construct a nullptr
|
||||
auto*& componentToReturn = m_Components[ComponentType::ComponentType];
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "EntityManager.h"
|
||||
#include "Profiler.h"
|
||||
#include "RakNetTypes.h"
|
||||
#include "Game.h"
|
||||
#include "User.h"
|
||||
@@ -117,6 +118,7 @@ void EntityManager::Initialize() {
|
||||
}
|
||||
|
||||
Entity* EntityManager::CreateEntity(EntityInfo info, User* user, Entity* parentEntity, const bool controller, const LWOOBJID explicitId) {
|
||||
Profiler::Scope profile("CreateEntity");
|
||||
|
||||
// Determine the objectID for the new entity
|
||||
LWOOBJID id;
|
||||
@@ -286,11 +288,18 @@ void EntityManager::DeleteEntities() {
|
||||
}
|
||||
|
||||
void EntityManager::UpdateEntities(const float deltaTime) {
|
||||
for (auto* entity : m_Entities | std::views::values) {
|
||||
entity->Update(deltaTime);
|
||||
{
|
||||
Profiler::Scope profile("Entity updates");
|
||||
for (auto* entity : m_Entities | std::views::values) {
|
||||
entity->Update(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
SerializeEntities();
|
||||
{
|
||||
Profiler::Scope profile("Serialize entities", Profiler::Phase::REPLICA);
|
||||
SerializeEntities();
|
||||
}
|
||||
Profiler::Scope profile("Kill and delete entities");
|
||||
KillEntities();
|
||||
DeleteEntities();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "InventoryComponent.h"
|
||||
#include "Profiler.h"
|
||||
#include "BrickByBrick.h"
|
||||
#include "Contraband.h"
|
||||
#include "EconomyLedger.h"
|
||||
@@ -668,6 +669,7 @@ namespace {
|
||||
}
|
||||
|
||||
void InventoryComponent::LoadXml(const tinyxml2::XMLDocument& document) {
|
||||
Profiler::Scope profile("InventoryComponent::LoadXml");
|
||||
LoadPetXml(document);
|
||||
|
||||
auto* inventoryElement = document.FirstChildElement("obj")->FirstChildElement("inv");
|
||||
|
||||
Reference in New Issue
Block a user