From 7e5e5b53360d95d7d3cddc18c4811ce8a4c8cba1 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 16 Jul 2019 12:13:24 +0100 Subject: [PATCH] [Rework] Eliminate virtual scan time as it is useless --- conf/logging.inc | 2 +- src/libserver/cfg_utils.c | 4 ++-- src/libserver/protocol.c | 3 --- src/libserver/task.c | 6 ++---- src/libserver/task.h | 1 - src/lua/lua_task.c | 5 +++-- src/plugins/lua/clickhouse.lua | 12 +++++------- 7 files changed, 13 insertions(+), 20 deletions(-) diff --git a/conf/logging.inc b/conf/logging.inc index 2511d968f..f0104342a 100644 --- a/conf/logging.inc +++ b/conf/logging.inc @@ -4,7 +4,7 @@ level = "info"; log_format =<,$if_qid{ qid: <$>,}$if_ip{ ip: $,}$if_user{ user: $,}$if_smtp_from{ from: <$>,} (default: $is_spam ($action): [$scores] [$symbols_scores_params]), -len: $len, time: $time_real real, $time_virtual virtual, dns req: $dns_req, +len: $len, time: $time_real, dns req: $dns_req, digest: <$digest>$if_smtp_rcpts{, rcpts: <$>}$if_mime_rcpts{, mime_rcpts: <$>}$if_filename{, file: $}$if_forced_action{, forced: $} EOD diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index 055a66930..f65883c3e 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -193,8 +193,8 @@ rspamd_config_new (enum rspamd_config_init_flags flags) /* Default log line */ cfg->log_format_str = "id: <$mid>,$if_qid{ qid: <$>,}$if_ip{ ip: $,}" "$if_user{ user: $,}$if_smtp_from{ from: <$>,} (default: $is_spam " - "($action): [$scores] [$symbols_scores_params]), len: $len, time: $time_real real," - " $time_virtual virtual, dns req: $dns_req, digest: <$digest>" + "($action): [$scores] [$symbols_scores_params]), len: $len, time: $time_real, " + "dns req: $dns_req, digest: <$digest>" "$if_smtp_rcpts{ rcpts: <$>, }$if_mime_rcpt{ mime_rcpt: <$>, }"; /* Allow non-mime input by default */ cfg->allow_raw_input = TRUE; diff --git a/src/libserver/protocol.c b/src/libserver/protocol.c index de2d5aa55..77c256971 100644 --- a/src/libserver/protocol.c +++ b/src/libserver/protocol.c @@ -1314,9 +1314,6 @@ rspamd_protocol_write_ucl (struct rspamd_task *task, ucl_object_insert_key (top, ucl_object_fromdouble (task->time_real_finish - task->task_timestamp), "time_real", 0, false); - ucl_object_insert_key (top, - ucl_object_fromdouble (task->time_virtual_finish - task->time_virtual), - "time_virtual", 0, false); } if (flags & RSPAMD_PROTOCOL_DKIM) { diff --git a/src/libserver/task.c b/src/libserver/task.c index 54f2510a2..778ca4ef5 100644 --- a/src/libserver/task.c +++ b/src/libserver/task.c @@ -100,7 +100,6 @@ rspamd_task_new (struct rspamd_worker *worker, struct rspamd_config *cfg, } new_task->time_real_finish = NAN; - new_task->time_virtual_finish = NAN; if (pool == NULL) { new_task->task_pool = @@ -1372,8 +1371,8 @@ rspamd_task_log_variable (struct rspamd_task *task, var.len = strlen (var.begin); break; case RSPAMD_LOG_TIME_VIRTUAL: - var.begin = rspamd_log_check_time (task->time_virtual, - task->time_virtual_finish, + var.begin = rspamd_log_check_time (task->task_timestamp, + task->time_real_finish, task->cfg->clock_res); var.len = strlen (var.begin); break; @@ -1693,7 +1692,6 @@ rspamd_task_set_finish_time (struct rspamd_task *task) { if (isnan (task->time_real_finish)) { task->time_real_finish = ev_time (); - task->time_virtual_finish = ev_now (task->event_loop); return TRUE; } diff --git a/src/libserver/task.h b/src/libserver/task.h index 67f33488a..5a6c85a04 100644 --- a/src/libserver/task.h +++ b/src/libserver/task.h @@ -188,7 +188,6 @@ struct rspamd_task { rspamd_mempool_t *task_pool; /**< memory pool for task */ double time_virtual; double time_real_finish; - double time_virtual_finish; ev_tstamp task_timestamp; gboolean (*fin_callback) (struct rspamd_task *task, void *arg); diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index 9fe61e07d..41ee110e3 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -4656,8 +4656,9 @@ lua_task_get_scan_time (lua_State *L) } rspamd_task_set_finish_time (task); - lua_pushnumber (L, task->time_real_finish - task->task_timestamp); - lua_pushnumber (L, task->time_virtual_finish - task->time_virtual); + gdouble diff = task->time_real_finish - task->task_timestamp; + lua_pushnumber (L, diff); + lua_pushnumber (L, diff); if (!set) { /* Reset to nan to allow further calcs in rspamd_task_set_finish_time */ diff --git a/src/plugins/lua/clickhouse.lua b/src/plugins/lua/clickhouse.lua index 83e9b714d..8762de239 100644 --- a/src/plugins/lua/clickhouse.lua +++ b/src/plugins/lua/clickhouse.lua @@ -132,7 +132,7 @@ CREATE TABLE rspamd `Symbols.Scores` Array(Float32) COMMENT 'Symbol score', `Symbols.Options` Array(String) COMMENT 'Symbol options (comma separated list)', ScanTimeReal UInt32 COMMENT 'Request time in milliseconds', - ScanTimeVirtual UInt32, + ScanTimeVirtual UInt32 COMMENT 'Deprecated do not use', AuthUser String COMMENT 'Username for authenticated SMTP client', SettingsId LowCardinality(String) COMMENT 'ID for the settings profile', Digest FixedString(32) COMMENT '[Deprecated]', @@ -269,7 +269,6 @@ local function clickhouse_main_row(res) 'MimeRecipients', 'MessageId', 'ScanTimeReal', - 'ScanTimeVirtual', -- 1.9.3 + 'CustomAction', -- 2.0 + @@ -622,12 +621,12 @@ local function clickhouse_collect(task) subject = lua_util.maybe_obfuscate_string(task:get_subject() or '', settings, 'subject') end - local scan_real,scan_virtual = task:get_scan_time() - scan_real,scan_virtual = math.floor(scan_real * 1000), math.floor(scan_virtual * 1000) + local scan_real = task:get_scan_time() + scan_real = math.floor(scan_real * 1000) if scan_real < 0 then rspamd_logger.messagex(task, - 'clock skew detected for message: %s ms real scan time (reset to 0), %s virtual scan time', - scan_real, scan_virtual) + 'clock skew detected for message: %s ms real scan time (reset to 0)', + scan_real) scan_real = 0 end @@ -677,7 +676,6 @@ local function clickhouse_collect(task) mime_recipients, message_id, scan_real, - scan_virtual, custom_action, auth_user, settings_id -- 2.39.5