Merge pull request #2252 from jolavillette/ConfigFilesSavePeriod

Save configuration files every 1 hour instead of every 5 seconds
This commit is contained in:
csoler 2021-01-30 19:56:46 +01:00 committed by GitHub
commit 38c0603f6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,7 +40,6 @@
#include "retroshare/rsevents.h" #include "retroshare/rsevents.h"
#include "services/rseventsservice.h" #include "services/rseventsservice.h"
/******************* /*******************
#define TICK_DEBUG 1 #define TICK_DEBUG 1
*******************/ *******************/
@ -110,14 +109,15 @@ RsServer::RsServer() :
mStatusSrv = NULL; mStatusSrv = NULL;
mGxsTunnels = NULL; mGxsTunnels = NULL;
/* timers */
mLastts = getCurrentTS(); mLastts = getCurrentTS();
mTickInterval = maxTickInterval ; mTickInterval = maxTickInterval ;
mAvgRunDuration = 0; mAvgRunDuration = 0;
mLastRunDuration = 0; mLastRunDuration = 0;
mCycle1 = 0; mCycle1 = mLastts;
mCycle2 = 0; mCycle2 = mLastts;
mCycle3 = 0; mCycle3 = mLastts;
mCycle4 = 0; mCycle4 = mLastts;
/* caches (that need ticking) */ /* caches (that need ticking) */
@ -136,10 +136,10 @@ RsServer::~RsServer()
void RsServer::threadTick() void RsServer::threadTick()
{ {
#ifdef TICK_DEBUG #ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG ticking interval "<< mTickInterval << std::endl; RsDbg() << "TICK_DEBUG ticking interval " << std::dec << (int) (1000 * mTickInterval) << " ms";
#endif #endif
// we try to tick at a regular interval which depends on the load // we try to tick at a regular interval depending on the load
// if there is time left, we sleep // if there is time left, we sleep
double timeToSleep = mTickInterval - mAvgRunDuration; double timeToSleep = mTickInterval - mAvgRunDuration;
@ -148,7 +148,7 @@ void RsServer::threadTick()
timeToSleep = 0.050; timeToSleep = 0.050;
#ifdef TICK_DEBUG #ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG will sleep " << (int) (1000 * timeToSleep) << " ms" << std::endl; RsDbg() << "TICK_DEBUG will sleep " << std::dec << (int) (1000 * timeToSleep) << " ms";
#endif #endif
rstime::rs_usleep(timeToSleep * 1000000); rstime::rs_usleep(timeToSleep * 1000000);
@ -156,24 +156,24 @@ void RsServer::threadTick()
mLastts = ts; mLastts = ts;
// stuff we do always // stuff we do always
// tick the core // tick the core
#ifdef TICK_DEBUG #ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG ticking server" << std::endl; RsDbg() << "TICK_DEBUG ticking RS core";
#endif #endif
lockRsCore(); lockRsCore();
int moreToTick = pqih->tick(); int moreToTick = pqih->tick();
unlockRsCore(); unlockRsCore();
// tick the managers // tick the managers
#ifdef TICK_DEBUG #ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG ticking mPeerMgr" << std::endl; RsDbg() << "TICK_DEBUG ticking mPeerMgr";
#endif #endif
mPeerMgr->tick(); mPeerMgr->tick();
#ifdef TICK_DEBUG #ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG ticking mLinkMgr" << std::endl; RsDbg() << "TICK_DEBUG ticking mLinkMgr";
#endif #endif
mLinkMgr->tick(); mLinkMgr->tick();
#ifdef TICK_DEBUG #ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG ticking mNetMgr" << std::endl; RsDbg() << "TICK_DEBUG ticking mNetMgr";
#endif #endif
mNetMgr->tick(); mNetMgr->tick();
@ -182,11 +182,16 @@ void RsServer::threadTick()
if (ts - mCycle1 > 1) if (ts - mCycle1 > 1)
{ {
#ifdef TICK_DEBUG #ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG every second" << std::endl; RsDbg() << "TICK_DEBUG every second";
#endif #endif
// slow services // slow services
if (rsPlugins) if (rsPlugins)
{
#ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG ticking slow tick plugins";
#endif
rsPlugins->slowTickPlugins((rstime_t)ts); rsPlugins->slowTickPlugins((rstime_t)ts);
}
// UDP keepalive // UDP keepalive
// tou_tick_stunkeepalive(); // tou_tick_stunkeepalive();
// other stuff to tick // other stuff to tick
@ -198,10 +203,8 @@ void RsServer::threadTick()
if (ts - mCycle2 > 5) if (ts - mCycle2 > 5)
{ {
#ifdef TICK_DEBUG #ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG every 5 seconds" << std::endl; RsDbg() << "TICK_DEBUG every 5 seconds";
#endif #endif
// save stuff
mConfigMgr->tick();
mCycle2 = ts; mCycle2 = ts;
} }
@ -209,7 +212,7 @@ void RsServer::threadTick()
if (ts - mCycle3 > 60) if (ts - mCycle3 > 60)
{ {
#ifdef TICK_DEBUG #ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG every 60 seconds" << std::endl; RsDbg() << "TICK_DEBUG every 60 seconds";
#endif #endif
// force saving FileTransferStatus TODO // force saving FileTransferStatus TODO
// ftserver->saveFileTransferStatus(); // ftserver->saveFileTransferStatus();
@ -222,8 +225,13 @@ void RsServer::threadTick()
if (ts - mCycle4 > 3600) if (ts - mCycle4 > 3600)
{ {
#ifdef TICK_DEBUG #ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG every hour" << std::endl; RsDbg() << "TICK_DEBUG every hour";
#endif #endif
// save configuration files
#ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG ticking mConfigMgr";
#endif
mConfigMgr->tick();
mCycle4 = ts; mCycle4 = ts;
} }
@ -237,22 +245,22 @@ void RsServer::threadTick()
mAvgRunDuration = maxTickInterval; mAvgRunDuration = maxTickInterval;
#ifdef TICK_DEBUG #ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG new mLastRunDuration " << mLastRunDuration << " mAvgRunDuration " << mAvgRunDuration << std::endl; RsDbg() << "TICK_DEBUG mLastRunDuration " << std::dec << (int) (1000 * mLastRunDuration) << " ms, mAvgRunDuration " << (int) (1000 * mAvgRunDuration) << " ms";
if (mLastRunDuration > WARN_BIG_CYCLE_TIME) if (mLastRunDuration > WARN_BIG_CYCLE_TIME)
RsDbg() << "TICK_DEBUG excessively long cycle time " << mLastRunDuration << std::endl; RsDbg() << "TICK_DEBUG excessively long cycle time " << std::dec << (int) (1000 * mLastRunDuration) << " ms";
#endif #endif
// if the core has returned that there is more to tick we decrease the ticking interval, else we increse it // if the core has returned that there is more to tick we decrease the ticking interval, else we increase it
// this should be studied closer as I dont think that the core ever returns 1 // TODO: this should be investigated as it seems that the core never returns 1
#ifdef TICK_DEBUG #ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG moreToTick " << moreToTick << std::endl; RsDbg() << "TICK_DEBUG moreToTick " << moreToTick;
#endif #endif
if (moreToTick == 1) if (moreToTick == 1)
mTickInterval = 0.9 * mTickInterval; mTickInterval = 0.9 * mTickInterval;
else else
mTickInterval = 1.1 * mTickInterval; mTickInterval = 1.1 * mTickInterval;
#ifdef TICK_DEBUG #ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG new tick interval " << mTickInterval << std::endl; RsDbg() << "TICK_DEBUG new tick interval " << std::dec << (int) (1000 * mTickInterval) << " ms";
#endif #endif
// keep the tick interval target within allowed limits // keep the tick interval target within allowed limits
@ -261,7 +269,7 @@ void RsServer::threadTick()
else if (mTickInterval > maxTickInterval) else if (mTickInterval > maxTickInterval)
mTickInterval = maxTickInterval; mTickInterval = maxTickInterval;
#ifdef TICK_DEBUG #ifdef TICK_DEBUG
RsDbg() << "TICK_DEBUG new tick interval after limiter " << mTickInterval << std::endl; RsDbg() << "TICK_DEBUG new tick interval after limiter " << std::dec << (int) (1000 * mTickInterval) << " ms";
#endif #endif
} }