zeek.bif: Implement table_pattern_matcher_stats() bif for introspection

Provide a script accessible way to introspect the DFA stats that can be
leveraged to gather runtime statistics of the underlying DFA. This
re-uses the existing MatcherStats used by ``get_matcher_stats()``.
This commit is contained in:
Arne Welzel 2023-11-08 20:30:04 +01:00
parent 3f240e0f0a
commit e39f280e3d
6 changed files with 116 additions and 0 deletions

View file

@ -20,6 +20,7 @@
#include "zeek/Attr.h"
#include "zeek/CompHash.h"
#include "zeek/Conn.h"
#include "zeek/DFA.h"
#include "zeek/Desc.h"
#include "zeek/Dict.h"
#include "zeek/Expr.h"
@ -1442,6 +1443,13 @@ public:
VectorValPtr Lookup(const StringValPtr& s);
void GetStats(detail::DFA_State_Cache_Stats* stats) const {
if ( matcher && matcher->DFA() )
matcher->DFA()->Cache()->GetStats(stats);
else
*stats = {0};
};
private:
void Build();
@ -2030,6 +2038,13 @@ VectorValPtr TableVal::LookupPattern(const StringValPtr& s) {
return pattern_matcher->Lookup(s);
}
void TableVal::GetPatternMatcherStats(detail::DFA_State_Cache_Stats* stats) const {
if ( ! pattern_matcher )
reporter->InternalError("GetPatternMatcherStats called on wrong table type");
return pattern_matcher->GetStats(stats);
}
bool TableVal::UpdateTimestamp(Val* index) {
TableEntryVal* v;