const gchar *start = NULL, *end = NULL;
guint max_hits = rspamd_regexp_get_maxhits (re);
guint64 id = rspamd_regexp_get_cache_id (re);
- gdouble t1, t2;
+ gdouble t1, t2, pr;
const gdouble slow_time = 0.1;
if (in == NULL) {
r = rt->results[id];
if (max_hits == 0 || r < max_hits) {
- t1 = rspamd_get_ticks ();
+ pr = rspamd_random_double_fast ();
+
+ if (pr > 0.9) {
+ t1 = rspamd_get_ticks ();
+ }
while (rspamd_regexp_search (re,
in,
rt->stat.regexp_matched += r;
}
- t2 = rspamd_get_ticks ();
+ if (pr > 0.9) {
+ t2 = rspamd_get_ticks ();
- if (t2 - t1 > slow_time) {
- msg_info_pool ("regexp '%16s' took %.2f seconds to execute",
- rspamd_regexp_get_pattern (re), t2 - t1);
+ if (t2 - t1 > slow_time) {
+ msg_info_pool ("regexp '%16s' took %.2f seconds to execute",
+ rspamd_regexp_get_pattern (re), t2 - t1);
+ }
}
}
struct symbols_cache *cache,
struct cache_item *item,
struct cache_savepoint *checkpoint,
- gdouble *total_diff);
+ gdouble *total_diff,
+ gdouble pr);
static gboolean rspamd_symbols_cache_check_deps (struct rspamd_task *task,
struct symbols_cache *cache,
struct cache_item *item,
struct cache_savepoint *checkpoint;
struct symbols_cache *cache;
gint i, remain = 0;
+ gdouble pr = rspamd_random_double_fast ();
checkpoint = task->checkpoint;
cache = task->cfg->cache;
}
rspamd_symbols_cache_check_symbol (task, cache, it, checkpoint,
- NULL);
+ NULL, pr);
}
}
}
struct symbols_cache *cache,
struct cache_item *item,
struct cache_savepoint *checkpoint,
- gdouble *total_diff)
+ gdouble *total_diff,
+ gdouble pr)
{
guint pending_before, pending_after;
double t1, t2;
}
if (check) {
- t1 = rspamd_get_ticks ();
+ if (pr > 0.9) {
+ t1 = rspamd_get_ticks ();
+ }
+
pending_before = rspamd_session_events_pending (task->s);
/* Watch for events appeared */
rspamd_session_watch_start (task->s, rspamd_symbols_cache_watcher_cb,
msg_debug_task ("execute %s, %d", item->symbol, item->id);
item->func (task, item->user_data);
- t2 = rspamd_get_ticks ();
- diff = (t2 - t1) * 1e6;
+ if (pr > 0.9) {
+ t2 = rspamd_get_ticks ();
+ diff = (t2 - t1) * 1e6;
- if (total_diff) {
- *total_diff += diff;
- }
+ if (total_diff) {
+ *total_diff += diff;
+ }
- if (diff > slow_diff_limit) {
- msg_info_task ("slow rule: %s: %d ms", item->symbol,
- (gint)(diff / 1000.));
- }
+ if (diff > slow_diff_limit) {
+ msg_info_task ("slow rule: %s: %d ms", item->symbol,
+ (gint)(diff / 1000.));
+ }
- rspamd_set_counter (item, diff);
+ rspamd_set_counter (item, diff);
+ }
rspamd_session_watch_stop (task->s);
pending_after = rspamd_session_events_pending (task->s);
struct cache_dependency *dep;
guint i;
gboolean ret = TRUE;
+ gdouble pr = rspamd_random_double_fast ();
if (item->deps != NULL && item->deps->len > 0) {
for (i = 0; i < item->deps->len; i ++) {
else if (!rspamd_symbols_cache_check_symbol (task, cache,
dep->item,
checkpoint,
- NULL)) {
+ NULL,
+ pr)) {
/* Now started, but has events pending */
ret = FALSE;
msg_debug_task ("started check of %d symbol as dep for "
gboolean all_done;
const gdouble max_microseconds = 3e5;
guint start_events_pending;
+ gdouble pr = rspamd_random_double_fast ();
g_assert (cache != NULL);
if (!isset (checkpoint->processed_bits, item->id * 2)) {
rspamd_symbols_cache_check_symbol (task, cache, item,
- checkpoint, &total_microseconds);
+ checkpoint, &total_microseconds, pr);
}
}
checkpoint->pass = RSPAMD_CACHE_PASS_WAIT_PREFILTERS;
}
rspamd_symbols_cache_check_symbol (task, cache, item,
- checkpoint, &total_microseconds);
+ checkpoint, &total_microseconds, pr);
}
if (total_microseconds > max_microseconds) {
}
rspamd_symbols_cache_check_symbol (task, cache, item,
- checkpoint, &total_microseconds);
+ checkpoint, &total_microseconds, pr);
}
if (total_microseconds > max_microseconds) {
if (!isset (checkpoint->processed_bits, item->id * 2)) {
rspamd_symbols_cache_check_symbol (task, cache, item,
- checkpoint, &total_microseconds);
+ checkpoint, &total_microseconds, pr);
}
}
checkpoint->pass = RSPAMD_CACHE_PASS_WAIT_POSTFILTERS;