Merge remote-tracking branch 'origin/topic/bernhard/log-threads-configureable-heartbeat' into topic/bernhard/input-threads

Conflicts:
	src/threading/Manager.h
This commit is contained in:
Bernhard Amann 2012-03-30 09:24:46 -07:00
commit e789724935
6 changed files with 18 additions and 5 deletions

View file

@ -1484,6 +1484,14 @@ export {
}; };
} # end export } # end export
module Threading;
export {
## The heart beat interval used by the threading framework.
## Changing this should usually not be neccessary and will break several tests.
const heart_beat_interval = 1.0 secs &redef;
}
module GLOBAL; module GLOBAL;
## An NTP message. ## An NTP message.

View file

@ -12,3 +12,4 @@ const NFS3::return_data: bool;
const NFS3::return_data_max: count; const NFS3::return_data_max: count;
const NFS3::return_data_first_only: bool; const NFS3::return_data_first_only: bool;
const Threading::heart_beat_interval: interval;

View file

@ -89,7 +89,7 @@ double Benchmark::CurrTime() {
// read the entire file and send appropriate thingies back to InputMgr // read the entire file and send appropriate thingies back to InputMgr
bool Benchmark::DoUpdate() { bool Benchmark::DoUpdate() {
int linestosend = num_lines * threading::Manager::HEART_BEAT_INTERVAL; int linestosend = num_lines * heart_beat_interval;
for ( int i = 0; i < linestosend; i++ ) { for ( int i = 0; i < linestosend; i++ ) {
Value** field = new Value*[num_fields]; Value** field = new Value*[num_fields];
for (unsigned int j = 0; j < num_fields; j++ ) { for (unsigned int j = 0; j < num_fields; j++ ) {
@ -117,7 +117,7 @@ bool Benchmark::DoUpdate() {
diff = CurrTime() - heartbeatstarttime; diff = CurrTime() - heartbeatstarttime;
//printf("%d %f\n", i, diff); //printf("%d %f\n", i, diff);
//} while ( diff < i/threading::Manager::HEART_BEAT_INTERVAL*(num_lines + (num_lines * timedspread) ) ); //} while ( diff < i/threading::Manager::HEART_BEAT_INTERVAL*(num_lines + (num_lines * timedspread) ) );
} while ( diff/threading::Manager::HEART_BEAT_INTERVAL < i/(linestosend + (linestosend * timedspread) ) ); } while ( diff/heart_beat_interval < i/(linestosend + (linestosend * timedspread) ) );
//} while ( diff < 0.8); //} while ( diff < 0.8);
} }

View file

@ -46,6 +46,7 @@ private:
int stopspreadat; int stopspreadat;
double heartbeatstarttime; double heartbeatstarttime;
double timedspread; double timedspread;
double heart_beat_interval;
string RandomString(const int len); string RandomString(const int len);

View file

@ -1,5 +1,6 @@
#include "Manager.h" #include "Manager.h"
#include "NetVar.h"
using namespace threading; using namespace threading;
@ -11,6 +12,9 @@ Manager::Manager()
next_beat = 0; next_beat = 0;
terminating = false; terminating = false;
idle = true; idle = true;
heart_beat_interval = double(BifConst::Threading::heart_beat_interval);
DBG_LOG(DBG_THREADING, "Heart beat interval set to %f", heart_beat_interval);
} }
Manager::~Manager() Manager::~Manager()
@ -74,7 +78,7 @@ void Manager::GetFds(int* read, int* write, int* except)
double Manager::NextTimestamp(double* network_time) double Manager::NextTimestamp(double* network_time)
{ {
if ( ::network_time && ! next_beat ) if ( ::network_time && ! next_beat )
next_beat = ::network_time + HEART_BEAT_INTERVAL; next_beat = ::network_time + heart_beat_interval;
// fprintf(stderr, "N %.6f %.6f did_process=%d next_next=%.6f\n", ::network_time, timer_mgr->Time(), (int)did_process, next_beat); // fprintf(stderr, "N %.6f %.6f did_process=%d next_next=%.6f\n", ::network_time, timer_mgr->Time(), (int)did_process, next_beat);

View file

@ -124,9 +124,8 @@ protected:
*/ */
virtual const char* Tag() { return "threading::Manager"; } virtual const char* Tag() { return "threading::Manager"; }
static const int HEART_BEAT_INTERVAL = 10;
private: private:
int heart_beat_interval;
typedef std::list<BasicThread*> all_thread_list; typedef std::list<BasicThread*> all_thread_list;
all_thread_list all_threads; all_thread_list all_threads;