aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-10-27 11:34:23 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-10-27 11:34:23 +0100
commita8bbbc899c238d06f89a1abe773a967c08051081 (patch)
tree7790f4a8992371c1d017a14cbab809cc9b879ae8 /src
parentc54eeafdd296585c1bd5100a58a36e3f32d03e78 (diff)
downloadrspamd-a8bbbc899c238d06f89a1abe773a967c08051081.tar.gz
rspamd-a8bbbc899c238d06f89a1abe773a967c08051081.zip
[Fix] Fix ticks processing
Diffstat (limited to 'src')
-rw-r--r--src/libserver/re_cache.c4
-rw-r--r--src/libserver/symbols_cache.c27
-rw-r--r--src/libutil/util.c21
3 files changed, 34 insertions, 18 deletions
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c
index 5bb153872..760b2a440 100644
--- a/src/libserver/re_cache.c
+++ b/src/libserver/re_cache.c
@@ -488,7 +488,7 @@ rspamd_re_cache_process_pcre (struct rspamd_re_runtime *rt,
guint max_hits = rspamd_regexp_get_maxhits (re);
guint64 id = rspamd_regexp_get_cache_id (re);
gdouble t1, t2, pr;
- const gdouble slow_time = 0.1;
+ const gdouble slow_time = 1e8;
if (in == NULL) {
return rt->results[id];
@@ -540,7 +540,7 @@ rspamd_re_cache_process_pcre (struct rspamd_re_runtime *rt,
t2 = rspamd_get_ticks (TRUE);
if (t2 - t1 > slow_time) {
- msg_info_task ("regexp '%16s' took %.2f seconds to execute",
+ msg_info_task ("regexp '%16s' took %.0f ticks to execute",
rspamd_regexp_get_pattern (re), t2 - t1);
}
}
diff --git a/src/libserver/symbols_cache.c b/src/libserver/symbols_cache.c
index ece7895da..7a9e05d27 100644
--- a/src/libserver/symbols_cache.c
+++ b/src/libserver/symbols_cache.c
@@ -1613,10 +1613,10 @@ rspamd_symbols_cache_process_symbols (struct rspamd_task * task,
struct cache_item *item = NULL;
struct cache_savepoint *checkpoint;
gint i;
- gdouble total_microseconds = 0;
+ gdouble total_ticks = 0;
gboolean all_done;
gint saved_priority;
- const gdouble max_microseconds = 3e5;
+ const gdouble max_ticks = 3e8;
guint start_events_pending;
g_assert (cache != NULL);
@@ -1669,7 +1669,7 @@ rspamd_symbols_cache_process_symbols (struct rspamd_task * task,
}
rspamd_symbols_cache_check_symbol (task, cache, item,
- checkpoint, &total_microseconds);
+ checkpoint, &total_ticks);
}
}
@@ -1746,10 +1746,10 @@ rspamd_symbols_cache_process_symbols (struct rspamd_task * task,
}
rspamd_symbols_cache_check_symbol (task, cache, item,
- checkpoint, &total_microseconds);
+ checkpoint, &total_ticks);
}
- if (total_microseconds > max_microseconds) {
+ if (total_ticks > max_ticks) {
/* Maybe we should stop and check pending events? */
if (rspamd_session_events_pending (task->s) > start_events_pending) {
/* Add some timeout event to avoid too long waiting */
@@ -1769,8 +1769,8 @@ rspamd_symbols_cache_process_symbols (struct rspamd_task * task,
(rspamd_mempool_destruct_t)event_del, ev);
#endif
msg_info_task ("trying to check async events after spending "
- "%d microseconds processing symbols",
- (gint)total_microseconds);
+ "%.0f ticks processing symbols",
+ total_ticks);
return TRUE;
}
@@ -1792,16 +1792,16 @@ rspamd_symbols_cache_process_symbols (struct rspamd_task * task,
}
rspamd_symbols_cache_check_symbol (task, cache, item,
- checkpoint, &total_microseconds);
+ checkpoint, &total_ticks);
}
- if (total_microseconds > max_microseconds) {
+ if (total_ticks > max_ticks) {
/* Maybe we should stop and check pending events? */
if (rspamd_session_events_pending (task->s) >
start_events_pending) {
msg_debug_task ("trying to check async events after spending "
- "%d microseconds processing symbols",
- (gint)total_microseconds);
+ "%.0f microseconds processing symbols",
+ total_ticks);
return TRUE;
}
}
@@ -1842,8 +1842,9 @@ rspamd_symbols_cache_process_symbols (struct rspamd_task * task,
return TRUE;
}
}
+
rspamd_symbols_cache_check_symbol (task, cache, item,
- checkpoint, &total_microseconds);
+ checkpoint, &total_ticks);
}
}
checkpoint->pass = RSPAMD_CACHE_PASS_WAIT_POSTFILTERS;
@@ -1901,7 +1902,7 @@ rspamd_symbols_cache_process_symbols (struct rspamd_task * task,
}
}
rspamd_symbols_cache_check_symbol (task, cache, item,
- checkpoint, &total_microseconds);
+ checkpoint, &total_ticks);
}
}
checkpoint->pass = RSPAMD_CACHE_PASS_WAIT_IDEMPOTENT;
diff --git a/src/libutil/util.c b/src/libutil/util.c
index f022b4689..7cb2ff81a 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -1792,14 +1792,29 @@ rspamd_get_ticks (gboolean rdtsc_ok)
# endif
clock_gettime (clk_id, &ts);
- res = (double)ts.tv_sec + ts.tv_nsec / 1000000000.;
+ if (rdtsc_ok) {
+ res = (double) ts.tv_sec + ts.tv_nsec / 1000000000.;
+ }
+ else {
+ res = (double) ts.tv_sec * 1e9 + ts.tv_nsec;
+ }
# elif defined(__APPLE__)
- res = mach_absolute_time () / 1000000000.;
+ if (rdtsc_ok) {
+ res = mach_absolute_time ();
+ }
+ else {
+ res = mach_absolute_time () / 1000000000.;
+ }
#else
struct timeval tv;
(void)gettimeofday (&tv, NULL);
- res = (double)tv.tv_sec + tv.tv_usec / 1000000.;
+ if (rdtsc_ok) {
+ res = (double) ts.tv_sec * 1e9 + tv.tv_usec * 1e3;
+ }
+ else {
+ res = (double)tv.tv_sec + tv.tv_usec / 1000000.;
+ }
#endif
return res;