Merge pull request #1258 from ZappoMan/remove_noise

removing more noise and dont sleep if we failed to lock the node
This commit is contained in:
Stephen Birarda 2013-11-13 17:00:06 -08:00
commit 950f486e2e
6 changed files with 24 additions and 27 deletions

View file

@ -35,8 +35,6 @@ VoxelNodeData::VoxelNodeData(Node* owningNode) :
_lastVoxelPacketLength = 0;
_duplicatePacketCount = 0;
resetVoxelPacket();
qDebug("VoxelNodeData::VoxelNodeData() this=%p owningNode=%p\n", this, owningNode);
}
void VoxelNodeData::initializeVoxelSendThread(VoxelServer* voxelServer) {
@ -44,10 +42,6 @@ void VoxelNodeData::initializeVoxelSendThread(VoxelServer* voxelServer) {
QUuid nodeUUID = getOwningNode()->getUUID();
_voxelSendThread = new VoxelSendThread(nodeUUID, voxelServer);
_voxelSendThread->initialize(true);
qDebug("VoxelNodeData::initializeVoxelSendThread() this=%p owningNode=%p _voxelSendThread=%p\n",
this, getOwningNode(), _voxelSendThread);
qDebug() << "VoxelNodeData::initializeVoxelSendThread() nodeUUID=" << nodeUUID << "\n";
}
bool VoxelNodeData::packetIsDuplicate() const {

View file

@ -60,19 +60,25 @@ bool VoxelPersistThread::process() {
VoxelNode::getSetChildAtIndexTime(), VoxelNode::getSetChildAtIndexCalls(), usecPerSet);
_initialLoadComplete = true;
_lastSave = usecTimestampNow(); // we just loaded, no need to save again
}
uint64_t MSECS_TO_USECS = 1000;
usleep(_persistInterval * MSECS_TO_USECS);
// check the dirty bit and persist here...
if (_tree->isDirty()) {
qDebug("saving voxels to file %s...\n",_filename);
_tree->writeToSVOFile(_filename);
_tree->clearDirtyBit(); // tree is clean after saving
qDebug("DONE saving voxels to file...\n");
}
if (isStillRunning()) {
uint64_t MSECS_TO_USECS = 1000;
uint64_t USECS_TO_SLEEP = 100 * MSECS_TO_USECS; // every 100ms
usleep(USECS_TO_SLEEP);
if ((usecTimestampNow() - _lastSave) > (_persistInterval * MSECS_TO_USECS)) {
qDebug("checking if voxels are dirty.\n");
// check the dirty bit and persist here...
if (_tree->isDirty()) {
_lastSave = usecTimestampNow();
qDebug("saving voxels to file %s...\n",_filename);
_tree->writeToSVOFile(_filename);
_tree->clearDirtyBit(); // tree is clean after saving
qDebug("DONE saving voxels to file...\n");
}
}
}
return isStillRunning(); // keep running till they terminate us
}

View file

@ -38,6 +38,7 @@ private:
time_t _loadCompleted;
uint64_t _loadTimeUSecs;
uint64_t _lastSave;
};
#endif // __voxel_server__VoxelPersistThread__

View file

@ -25,6 +25,7 @@ VoxelSendThread::VoxelSendThread(const QUuid& nodeUUID, VoxelServer* myServer) :
bool VoxelSendThread::process() {
uint64_t start = usecTimestampNow();
bool gotLock = false;
// don't do any send processing until the initial load of the voxels is complete...
if (_myServer->isInitialLoadComplete()) {
@ -33,6 +34,7 @@ bool VoxelSendThread::process() {
if (node) {
// make sure the node list doesn't kill our node while we're using it
if (node->trylock()) {
gotLock = true;
VoxelNodeData* nodeData = NULL;
nodeData = (VoxelNodeData*) node->getLinkedData();
@ -49,9 +51,6 @@ bool VoxelSendThread::process() {
}
node->unlock(); // we're done with this node for now.
} else {
qDebug("VoxelSendThread::process() failed to lock node...isStillRunning()=%s\n",
debug::valueOf(isStillRunning()));
}
}
} else {
@ -60,8 +59,8 @@ bool VoxelSendThread::process() {
}
}
// Only sleep if we're still running...
if (isStillRunning()) {
// Only sleep if we're still running and we got the lock last time we tried, otherwise try to get the lock asap
if (isStillRunning() && gotLock) {
// dynamically sleep until we need to fire off the next set of voxels
int elapsed = (usecTimestampNow() - start);
int usecToSleep = VOXEL_SEND_INTERVAL_USECS - elapsed;

View file

@ -47,9 +47,6 @@ const char* VOXELS_PERSIST_FILE = "/etc/highfidelity/voxel-server/resources/voxe
void attachVoxelNodeDataToNode(Node* newNode) {
if (newNode->getLinkedData() == NULL) {
VoxelNodeData* voxelNodeData = new VoxelNodeData(newNode);
QUuid nodeUUID = newNode->getUUID();
qDebug("attachVoxelNodeDataToNode() newNode=%p voxelNodeData=%p\n", newNode, voxelNodeData);
qDebug() << "attachVoxelNodeDataToNode() node UUID:" << nodeUUID << "\n";
newNode->setLinkedData(voxelNodeData);
}
}

View file

@ -42,7 +42,7 @@ VoxelQuery::VoxelQuery(Node* owningNode) :
}
VoxelQuery::~VoxelQuery() {
qDebug("VoxelQuery::~VoxelQuery()\n");
// nothing to do
}
int VoxelQuery::getBroadcastData(unsigned char* destinationBuffer) {