mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 15:48:19 +00:00
Adding thread statistics to prof.log
This commit is contained in:
parent
4f0fc571ef
commit
1058e11ffb
3 changed files with 52 additions and 1 deletions
15
src/Stats.cc
15
src/Stats.cc
|
@ -9,7 +9,7 @@
|
||||||
#include "ConnCompressor.h"
|
#include "ConnCompressor.h"
|
||||||
#include "DNS_Mgr.h"
|
#include "DNS_Mgr.h"
|
||||||
#include "Trigger.h"
|
#include "Trigger.h"
|
||||||
|
#include "threading/Manager.h"
|
||||||
|
|
||||||
int killed_by_inactivity = 0;
|
int killed_by_inactivity = 0;
|
||||||
|
|
||||||
|
@ -217,6 +217,19 @@ void ProfileLogger::Log()
|
||||||
current_timers[i]));
|
current_timers[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file->Write(fmt("%0.6f Threads: current=%d\n", network_time, thread_mgr->NumThreads()));
|
||||||
|
|
||||||
|
const threading::Manager::msg_stats_list& thread_stats = thread_mgr->GetMsgThreadStats();
|
||||||
|
for ( threading::Manager::msg_stats_list::const_iterator i = thread_stats.begin();
|
||||||
|
i != thread_stats.end(); ++i )
|
||||||
|
{
|
||||||
|
threading::MsgThread::Stats s = i->second;
|
||||||
|
file->Write(fmt(" %20s in=%" PRIu64 " out=%" PRIu64 " pending=%" PRIu64 "/%" PRIu64 "\n",
|
||||||
|
i->first.c_str(),
|
||||||
|
s.sent_in, s.sent_out,
|
||||||
|
s.pending_in, s.pending_out));
|
||||||
|
}
|
||||||
|
|
||||||
// Script-level state.
|
// Script-level state.
|
||||||
unsigned int size, mem = 0;
|
unsigned int size, mem = 0;
|
||||||
PDict(ID)* globals = global_scope()->Vars();
|
PDict(ID)* globals = global_scope()->Vars();
|
||||||
|
|
|
@ -101,4 +101,21 @@ void Manager::Process()
|
||||||
next_beat = network_time + HEART_BEAT_INTERVAL;
|
next_beat = network_time + HEART_BEAT_INTERVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const threading::Manager::msg_stats_list& threading::Manager::GetMsgThreadStats()
|
||||||
|
{
|
||||||
|
stats.clear();
|
||||||
|
|
||||||
|
for ( msg_thread_list::iterator i = msg_threads.begin(); i != msg_threads.end(); i++ )
|
||||||
|
{
|
||||||
|
MsgThread* t = *i;
|
||||||
|
|
||||||
|
MsgThread::Stats s;
|
||||||
|
t->GetStats(&s);
|
||||||
|
|
||||||
|
stats.push_back(std::make_pair(t->Name(),s));
|
||||||
|
}
|
||||||
|
|
||||||
|
return stats;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,25 @@ public:
|
||||||
*/
|
*/
|
||||||
void Terminate();
|
void Terminate();
|
||||||
|
|
||||||
|
typedef std::list<std::pair<string, MsgThread::Stats> > msg_stats_list;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns statistics from all current MsgThread instances.
|
||||||
|
*
|
||||||
|
* @return A list of statistics, with one entry for each MsgThread.
|
||||||
|
* Each entry is a tuple of thread name and statistics. The list
|
||||||
|
* reference remains valid until the next call to this method (or
|
||||||
|
* termination of the manager).
|
||||||
|
*/
|
||||||
|
const msg_stats_list& GetMsgThreadStats();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of currently active threads. This counts all
|
||||||
|
* threads that are not yet joined, includingt any potentially in
|
||||||
|
* Terminating() state.
|
||||||
|
*/
|
||||||
|
int NumThreads() const { return all_threads.size(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class BasicThread;
|
friend class BasicThread;
|
||||||
friend class MsgThread;
|
friend class MsgThread;
|
||||||
|
@ -96,6 +115,8 @@ private:
|
||||||
|
|
||||||
bool did_process; // True if the last Process() found some work to do.
|
bool did_process; // True if the last Process() found some work to do.
|
||||||
double next_beat; // Timestamp when the next heartbeat will be sent.
|
double next_beat; // Timestamp when the next heartbeat will be sent.
|
||||||
|
|
||||||
|
msg_stats_list stats;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue