Files

230 lines
6.7 KiB
C
Raw Permalink Normal View History

2013-08-02 13:12:24 -07:00
// Matt Wells, copyright Jul 2002
// . all disk accesses should use this global class to record their stats
// . this class can dump a gif graph to disk in the html directory with
// the filename "Stats.gif"
// . you may add stats to this class, but do not remove them as they may
// be necessary for Statsdb.
2016-03-08 22:14:30 +01:00
#ifndef GB_STATS_H
#define GB_STATS_H
2013-08-02 13:12:24 -07:00
#include "SafeBuf.h"
#include "UdpProtocol.h" // MAX_MSG_TYPES
class StatPoint {
public:
2014-11-10 14:45:11 -08:00
int32_t m_numBytes ;
2014-10-30 13:36:39 -06:00
int64_t m_startTime ;
int64_t m_endTime ;
2013-08-02 13:12:24 -07:00
int m_color ;
char m_type ;
};
#define MAX_POINTS 6000
#define MAX_WIDTH 6
2014-01-19 01:09:38 -08:00
//#define DY 1000 // pixels vertical
#define DY 500 // pixels vertical
2013-08-02 13:12:24 -07:00
#define DX 1000 // pixels across
2014-01-19 01:09:38 -08:00
#define DT (10*1000) // time window, 10 seconds
2013-08-02 13:12:24 -07:00
#define MAX_LINES (DY / (MAX_WIDTH+1)) // leave free pixel above each line
#define STAT_GENERIC 0
#define STAT_QUERY 1
#define MAX_BUCKETS 16
class Stats {
public:
// just clear our points array when we're born
Stats ( ) ;
// we take lower 3 bytes of "color" for the rgb color of this line/pt
2014-11-10 14:45:11 -08:00
void addStat_r ( int32_t numBytes ,
2014-10-30 13:36:39 -06:00
int64_t startTime ,
int64_t endTime ,
2014-11-10 14:45:11 -08:00
int32_t color = 0x00000000 , // black
2013-08-02 13:12:24 -07:00
char type = STAT_GENERIC,
char *fnName = NULL);
void printGraphInHtml ( SafeBuf &sb );
2013-08-02 13:12:24 -07:00
// store the points here
StatPoint m_pts [ MAX_POINTS ];
2014-11-10 14:45:11 -08:00
int32_t m_next;
2013-08-02 13:12:24 -07:00
// don't graph any points that start BEFORE this time because our
// sampling is not accurate because we had to throw points away
// due to the MAX_POINTS limit
2014-10-30 13:36:39 -06:00
//int64_t m_minWindowStartTime;
2013-08-02 13:12:24 -07:00
void addPoint ( StatPoint **points ,
2014-11-10 14:45:11 -08:00
int32_t *numPoints ,
2013-08-02 13:12:24 -07:00
StatPoint *p ) ;
//queries
2014-10-30 13:36:39 -06:00
void logAvgQueryTime(int64_t startTime);
2013-08-02 13:12:24 -07:00
void calcQueryStats();
void clearMsgStats();
2014-10-30 13:36:39 -06:00
int64_t m_startTime;
int64_t m_upTime;
int64_t m_lastQueryLogTime;
int64_t m_queryTimes;
2013-08-02 13:12:24 -07:00
float m_avgQueriesPerSec;
2014-11-10 14:45:11 -08:00
int32_t m_numQueries;
int32_t m_numSuccess;
int32_t m_numFails;
int32_t m_totalNumQueries;
int32_t m_totalNumSuccess;
int32_t m_totalNumFails;
2013-08-02 13:12:24 -07:00
float m_avgQueryTime;
float m_successRate;
2014-10-30 13:36:39 -06:00
//int64_t m_readSignals;
//int64_t m_writeSignals;
2013-08-02 13:12:24 -07:00
// set in BigFile.cpp
2014-11-10 14:45:11 -08:00
int32_t m_slowDiskReads;
2013-08-02 13:12:24 -07:00
// when we have to close a socket because too many are open.. count it
2014-11-10 14:45:11 -08:00
int32_t m_closedSockets;
2013-08-02 13:12:24 -07:00
time_t m_uptimeStart;
// Deduped stats
2014-11-10 14:45:11 -08:00
int32_t m_msg3aRecallCnt;
2013-08-02 13:12:24 -07:00
// when we have to re-requrest docid lists for each split, inc this one
2014-11-10 14:45:11 -08:00
int32_t m_msg3aSlowRecalls;
2013-08-02 13:12:24 -07:00
// when we just request more docids from the same tier
2014-11-10 14:45:11 -08:00
int32_t m_msg3aFastRecalls;
2013-08-02 13:12:24 -07:00
// how many resolutions did we get on each tier
//int32_t m_tierHits [MAX_TIERS];
//int64_t m_tierTimes[MAX_TIERS];
2013-08-02 13:12:24 -07:00
// how many searches did not get enough results?
2014-11-10 14:45:11 -08:00
int32_t m_tier2Misses;
2016-06-29 11:32:40 +02:00
2013-08-02 13:12:24 -07:00
// one count for each CR_* defined in Msg51.h
2014-11-10 14:45:11 -08:00
int32_t m_filterStats[30];
2016-06-29 11:32:40 +02:00
2014-11-10 14:45:11 -08:00
int32_t m_msg3aRecalls[6];
2013-08-02 13:12:24 -07:00
SafeBuf m_keyCols;
//int32_t m_numTermsVsTier[14][MAX_TIERS];
//int32_t m_termsVsTierExp[14][MAX_TIERS][7];
2013-08-02 13:12:24 -07:00
// use m_start so we know what msg stats to clear with memset
char m_start;
// and stats for how long to send a request or reply from
2013-08-02 13:12:24 -07:00
// start to finish. the first "2" is the niceness, 0 or 1, and
// the second "2" is 0 if sending a reply and 1 if sending a request.
2014-10-30 13:36:39 -06:00
int64_t m_msgTotalOfSendTimes [MAX_MSG_TYPES][2][2];
int64_t m_msgTotalSent [MAX_MSG_TYPES][2][2];
int64_t m_msgTotalSentByTime [MAX_MSG_TYPES][2][2][MAX_BUCKETS];
// how long we wait after receiving the request until handler is called
2014-10-30 13:36:39 -06:00
int64_t m_msgTotalOfQueuedTimes [MAX_MSG_TYPES][2];
int64_t m_msgTotalQueued [MAX_MSG_TYPES][2];
int64_t m_msgTotalQueuedByTime [MAX_MSG_TYPES][2][MAX_BUCKETS];
2013-08-02 13:12:24 -07:00
// msg stats, from UdpServer.cpp and UdpSlot.cpp. all times in
// milliseconds. the second index is the niceness, 0 or 1. Buckets
// are for breaking down times by the time range: 0-1ms, 2-3ms,
// 4-7ms, 8-15ms, ...
2014-10-30 13:36:39 -06:00
int64_t m_msgTotalOfHandlerTimes [MAX_MSG_TYPES][2];
int64_t m_msgTotalHandlersCalled [MAX_MSG_TYPES][2];
int64_t m_msgTotalHandlersByTime [MAX_MSG_TYPES][2][MAX_BUCKETS];
2013-08-02 13:12:24 -07:00
2014-11-10 14:45:11 -08:00
int32_t m_packetsIn [MAX_MSG_TYPES][2];
int32_t m_packetsOut [MAX_MSG_TYPES][2];
int32_t m_acksIn [MAX_MSG_TYPES][2];
int32_t m_acksOut [MAX_MSG_TYPES][2];
int32_t m_reroutes [MAX_MSG_TYPES][2];
int32_t m_errors [MAX_MSG_TYPES][2];
int32_t m_timeouts [MAX_MSG_TYPES][2]; // specific error
int32_t m_nomem [MAX_MSG_TYPES][2]; // specific error
int32_t m_dropped [MAX_MSG_TYPES][2]; // dropped dgram
int32_t m_cancelRead [MAX_MSG_TYPES][2]; // dropped dgram
2013-08-02 13:12:24 -07:00
2014-11-10 14:45:11 -08:00
int32_t m_parsingInconsistencies;
2013-08-02 13:12:24 -07:00
int32_t m_totalOverflows;
2013-08-02 13:12:24 -07:00
// used by msg39
2016-08-09 20:59:31 +02:00
//int32_t m_recomputeCacheMissess;
2013-08-02 13:12:24 -07:00
// if the msg3a advances to the next tier, of course, it will be
// a cache miss, so don't count those, they are justified
// recomputeCacheMisses
2016-08-09 20:59:31 +02:00
//int32_t m_icacheTierJumps;
2013-08-02 13:12:24 -07:00
2014-11-10 14:45:11 -08:00
int32_t m_compressedBytesIn;
int32_t m_uncompressedBytesIn;
2013-08-02 13:12:24 -07:00
// spider compression proxy stats set in Msg13.cpp
2014-10-30 13:36:39 -06:00
int64_t m_compressAllDocs;
int64_t m_compressAllBytesIn;
int64_t m_compressAllBytesOut;
2013-08-02 13:12:24 -07:00
2014-10-30 13:36:39 -06:00
int64_t m_compressMimeErrorDocs;
int64_t m_compressMimeErrorBytesIn;
int64_t m_compressMimeErrorBytesOut;
2013-08-02 13:12:24 -07:00
2014-10-30 13:36:39 -06:00
int64_t m_compressUnchangedDocs;
int64_t m_compressUnchangedBytesIn;
int64_t m_compressUnchangedBytesOut;
2013-08-02 13:12:24 -07:00
2014-10-30 13:36:39 -06:00
int64_t m_compressBadContentDocs;
int64_t m_compressBadContentBytesIn;
int64_t m_compressBadContentBytesOut;
2013-08-02 13:12:24 -07:00
2014-10-30 13:36:39 -06:00
int64_t m_compressBadLangDocs;
int64_t m_compressBadLangBytesIn;
int64_t m_compressBadLangBytesOut;
2013-08-02 13:12:24 -07:00
2014-10-30 13:36:39 -06:00
int64_t m_compressBadCharsetDocs;
int64_t m_compressBadCharsetBytesIn;
int64_t m_compressBadCharsetBytesOut;
2013-08-02 13:12:24 -07:00
2014-10-30 13:36:39 -06:00
int64_t m_compressBadCTypeDocs;
int64_t m_compressBadCTypeBytesIn;
int64_t m_compressBadCTypeBytesOut;
2013-08-02 13:12:24 -07:00
2014-10-30 13:36:39 -06:00
int64_t m_compressHasIframeDocs;
2016-08-09 20:59:54 +02:00
//int64_t m_compressHasIframeBytesIn;
//int64_t m_compressHasIframeBytesOut;
2013-08-02 13:12:24 -07:00
2014-10-30 13:36:39 -06:00
int64_t m_compressPlainLinkDocs;
int64_t m_compressPlainLinkBytesIn;
int64_t m_compressPlainLinkBytesOut;
2013-08-02 13:12:24 -07:00
2014-10-30 13:36:39 -06:00
int64_t m_compressEmptyLinkDocs;
int64_t m_compressEmptyLinkBytesIn;
int64_t m_compressEmptyLinkBytesOut;
2013-08-02 13:12:24 -07:00
2014-10-30 13:36:39 -06:00
int64_t m_compressFullPageDocs;
int64_t m_compressFullPageBytesIn;
int64_t m_compressFullPageBytesOut;
2013-08-02 13:12:24 -07:00
2014-10-30 13:36:39 -06:00
int64_t m_compressHasDateDocs;
int64_t m_compressHasDateBytesIn;
int64_t m_compressHasDateBytesOut;
2013-08-02 13:12:24 -07:00
2014-10-30 13:36:39 -06:00
int64_t m_compressRobotsTxtDocs;
int64_t m_compressRobotsTxtBytesIn;
int64_t m_compressRobotsTxtBytesOut;
2013-08-02 13:12:24 -07:00
2014-10-30 13:36:39 -06:00
int64_t m_compressUnknownTypeDocs;
int64_t m_compressUnknownTypeBytesIn;
int64_t m_compressUnknownTypeBytesOut;
2013-08-02 13:12:24 -07:00
// use m_end so we know what msg stats to clear with memset
char m_end;
//bool m_gotLock;
};
extern class Stats g_stats;
2016-03-08 22:14:30 +01:00
#endif // GB_STATS_H