Update of /cvsroot/wpdev/wolfpack
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17868
Modified Files:
ChangeLog console.cpp server.cpp serverconfig.cpp timing.cpp
wolfpack.vcproj
Added Files:
profile.cpp profile.h
Log Message:
fixes
--- NEW FILE: profile.h ---
#if !defined(__PROFILE_H__)
#define __PROFILE_H__
enum eProfileKeys {
PF_NICENESS = 0,
PF_SPAWNCHECK,
PF_DECAYCHECK,
PF_WORLDSAVE,
PF_UOTIMECHECK,
PF_COMBATCHECK,
PF_TIMERSCHECK,
PF_AICHECK,
PF_NPCCHECK,
PF_PLAYERCHECK,
PF_REGENERATION,
PF_AICHECKFINDACTION,
PF_AICHECKEXECUTEACTION,
PF_COUNT,
};
#define ENABLE_PROFILING 0
#if defined(ENABLE_PROFILING)
void startProfiling(eProfileKeys key);
void stopProfiling(eProfileKeys key);
void dumpProfilingInfo();
void clearProfilingInfo();
#else
#define startProfiling(key)
#define stopProfiling(key)
#define dumpProfilingInfo()
#define clearProfilingInfo()
#endif
#endif
Index: serverconfig.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/serverconfig.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** serverconfig.cpp 14 Sep 2004 04:20:23 -0000 1.8
--- serverconfig.cpp 18 Sep 2004 21:10:40 -0000 1.9
***************
*** 201,206 ****
pathfind4Follow_ = getBool( "Path Finding", "Activate for Following", true, true );
pathfind4Combat_ = getBool( "Path Finding", "Activate for Combat", false, true );
! pathfindMaxIterations_ = getNumber( "Path Finding", "Maximum Iterations during Calculation", 100, true );
! pathfindMaxSteps_ = getNumber( "Path Finding", "Maximum Steps for Calculation", 20, true );
pathfindFollowRadius_ = getNumber( "Path Finding", "Follow Radius", 10, true );
pathfindFollowMinCost_ = getDouble( "Path Finding", "Follow min. estimated Cost", 1.5, true );
--- 201,206 ----
pathfind4Follow_ = getBool( "Path Finding", "Activate for Following", true, true );
pathfind4Combat_ = getBool( "Path Finding", "Activate for Combat", false, true );
! pathfindMaxIterations_ = getNumber( "Path Finding", "Maximum Iterations during Calculation", 45, true );
! pathfindMaxSteps_ = getNumber( "Path Finding", "Maximum Steps for Calculation", 15, true );
pathfindFollowRadius_ = getNumber( "Path Finding", "Follow Radius", 10, true );
pathfindFollowMinCost_ = getDouble( "Path Finding", "Follow min. estimated Cost", 1.5, true );
Index: server.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/server.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** server.cpp 14 Sep 2004 00:00:38 -0000 1.22
--- server.cpp 18 Sep 2004 21:10:40 -0000 1.23
***************
*** 56,59 ****
--- 56,60 ----
#include "multi.h"
#include "persistentbroker.h"
+ #include "profile.h"
// System Includes
***************
*** 310,318 ****
unsigned char cycles = 0;
! while ( isRunning() )
! {
// Every 10th cycle we sleep for a while and give other threads processing time.
if ( ++cycles == 10 )
{
cycles = 0;
_save = PyEval_SaveThread(); // Python threading - start
--- 311,322 ----
unsigned char cycles = 0;
! clearProfilingInfo();
!
! while ( isRunning() ) {
// Every 10th cycle we sleep for a while and give other threads processing time.
if ( ++cycles == 10 )
{
+ startProfiling(PF_NICENESS);
+
cycles = 0;
_save = PyEval_SaveThread(); // Python threading - start
***************
*** 345,348 ****
--- 349,354 ----
qApp->processEvents( 40 );
PyEval_RestoreThread( _save ); // Python threading - end
+
+ stopProfiling(PF_NICENESS);
}
***************
*** 363,366 ****
--- 369,374 ----
}
+ dumpProfilingInfo();
+
} catch (wpException &exception) {
Console::instance()->log(LOG_ERROR, exception.error() + "\n" );
Index: ChangeLog
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/ChangeLog,v
retrieving revision 1.62
retrieving revision 1.63
diff -C2 -d -r1.62 -r1.63
*** ChangeLog 18 Sep 2004 18:50:23 -0000 1.62
--- ChangeLog 18 Sep 2004 21:10:39 -0000 1.63
***************
*** 17,21 ****
- Fixed bug #0000253. (Invalid drop sound for items dropped to ground)
- Fixed bug #0000309. (Console in web administration caused endless loop)
- - Completely rewrote line of sight.
- Fixed a crashbug related to trying to remove basescripts from objects.
- Fixed a crasbhug related to players being removed and the owner property of their
--- 17,20 ----
***************
*** 26,29 ****
--- 25,30 ----
- Fixed bug #0000317. (Server not refusing to load even when accounts db corrupt)
- Fixed bug #0000187. (Land and Static targets on height -1 were broken)
+ - Resolved an issue with extreme lag and NPC ai.
+ - Added a rudimentary method for profiling parts of the code.
- Complete LOS Rewrite (works much better and faster now)
- Fixed persistency issue for dupe() and sql saves.
Index: wolfpack.vcproj
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/wolfpack.vcproj,v
retrieving revision 1.49
retrieving revision 1.50
diff -C2 -d -r1.49 -r1.50
*** wolfpack.vcproj 16 Sep 2004 16:43:27 -0000 1.49
--- wolfpack.vcproj 18 Sep 2004 21:10:40 -0000 1.50
***************
*** 457,460 ****
--- 457,466 ----
</File>
<File
+ RelativePath=".\profile.cpp">
+ </File>
+ <File
+ RelativePath=".\profile.h">
+ </File>
+ <File
RelativePath=".\progress.h">
</File>
--- NEW FILE: profile.cpp ---
#include "profile.h"
#include "console.h"
#if defined(ENABLE_PROFILING)
const char *profileNames[PF_COUNT] = {
"Niceness/PythonThreads",
"Spawnregion Checks",
"DecayCheck",
"WorldSave",
"UO Time Check",
"Combat Check",
"Timers Check",
"AI Check",
"NPC Check",
"Player Check",
"Regeneration Check",
"AI Check\\Search New Action",
"AI Check\\Execute Action",
};
// Time in MS spent in the given profile keys
unsigned int profileData[PF_COUNT];
unsigned int profileStart[PF_COUNT];
// Time spent from first to last profiling
unsigned int startTime = 0;
void startProfiling(eProfileKeys key) {
Server::instance()->refreshTime();
unsigned int time = Server::instance()->time();
// Let's just say this has been the server start
if (!startTime) {
startTime = time;
}
profileStart[key] = time;
}
void stopProfiling(eProfileKeys key) {
Server::instance()->refreshTime();
unsigned int time = Server::instance()->time();
unsigned int diff = time - profileStart[key];
profileData[key] += diff;
}
void clearProfilingInfo() {
Server::instance()->refreshTime();
startTime = Server::instance()->time();
for (int i = 0; i < PF_COUNT; ++i) {
profileData[i] = 0;
}
}
void dumpProfilingInfo() {
Server::instance()->refreshTime();
unsigned int total = Server::instance()->time() - startTime;
Console::instance()->send("PROFILING INFORMATION:\n");
Console::instance()->send("TOTAL TIME: " + QString::number(total) + "\n");
for (int i = 0; i < PF_COUNT; ++i) {
Console::instance()->send(profileNames[i]);
Console::instance()->send(QString(": %1\n").arg(profileData[i]));
}
// Clear Profiling Info
clearProfilingInfo();
}
#endif
Index: timing.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/timing.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** timing.cpp 9 Sep 2004 03:19:58 -0000 1.14
--- timing.cpp 18 Sep 2004 21:10:40 -0000 1.15
***************
*** 30,33 ****
--- 30,34 ----
#include "timing.h"
+ #include "profile.h"
#include "basics.h"
***************
*** 88,93 ****
--- 89,96 ----
if ( nextSpawnRegionCheck <= time )
{
+ startProfiling(PF_SPAWNCHECK);
SpawnRegions::instance()->check();
nextSpawnRegionCheck = time + Config::instance()->spawnRegionCheckTime() * MY_CLOCKS_PER_SEC;
+ stopProfiling(PF_SPAWNCHECK);
}
***************
*** 95,98 ****
--- 98,102 ----
if ( nextItemCheck <= time )
{
+ startProfiling(PF_DECAYCHECK);
QValueVector<SERIAL> toRemove;
DecayIterator it = decayitems.begin();
***************
*** 121,125 ****
}
! nextItemCheck += 5000;
}
--- 125,131 ----
}
! nextItemCheck = time + 5000;
!
! stopProfiling(PF_DECAYCHECK);
}
***************
*** 127,130 ****
--- 133,138 ----
if ( Config::instance()->saveInterval() )
{
+ startProfiling(PF_WORLDSAVE);
+
// Calculate the next worldsave based on the last worldsave
unsigned int nextSave = lastWorldsave() + Config::instance()->saveInterval() * MY_CLOCKS_PER_SEC;
***************
*** 134,137 ****
--- 142,147 ----
World::instance()->save();
}
+
+ stopProfiling(PF_WORLDSAVE);
}
***************
*** 141,144 ****
--- 151,156 ----
if ( nextUOTimeTick <= time )
{
+ startProfiling(PF_UOTIMECHECK);
+
unsigned char oldhour = UoTime::instance()->hour();
UoTime::instance()->setMinutes( UoTime::instance()->getMinutes() + 1 );
***************
*** 189,196 ****
--- 201,212 ----
currentLevel = newLevel;
}
+
+ stopProfiling(PF_UOTIMECHECK);
}
if ( nextCombatCheck <= time )
{
+ startProfiling(PF_COMBATCHECK);
+
nextCombatCheck = time + 250;
***************
*** 221,224 ****
--- 237,242 ----
}
}
+
+ stopProfiling(PF_COMBATCHECK);
}
***************
*** 234,238 ****
--- 252,259 ----
}
+ startProfiling(PF_PLAYERCHECK);
socket->player()->poll( time, events );
+ stopProfiling(PF_PLAYERCHECK);
+
checkRegeneration( socket->player(), time );
checkPlayer( socket->player(), time );
***************
*** 258,262 ****
--- 279,285 ----
checkRegeneration( npc, time );
checkNpc( npc, time );
+ startProfiling(PF_NPCCHECK);
npc->poll( time, events );
+ stopProfiling(PF_NPCCHECK);
break;
}
***************
*** 283,287 ****
--- 306,312 ----
// Check the Timers
+ startProfiling(PF_TIMERSCHECK);
Timers::instance()->check();
+ stopProfiling(PF_TIMERSCHECK);
if ( nextHungerCheck <= time )
***************
*** 297,300 ****
--- 322,327 ----
}
+ startProfiling(PF_REGENERATION);
+
if ( character->regenHitpointsTime() <= time )
{
***************
*** 349,356 ****
--- 376,387 ----
}
}
+
+ stopProfiling(PF_REGENERATION);
}
void cTiming::checkPlayer( P_PLAYER player, unsigned int time )
{
+ startProfiling(PF_PLAYERCHECK);
+
cUOSocket* socket = player->socket();
***************
*** 401,404 ****
--- 432,437 ----
}
}
+
+ stopProfiling(PF_PLAYERCHECK);
}
***************
*** 418,423 ****
if ( npc->ai() && npc->aiCheckTime() <= time )
{
! npc->setAICheckTime( ( uint )( time + Config::instance()->checkAITime() * MY_CLOCKS_PER_SEC ) );
npc->ai()->check();
}
--- 451,459 ----
if ( npc->ai() && npc->aiCheckTime() <= time )
{
! startProfiling(PF_AICHECK);
! unsigned int delay = RandomNum(250, 750);
! npc->setAICheckTime( time + delay );
npc->ai()->check();
+ stopProfiling(PF_AICHECK);
}
Index: console.cpp
===================================================================
RCS file: /cvsroot/wpdev/wolfpack/console.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** console.cpp 19 Aug 2004 01:22:51 -0000 1.24
--- console.cpp 18 Sep 2004 21:10:40 -0000 1.25
***************
*** 30,33 ****
--- 30,34 ----
#include "pythonscript.h"
#include "log.h"
+ #include "profile.h"
#include "world.h"
***************
*** 142,145 ****
--- 143,150 ----
break;
+ case 'P':
+ dumpProfilingInfo();
+ break;
+
case 'W':
Console::instance()->send( "Current Users in the World:\n" );
|