commit 005c9fe: [Minor] Remove vectorized hyperscan mode: it has been always broken

Vsevolod Stakhov vsevolod at rspamd.com
Thu Oct 20 20:28:03 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-10-20 12:50:39 +0100
URL: https://github.com/rspamd/rspamd/commit/005c9fece0912113bf5a8577b08da7ea7946cfab (HEAD -> master)

[Minor] Remove vectorized hyperscan mode: it has been always broken

---
 src/libserver/cfg_rcl.c  |  2 +-
 src/libserver/re_cache.c | 54 ++++++++++--------------------------------------
 2 files changed, 12 insertions(+), 44 deletions(-)

diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index 8619fcc5e..7ae4bcbdc 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -1962,7 +1962,7 @@ rspamd_rcl_config_init (struct rspamd_config *cfg, GHashTable *skip_sections)
 				rspamd_rcl_parse_struct_boolean,
 				G_STRUCT_OFFSET (struct rspamd_config, vectorized_hyperscan),
 				0,
-				"Use hyperscan in vectorized mode (experimental)");
+				"Use hyperscan in vectorized mode (obsoleted, do not use)");
 		rspamd_rcl_add_default_handler (sub,
 				"cores_dir",
 				rspamd_rcl_parse_struct_string,
diff --git a/src/libserver/re_cache.c b/src/libserver/re_cache.c
index a09d04e14..4dadc14e3 100644
--- a/src/libserver/re_cache.c
+++ b/src/libserver/re_cache.c
@@ -127,7 +127,6 @@ struct rspamd_re_cache {
 #ifdef WITH_HYPERSCAN
 	enum rspamd_hyperscan_status hyperscan_loaded;
 	gboolean disable_hyperscan;
-	gboolean vectorized_hyperscan;
 	hs_platform_info_t plt;
 #endif
 };
@@ -482,7 +481,6 @@ rspamd_re_cache_init (struct rspamd_re_cache *cache, struct rspamd_config *cfg)
 	rspamd_fstring_t *features = rspamd_fstring_new ();
 
 	cache->disable_hyperscan = cfg->disable_hyperscan;
-	cache->vectorized_hyperscan = cfg->vectorized_hyperscan;
 
 	g_assert (hs_populate_platform (&cache->plt) == HS_SUCCESS);
 
@@ -803,37 +801,17 @@ rspamd_re_cache_process_regexp_data (struct rspamd_re_runtime *rt,
 		g_assert (re_class->hs_db != NULL);
 
 		/* Go through hyperscan API */
-		if (!rt->cache->vectorized_hyperscan) {
-			for (i = 0; i < count; i++) {
-				cbdata.ins = &in[i];
-				cbdata.re = re;
-				cbdata.rt = rt;
-				cbdata.lens = &lens[i];
-				cbdata.count = 1;
-				cbdata.task = task;
-
-				if ((hs_scan (re_class->hs_db, in[i], lens[i], 0,
-						re_class->hs_scratch,
-						rspamd_re_cache_hyperscan_cb, &cbdata)) != HS_SUCCESS) {
-					ret = 0;
-				}
-				else {
-					ret = rt->results[re_id];
-					*processed_hyperscan = TRUE;
-				}
-			}
-		}
-		else {
-			cbdata.ins = in;
+		for (i = 0; i < count; i++) {
+			cbdata.ins = &in[i];
 			cbdata.re = re;
 			cbdata.rt = rt;
-			cbdata.lens = lens;
+			cbdata.lens = &lens[i];
 			cbdata.count = 1;
 			cbdata.task = task;
 
-			if ((hs_scan_vector (re_class->hs_db, (const char **)in, lens, count, 0,
-					re_class->hs_scratch,
-					rspamd_re_cache_hyperscan_cb, &cbdata)) != HS_SUCCESS) {
+			if ((hs_scan (re_class->hs_db, in[i], lens[i], 0,
+				re_class->hs_scratch,
+				rspamd_re_cache_hyperscan_cb, &cbdata)) != HS_SUCCESS) {
 				ret = 0;
 			}
 			else {
@@ -1793,7 +1771,7 @@ rspamd_re_cache_is_finite (struct rspamd_re_cache *cache,
 
 		if (hs_compile (pat,
 				flags | HS_FLAG_PREFILTER,
-				cache->vectorized_hyperscan ? HS_MODE_VECTORED : HS_MODE_BLOCK,
+				HS_MODE_BLOCK,
 				&cache->plt,
 				&test_db,
 				&hs_errors) != HS_SUCCESS) {
@@ -2027,7 +2005,7 @@ rspamd_re_cache_compile_timer_cb (EV_P_ ev_timer *w, int revents )
 
 		if (hs_compile (pat,
 				hs_flags[i],
-				cache->vectorized_hyperscan ? HS_MODE_VECTORED : HS_MODE_BLOCK,
+				HS_MODE_BLOCK,
 				&cache->plt,
 				&test_db,
 				&hs_errors) != HS_SUCCESS) {
@@ -2082,7 +2060,7 @@ rspamd_re_cache_compile_timer_cb (EV_P_ ev_timer *w, int revents )
 				hs_ids,
 				hs_exts,
 				n,
-				cache->vectorized_hyperscan ? HS_MODE_VECTORED : HS_MODE_BLOCK,
+				HS_MODE_BLOCK,
 				&cache->plt,
 				&test_db,
 				&hs_errors) != HS_SUCCESS) {
@@ -2130,13 +2108,8 @@ rspamd_re_cache_compile_timer_cb (EV_P_ ev_timer *w, int revents )
 				hs_serialized, serialized_len);
 		crc = rspamd_cryptobox_fast_hash_final (&crc_st);
 
-		if (cache->vectorized_hyperscan) {
-			iov[0].iov_base = (void *) rspamd_hs_magic_vector;
-		}
-		else {
-			iov[0].iov_base = (void *) rspamd_hs_magic;
-		}
 
+		iov[0].iov_base = (void *) rspamd_hs_magic;
 		iov[0].iov_len = RSPAMD_HS_MAGIC_LEN;
 		iov[1].iov_base = &cache->plt;
 		iov[1].iov_len = sizeof (cache->plt);
@@ -2356,12 +2329,7 @@ rspamd_re_cache_is_valid_hyperscan_file (struct rspamd_re_cache *cache,
 				return FALSE;
 			}
 
-			if (cache->vectorized_hyperscan) {
-				mb = rspamd_hs_magic_vector;
-			}
-			else {
-				mb = rspamd_hs_magic;
-			}
+			mb = rspamd_hs_magic;
 
 			if (memcmp (magicbuf, mb, sizeof (magicbuf)) != 0) {
 				msg_err_re_cache ("cannot open hyperscan cache file %s: "


More information about the Commits mailing list