some hacking on server performance

This commit is contained in:
ZappoMan 2014-02-27 10:47:17 -08:00
parent 89cf2f9a7a
commit cdb0aeb153
5 changed files with 46 additions and 5 deletions

View file

@ -52,6 +52,8 @@ bool OctreeSendThread::process() {
}
node->getMutex().unlock(); // we're done with this node for now.
} else {
qDebug("OctreeSendThread::process() failed to get node lock");
}
}
} else {
@ -70,8 +72,8 @@ bool OctreeSendThread::process() {
PerformanceWarning warn(false,"OctreeSendThread... usleep()",false,&_usleepTime,&_usleepCalls);
usleep(usecToSleep);
} else {
if (_myServer->wantsDebugSending() && _myServer->wantsVerboseDebug()) {
std::cout << "Last send took too much time, not sleeping!\n";
if (true || (_myServer->wantsDebugSending() && _myServer->wantsVerboseDebug())) {
qDebug() << "Last send took too much time (" << (elapsed / USECS_PER_MSEC) <<" msecs), not sleeping!\n";
}
}
}
@ -420,9 +422,23 @@ int OctreeSendThread::packetDistributor(const SharedNodePointer& node, OctreeQue
isFullScene, &nodeData->stats, _myServer->getJurisdiction());
quint64 lockWaitStart = usecTimestampNow();
_myServer->getOctree()->lockForRead();
quint64 lockWaitEnd = usecTimestampNow();
int lockWaitElapsedMsec = (lockWaitEnd - lockWaitStart)/USECS_PER_MSEC;
if (lockWaitElapsedMsec > 0) {
qDebug() << "lockWaitElapsedMsec=" << lockWaitElapsedMsec;
}
nodeData->stats.encodeStarted();
quint64 encodeStart = usecTimestampNow();
bytesWritten = _myServer->getOctree()->encodeTreeBitstream(subTree, &_packetData, nodeData->nodeBag, params);
quint64 encodeEnd = usecTimestampNow();
int encodeElapsedMsec = (encodeEnd - encodeStart)/USECS_PER_MSEC;
if (encodeElapsedMsec > 0) {
qDebug() << "encodeElapsedMsec=" << encodeElapsedMsec;
}
// If after calling encodeTreeBitstream() there are no nodes left to send, then we know we've
// sent the entire scene. We want to know this below so we'll actually write this content into
@ -543,7 +559,11 @@ int OctreeSendThread::packetDistributor(const SharedNodePointer& node, OctreeQue
quint64 endCompressTimeMsecs = OctreePacketData::getCompressContentTime() / 1000;
int elapsedCompressTimeMsecs = endCompressTimeMsecs - startCompressTimeMsecs;
if (elapsedmsec > 0) {
qDebug() << "elapsedmsec=" << elapsedmsec;
}
OctreeServer::trackLoopTime((float)elapsedmsec);
if (elapsedmsec > 100) {
if (elapsedmsec > 1000) {
int elapsedsec = (end - start)/1000000;

View file

@ -19,6 +19,8 @@
#include "OctreeServerConsts.h"
OctreeServer* OctreeServer::_instance = NULL;
int OctreeServer::_clientCount = 0;
SimpleMovingAverage OctreeServer::_averageLoopTime(1000);
void OctreeServer::attachQueryNodeToNode(Node* newNode) {
if (newNode->getLinkedData() == NULL) {
@ -48,6 +50,7 @@ OctreeServer::OctreeServer(const QByteArray& packet) :
_startedUSecs(usecTimestampNow())
{
_instance = this;
_averageLoopTime.updateAverage(0);
}
OctreeServer::~OctreeServer() {
@ -234,6 +237,19 @@ bool OctreeServer::handleHTTPRequest(HTTPConnection* connection, const QString&
quint64 totalBytesOfColor = OctreePacketData::getTotalBytesOfColor();
const int COLUMN_WIDTH = 10;
statsString += QString(" Configured Max PPS/Client: %1 pps/client\r\n")
.arg(locale.toString((uint)getPacketsPerClientPerSecond()).rightJustified(COLUMN_WIDTH, ' '));
statsString += QString(" Configured Max PPS/Server: %1 pps/server\r\n\r\n")
.arg(locale.toString((uint)getPacketsTotalPerSecond()).rightJustified(COLUMN_WIDTH, ' '));
statsString += QString(" Total Clients Connected: %1 clients\r\n\r\n")
.arg(locale.toString((uint)getCurrentClientCount()).rightJustified(COLUMN_WIDTH, ' '));
float averageLoopTime = _averageLoopTime.getAverage();
statsString += QString().sprintf(" Average packetLoop() time: %5.2f msecs\r\n", averageLoopTime);
qDebug() << "_averageLoopTime.getAverage()=" << averageLoopTime;
statsString += QString(" Total Outbound Packets: %1 packets\r\n")
.arg(locale.toString((uint)totalOutboundPackets).rightJustified(COLUMN_WIDTH, ' '));
statsString += QString(" Total Outbound Bytes: %1 bytes\r\n")

View file

@ -63,6 +63,8 @@ public:
static void attachQueryNodeToNode(Node* newNode);
static void trackLoopTime(float time) { _averageLoopTime.updateAverage(time); }
bool handleHTTPRequest(HTTPConnection* connection, const QString& path);
public slots:
/// runs the voxel server assignment
@ -95,6 +97,9 @@ protected:
time_t _started;
quint64 _startedUSecs;
static int _clientCount;
static SimpleMovingAverage _averageLoopTime;
};
#endif // __octree_server__OctreeServer__

View file

@ -68,9 +68,7 @@ bool OctreePersistThread::process() {
usleep(USECS_TO_SLEEP);
// do our updates then check to save...
_tree->lockForWrite();
_tree->update();
_tree->unlock();
quint64 now = usecTimestampNow();
quint64 sinceLastSave = now - _lastCheck;

View file

@ -474,7 +474,9 @@ void ParticleTree::update() {
AABox treeBounds = getRoot()->getAABox();
if (!shouldDie && treeBounds.contains(args._movingParticles[i].getPosition())) {
lockForWrite();
storeParticle(args._movingParticles[i]);
unlock();
} else {
uint32_t particleID = args._movingParticles[i].getID();
quint64 deletedAt = usecTimestampNow();