added additional debugging of VoxelNode memory usage, shrunk size of VoxelNode by better alignment

This commit is contained in:
ZappoMan 2013-10-14 15:10:56 -07:00
parent f0fc973db1
commit 924053f2ec
4 changed files with 37 additions and 21 deletions

View file

@ -2993,13 +2993,19 @@ void Application::displayStats() {
drawtext(10, statsVerticalOffset + 230, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); drawtext(10, statsVerticalOffset + 230, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
voxelStats.str(""); voxelStats.str("");
voxelStats << "Voxels Memory Nodes: " << VoxelNode::getVoxelMemoryUsage() / 1000000.f << "MB " voxelStats <<
"Voxels Memory Nodes: " << VoxelNode::getVoxelMemoryUsage() / 1000000.f << "MB "
"Octcodes: " << VoxelNode::getOctcodeMemoryUsage() / 1000000.f << "MB "
"Geometry RAM: " << _voxels.getVoxelMemoryUsageRAM() / 1000000.f << "MB " << "Geometry RAM: " << _voxels.getVoxelMemoryUsageRAM() / 1000000.f << "MB " <<
"VBO: " << _voxels.getVoxelMemoryUsageVBO() / 1000000.f << "MB "; "VBO: " << _voxels.getVoxelMemoryUsageVBO() / 1000000.f << "MB ";
if (_voxels.hasVoxelMemoryUsageGPU()) { if (_voxels.hasVoxelMemoryUsageGPU()) {
voxelStats << "GPU: " << _voxels.getVoxelMemoryUsageGPU() / 1000000.f << "MB "; voxelStats << "GPU: " << _voxels.getVoxelMemoryUsageGPU() / 1000000.f << "MB ";
} }
// Some debugging for memory usage of VoxelNodes
//voxelStats << "VoxelNode size: " << sizeof(VoxelNode) << " bytes ";
//voxelStats << "AABox size: " << sizeof(AABox) << " bytes ";
drawtext(10, statsVerticalOffset + 250, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str()); drawtext(10, statsVerticalOffset + 250, 0.10f, 0, 1.0, 0, (char *)voxelStats.str().c_str());
voxelStats.str(""); voxelStats.str("");

View file

@ -137,6 +137,7 @@ int VoxelServer::civetwebRequestHandler(struct mg_connection* connection) {
mg_printf(connection, "%s", "Your Voxel Server is running.\r\n"); mg_printf(connection, "%s", "Your Voxel Server is running.\r\n");
mg_printf(connection, "%s", "Current Statistics\r\n"); mg_printf(connection, "%s", "Current Statistics\r\n");
mg_printf(connection, "Voxel Node Memory Usage: %f MB\r\n", VoxelNode::getVoxelMemoryUsage() / 1000000.f); mg_printf(connection, "Voxel Node Memory Usage: %f MB\r\n", VoxelNode::getVoxelMemoryUsage() / 1000000.f);
mg_printf(connection, "Octcode Memory Usage: %f MB\r\n", VoxelNode::getOctcodeMemoryUsage() / 1000000.f);
VoxelTree* theTree = VoxelServer::GetInstance()->getTree(); VoxelTree* theTree = VoxelServer::GetInstance()->getTree();
unsigned long nodeCount = theTree->rootNode->getSubTreeNodeCount(); unsigned long nodeCount = theTree->rootNode->getSubTreeNodeCount();

View file

@ -22,6 +22,7 @@
#include "VoxelTree.h" #include "VoxelTree.h"
uint64_t VoxelNode::_voxelMemoryUsage = 0; uint64_t VoxelNode::_voxelMemoryUsage = 0;
uint64_t VoxelNode::_octcodeMemoryUsage = 0;
VoxelNode::VoxelNode() { VoxelNode::VoxelNode() {
unsigned char* rootCode = new unsigned char[1]; unsigned char* rootCode = new unsigned char[1];
@ -60,14 +61,14 @@ void VoxelNode::init(unsigned char * octalCode) {
markWithChangedTime(); markWithChangedTime();
_voxelMemoryUsage += sizeof(VoxelNode); _voxelMemoryUsage += sizeof(VoxelNode);
_voxelMemoryUsage += bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(_octalCode)); _octcodeMemoryUsage += bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(_octalCode));
} }
VoxelNode::~VoxelNode() { VoxelNode::~VoxelNode() {
notifyDeleteHooks(); notifyDeleteHooks();
_voxelMemoryUsage -= sizeof(VoxelNode); _voxelMemoryUsage -= sizeof(VoxelNode);
_voxelMemoryUsage -= bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(_octalCode)); _octcodeMemoryUsage -= bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(_octalCode));
delete[] _octalCode; delete[] _octalCode;

View file

@ -128,6 +128,7 @@ public:
unsigned long getSubTreeLeafNodeCount() const { return _subtreeLeafNodeCount; } unsigned long getSubTreeLeafNodeCount() const { return _subtreeLeafNodeCount; }
static uint64_t getVoxelMemoryUsage() { return _voxelMemoryUsage; } static uint64_t getVoxelMemoryUsage() { return _voxelMemoryUsage; }
static uint64_t getOctcodeMemoryUsage() { return _octcodeMemoryUsage; }
private: private:
void calculateAABox(); void calculateAABox();
@ -135,28 +136,35 @@ private:
void notifyDeleteHooks(); void notifyDeleteHooks();
void notifyUpdateHooks(); void notifyUpdateHooks();
nodeColor _trueColor; VoxelNode* _children[8]; /// Client and server, pointers to child nodes, 64 bytes
AABox _box; /// Client and server, axis aligned box for bounds of this voxel, 48 bytes
unsigned char* _octalCode; /// Client and server, pointer to octal code for this node, 8 bytes
uint64_t _lastChanged; /// Client and server, timestamp this node was last changed, 8 bytes
unsigned long _subtreeNodeCount; /// Client and server, nodes below this node, 8 bytes
unsigned long _subtreeLeafNodeCount; /// Client and server, leaves below this node, 8 bytes
glBufferIndex _glBufferIndex; /// Client only, vbo index for this voxel if being rendered, 8 bytes
VoxelSystem* _voxelSystem; /// Client only, pointer to VoxelSystem rendering this voxel, 8 bytes
float _density; /// Client and server, If leaf: density = 1, if internal node: 0-1 density of voxels inside, 4 bytes
int _childCount; /// Client and server, current child nodes set to non-null in _children, 4 bytes
nodeColor _trueColor; /// Client and server, true color of this voxel, 4 bytes
#ifndef NO_FALSE_COLOR // !NO_FALSE_COLOR means, does have false color #ifndef NO_FALSE_COLOR // !NO_FALSE_COLOR means, does have false color
nodeColor _currentColor; nodeColor _currentColor; /// Client only, false color of this voxel, 4 bytes
bool _falseColored; bool _falseColored; /// Client only, is this voxel false colored, 1 bytes
#endif #endif
glBufferIndex _glBufferIndex;
VoxelSystem* _voxelSystem; bool _isDirty; /// Client only, has this voxel changed since being rendered, 1 byte
bool _isDirty; bool _shouldRender; /// Client only, should this voxel render at this time, 1 byte
uint64_t _lastChanged; uint16_t _sourceID; /// Client only, stores node id of voxel server that sent his voxel, 2 bytes
bool _shouldRender;
AABox _box;
unsigned char* _octalCode;
VoxelNode* _children[8];
int _childCount;
unsigned long _subtreeNodeCount;
unsigned long _subtreeLeafNodeCount;
float _density; // If leaf: density = 1, if internal node: 0-1 density of voxels inside
uint16_t _sourceID;
static std::vector<VoxelNodeDeleteHook*> _deleteHooks; static std::vector<VoxelNodeDeleteHook*> _deleteHooks;
static std::vector<VoxelNodeUpdateHook*> _updateHooks; static std::vector<VoxelNodeUpdateHook*> _updateHooks;
static uint64_t _voxelMemoryUsage; static uint64_t _voxelMemoryUsage;
static uint64_t _octcodeMemoryUsage;
}; };
#endif /* defined(__hifi__VoxelNode__) */ #endif /* defined(__hifi__VoxelNode__) */