mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 12:13:40 +02:00
get voxel packet statistics to work and add them to server status page
This commit is contained in:
parent
8d8d73a940
commit
8bb2bd2ecf
5 changed files with 81 additions and 15 deletions
|
@ -111,7 +111,9 @@ int VoxelSendThread::handlePacketSend(Node* node, VoxelNodeData* nodeData, int&
|
|||
memcpy(statsMessage + statsMessageLength, nodeData->getPacket(), nodeData->getPacketLength());
|
||||
statsMessageLength += nodeData->getPacketLength();
|
||||
|
||||
int thisWastedBytes = MAX_PACKET_SIZE - statsMessageLength; // the statsMessageLength at this point includes data
|
||||
// since a stats message is only included on end of scene, don't consider any of these bytes "wasted", since
|
||||
// there was nothing else to send.
|
||||
int thisWastedBytes = 0;
|
||||
_totalWastedBytes += thisWastedBytes;
|
||||
_totalBytes += nodeData->getPacketLength();
|
||||
_totalPackets++;
|
||||
|
@ -129,7 +131,9 @@ int VoxelSendThread::handlePacketSend(Node* node, VoxelNodeData* nodeData, int&
|
|||
// not enough room in the packet, send two packets
|
||||
NodeList::getInstance()->getNodeSocket()->send(node->getActiveSocket(), statsMessage, statsMessageLength);
|
||||
|
||||
int thisWastedBytes = MAX_PACKET_SIZE - statsMessageLength; // the statsMessageLength is only the stats
|
||||
// since a stats message is only included on end of scene, don't consider any of these bytes "wasted", since
|
||||
// there was nothing else to send.
|
||||
int thisWastedBytes = 0;
|
||||
_totalWastedBytes += thisWastedBytes;
|
||||
_totalBytes += nodeData->getPacketLength();
|
||||
_totalPackets++;
|
||||
|
|
|
@ -22,6 +22,11 @@
|
|||
class VoxelSendThread : public virtual GenericThread {
|
||||
public:
|
||||
VoxelSendThread(const QUuid& nodeUUID, VoxelServer* myServer);
|
||||
|
||||
static uint64_t _totalBytes;
|
||||
static uint64_t _totalWastedBytes;
|
||||
static uint64_t _totalPackets;
|
||||
|
||||
protected:
|
||||
/// Implements generic processing behavior for this thread.
|
||||
virtual bool process();
|
||||
|
@ -37,10 +42,6 @@ private:
|
|||
VoxelPacket _tempPacket;
|
||||
bool _encodedSomething;
|
||||
|
||||
static uint64_t _totalBytes;
|
||||
static uint64_t _totalWastedBytes;
|
||||
static uint64_t _totalPackets;
|
||||
|
||||
};
|
||||
|
||||
#endif // __voxel_server__VoxelSendThread__
|
||||
|
|
|
@ -262,6 +262,36 @@ int VoxelServer::civetwebRequestHandler(struct mg_connection* connection) {
|
|||
mg_printf(connection, "%s", "\r\n");
|
||||
mg_printf(connection, "%s", "\r\n");
|
||||
|
||||
|
||||
// display outbound packet stats
|
||||
mg_printf(connection, "%s", "<b>Voxel Packet Statistics...</b>\r\n");
|
||||
uint64_t totalOutboundPackets = VoxelSendThread::_totalPackets;
|
||||
uint64_t totalOutboundBytes = VoxelSendThread::_totalBytes;
|
||||
uint64_t totalWastedBytes = VoxelSendThread::_totalWastedBytes;
|
||||
uint64_t totalBytesOfOctalCodes = VoxelPacket::_totalBytesOfOctalCodes;
|
||||
uint64_t totalBytesOfBitMasks = VoxelPacket::_totalBytesOfBitMasks;
|
||||
uint64_t totalBytesOfColor = VoxelPacket::_totalBytesOfColor;
|
||||
|
||||
const int COLUMN_WIDTH = 10;
|
||||
mg_printf(connection, " Total Outbound Packets: %s packets\r\n",
|
||||
locale.toString((uint)totalOutboundPackets).rightJustified(COLUMN_WIDTH, ' ').toLocal8Bit().constData());
|
||||
mg_printf(connection, " Total Outbound Bytes: %s bytes\r\n",
|
||||
locale.toString((uint)totalOutboundBytes).rightJustified(COLUMN_WIDTH, ' ').toLocal8Bit().constData());
|
||||
mg_printf(connection, " Total Wasted Bytes: %s bytes\r\n",
|
||||
locale.toString((uint)totalWastedBytes).rightJustified(COLUMN_WIDTH, ' ').toLocal8Bit().constData());
|
||||
mg_printf(connection, " Total OctalCode Bytes: %s bytes (%5.2f%%)\r\n",
|
||||
locale.toString((uint)totalBytesOfOctalCodes).rightJustified(COLUMN_WIDTH, ' ').toLocal8Bit().constData(),
|
||||
((float)totalBytesOfOctalCodes / (float)totalOutboundBytes) * AS_PERCENT);
|
||||
mg_printf(connection, " Total BitMasks Bytes: %s bytes (%5.2f%%)\r\n",
|
||||
locale.toString((uint)totalBytesOfBitMasks).rightJustified(COLUMN_WIDTH, ' ').toLocal8Bit().constData(),
|
||||
((float)totalBytesOfBitMasks / (float)totalOutboundBytes) * AS_PERCENT);
|
||||
mg_printf(connection, " Total Color Bytes: %s bytes (%5.2f%%)\r\n",
|
||||
locale.toString((uint)totalBytesOfColor).rightJustified(COLUMN_WIDTH, ' ').toLocal8Bit().constData(),
|
||||
((float)totalBytesOfColor / (float)totalOutboundBytes) * AS_PERCENT);
|
||||
|
||||
mg_printf(connection, "%s", "\r\n");
|
||||
mg_printf(connection, "%s", "\r\n");
|
||||
|
||||
// display inbound packet stats
|
||||
mg_printf(connection, "%s", "<b>Voxel Edit Statistics... <a href='/resetStats'>[RESET]</a></b>\r\n");
|
||||
uint64_t averageTransitTimePerPacket = theServer->_voxelServerPacketProcessor->getAverageTransitTimePerPacket();
|
||||
|
@ -274,7 +304,6 @@ int VoxelServer::civetwebRequestHandler(struct mg_connection* connection) {
|
|||
|
||||
float averageVoxelsPerPacket = totalPacketsProcessed == 0 ? 0 : totalVoxelsProcessed / totalPacketsProcessed;
|
||||
|
||||
const int COLUMN_WIDTH = 10;
|
||||
mg_printf(connection, " Total Inbound Packets: %s packets\r\n",
|
||||
locale.toString((uint)totalPacketsProcessed).rightJustified(COLUMN_WIDTH, ' ').toLocal8Bit().constData());
|
||||
mg_printf(connection, " Total Inbound Voxels: %s voxels\r\n",
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
#include "VoxelPacket.h"
|
||||
|
||||
bool VoxelPacket::_debug = false;
|
||||
uint64_t VoxelPacket::_bytesOfOctalCodes = 0;
|
||||
uint64_t VoxelPacket::_bytesOfBitMasks = 0;
|
||||
uint64_t VoxelPacket::_bytesOfColor = 0;
|
||||
uint64_t VoxelPacket::_totalBytesOfOctalCodes = 0;
|
||||
uint64_t VoxelPacket::_totalBytesOfBitMasks = 0;
|
||||
uint64_t VoxelPacket::_totalBytesOfColor = 0;
|
||||
|
||||
|
||||
|
||||
|
@ -33,6 +33,11 @@ void VoxelPacket::reset() {
|
|||
_compressedBytes = 0;
|
||||
_bytesInUseLastCheck = 0;
|
||||
_dirty = false;
|
||||
|
||||
_bytesOfOctalCodes = 0;
|
||||
_bytesOfBitMasks = 0;
|
||||
_bytesOfColor = 0;
|
||||
_bytesOfOctalCodesCurrentSubTree = 0;
|
||||
}
|
||||
|
||||
VoxelPacket::~VoxelPacket() {
|
||||
|
@ -84,6 +89,7 @@ bool VoxelPacket::updatePriorBytes(int offset, const unsigned char* replacementB
|
|||
}
|
||||
|
||||
bool VoxelPacket::startSubTree(const unsigned char* octcode) {
|
||||
_bytesOfOctalCodesCurrentSubTree = _bytesOfOctalCodes;
|
||||
bool success = false;
|
||||
int possibleStartAt = _bytesInUse;
|
||||
int length = 0;
|
||||
|
@ -101,6 +107,7 @@ bool VoxelPacket::startSubTree(const unsigned char* octcode) {
|
|||
}
|
||||
if (success) {
|
||||
_bytesOfOctalCodes += length;
|
||||
_totalBytesOfOctalCodes += length;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -146,15 +153,33 @@ void VoxelPacket::discardSubTree() {
|
|||
_bytesAvailable += bytesInSubTree;
|
||||
_subTreeAt = _bytesInUse; // should be the same actually...
|
||||
_dirty = true;
|
||||
|
||||
// rewind to start of this subtree, other items rewound by endLevel()
|
||||
int reduceBytesOfOctalCodes = _bytesOfOctalCodes - _bytesOfOctalCodesCurrentSubTree;
|
||||
_bytesOfOctalCodes = _bytesOfOctalCodesCurrentSubTree;
|
||||
_totalBytesOfOctalCodes -= reduceBytesOfOctalCodes;
|
||||
}
|
||||
|
||||
LevelDetails VoxelPacket::startLevel() {
|
||||
LevelDetails key(_bytesInUse,0,0,0);
|
||||
LevelDetails key(_bytesInUse, _bytesOfOctalCodes, _bytesOfBitMasks, _bytesOfColor);
|
||||
return key;
|
||||
}
|
||||
|
||||
void VoxelPacket::discardLevel(LevelDetails key) {
|
||||
int bytesInLevel = _bytesInUse - key._startIndex;
|
||||
|
||||
// reset statistics...
|
||||
int reduceBytesOfOctalCodes = _bytesOfOctalCodes - key._bytesOfOctalCodes;
|
||||
int reduceBytesOfBitMasks = _bytesOfBitMasks - key._bytesOfBitmasks;
|
||||
int reduceBytesOfColor = _bytesOfColor - key._bytesOfColor;
|
||||
|
||||
_bytesOfOctalCodes = key._bytesOfOctalCodes;
|
||||
_bytesOfBitMasks = key._bytesOfBitmasks;
|
||||
_bytesOfColor = key._bytesOfColor;
|
||||
|
||||
_totalBytesOfOctalCodes -= reduceBytesOfOctalCodes;
|
||||
_totalBytesOfBitMasks -= reduceBytesOfBitMasks;
|
||||
_totalBytesOfColor -= reduceBytesOfColor;
|
||||
|
||||
if (_debug) {
|
||||
printf("discardLevel() BEFORE _dirty=%s bytesInLevel=%d _compressedBytes=%d _bytesInUse=%d\n",
|
||||
|
@ -201,6 +226,7 @@ bool VoxelPacket::appendBitMask(unsigned char bitmask) {
|
|||
bool success = append(bitmask); // handles checking compression
|
||||
if (success) {
|
||||
_bytesOfBitMasks++;
|
||||
_totalBytesOfBitMasks++;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -221,6 +247,7 @@ bool VoxelPacket::appendColor(const nodeColor& color) {
|
|||
}
|
||||
if (success) {
|
||||
_bytesOfColor += BYTES_PER_COLOR;
|
||||
_totalBytesOfColor += BYTES_PER_COLOR;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
|
|
@ -113,6 +113,10 @@ public:
|
|||
|
||||
static uint64_t _checkCompressTime;
|
||||
static uint64_t _checkCompressCalls;
|
||||
|
||||
static uint64_t _totalBytesOfOctalCodes;
|
||||
static uint64_t _totalBytesOfBitMasks;
|
||||
static uint64_t _totalBytesOfColor;
|
||||
|
||||
private:
|
||||
/// appends raw bytes, might fail if byte would cause packet to be too large
|
||||
|
@ -137,10 +141,11 @@ private:
|
|||
bool _dirty;
|
||||
|
||||
// statistics...
|
||||
static uint64_t _bytesOfOctalCodes;
|
||||
static uint64_t _bytesOfBitMasks;
|
||||
static uint64_t _bytesOfColor;
|
||||
|
||||
int _bytesOfOctalCodes;
|
||||
int _bytesOfBitMasks;
|
||||
int _bytesOfColor;
|
||||
int _bytesOfOctalCodesCurrentSubTree;
|
||||
|
||||
static bool _debug;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue