[OPTIMIZE]optimize hyperscan callback performance
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
#include "maat_utils.h"
|
#include "maat_utils.h"
|
||||||
#include "../../bool_matcher/bool_matcher.h"
|
#include "../../bool_matcher/bool_matcher.h"
|
||||||
|
|
||||||
#define MAX_HIT_PATTERN_NUM 512
|
#define MAX_HIT_PATTERN_NUM 1024
|
||||||
|
|
||||||
pid_t hs_gettid()
|
pid_t hs_gettid()
|
||||||
{
|
{
|
||||||
@@ -585,11 +585,6 @@ static int matched_event_cb(unsigned int id, unsigned long long from,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// duplicate pattern_id
|
|
||||||
if (utarray_find(matched_pat->pattern_ids, &pattern_id, compare_pattern_id)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct pattern_attribute pat_attr = matched_pat->ref_hs_attr[id];
|
struct pattern_attribute pat_attr = matched_pat->ref_hs_attr[id];
|
||||||
switch (pat_attr.match_mode) {
|
switch (pat_attr.match_mode) {
|
||||||
@@ -640,7 +635,6 @@ static int matched_event_cb(unsigned int id, unsigned long long from,
|
|||||||
|
|
||||||
if (1 == ret) {
|
if (1 == ret) {
|
||||||
utarray_push_back(matched_pat->pattern_ids, &pattern_id);
|
utarray_push_back(matched_pat->pattern_ids, &pattern_id);
|
||||||
utarray_sort(matched_pat->pattern_ids, compare_pattern_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -834,8 +828,9 @@ int adapter_hs_scan_stream(void *hs_stream, const char *data, size_t data_len,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long pattern_ids[n_pattern_id];
|
utarray_sort(stream->matched_pat->pattern_ids, compare_pattern_id);
|
||||||
|
|
||||||
|
unsigned long long pattern_ids[n_pattern_id];
|
||||||
for (size_t i = 0; i < n_pattern_id; i++) {
|
for (size_t i = 0; i < n_pattern_id; i++) {
|
||||||
pattern_ids[i] = *(unsigned long long *)utarray_eltptr(stream->matched_pat->pattern_ids, i);
|
pattern_ids[i] = *(unsigned long long *)utarray_eltptr(stream->matched_pat->pattern_ids, i);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#include "maat_utils.h"
|
#include "maat_utils.h"
|
||||||
#include "../../bool_matcher/bool_matcher.h"
|
#include "../../bool_matcher/bool_matcher.h"
|
||||||
|
|
||||||
#define MAX_HIT_PATTERN_NUM 512
|
#define MAX_HIT_PATTERN_NUM 1024
|
||||||
|
|
||||||
pid_t rs_gettid()
|
pid_t rs_gettid()
|
||||||
{
|
{
|
||||||
@@ -431,11 +431,6 @@ static int matched_event_cb(unsigned int id, int pos_offset, int from, int to,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// duplicate pattern_id
|
|
||||||
if (utarray_find(matched_pat->pattern_ids, &pattern_id, compare_pattern_id)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
struct pattern_attribute pat_attr = matched_pat->ref_rs_attr[id];
|
struct pattern_attribute pat_attr = matched_pat->ref_rs_attr[id];
|
||||||
|
|
||||||
@@ -487,7 +482,6 @@ static int matched_event_cb(unsigned int id, int pos_offset, int from, int to,
|
|||||||
|
|
||||||
if (1 == ret) {
|
if (1 == ret) {
|
||||||
utarray_push_back(matched_pat->pattern_ids, &pattern_id);
|
utarray_push_back(matched_pat->pattern_ids, &pattern_id);
|
||||||
utarray_sort(matched_pat->pattern_ids, compare_pattern_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -609,8 +603,9 @@ int adapter_rs_scan_stream(void *rs_stream, const char *data, size_t data_len,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long long pattern_ids[n_pattern_id];
|
utarray_sort(matched_pat->pattern_ids, compare_pattern_id);
|
||||||
|
|
||||||
|
unsigned long long pattern_ids[n_pattern_id];
|
||||||
for (size_t i = 0; i < n_pattern_id; i++) {
|
for (size_t i = 0; i < n_pattern_id; i++) {
|
||||||
pattern_ids[i] = *(unsigned long long *)utarray_eltptr(matched_pat->pattern_ids, i);
|
pattern_ids[i] = *(unsigned long long *)utarray_eltptr(matched_pat->pattern_ids, i);
|
||||||
}
|
}
|
||||||
@@ -678,6 +673,8 @@ int adapter_rs_scan(void *rs_instance, int thread_id, const char *data, size_t d
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
utarray_sort(matched_pat->pattern_ids, compare_pattern_id);
|
||||||
|
|
||||||
unsigned long long pattern_ids[n_pattern_id];
|
unsigned long long pattern_ids[n_pattern_id];
|
||||||
for (size_t i = 0; i < n_pattern_id; i++) {
|
for (size_t i = 0; i < n_pattern_id; i++) {
|
||||||
pattern_ids[i] = *(unsigned long long *)utarray_eltptr(matched_pat->pattern_ids, i);
|
pattern_ids[i] = *(unsigned long long *)utarray_eltptr(matched_pat->pattern_ids, i);
|
||||||
|
|||||||
Reference in New Issue
Block a user