]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Remove vectorized hyperscan mode: it has been always broken
authorVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 20 Oct 2022 11:50:39 +0000 (12:50 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 20 Oct 2022 20:21:39 +0000 (21:21 +0100)
src/libserver/cfg_rcl.c
src/libserver/re_cache.c

index 8619fcc5e965340b4b79d510072a81e0c11c7107..7ae4bcbdcbb777d0ad1515b653dd43810e2368eb 100644 (file)
@@ -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,
index a09d04e149c1a3bb20f57a4abe895697c3a53d69..4dadc14e3ff4505327feb4d86a65943dc0b18c65 100644 (file)
@@ -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: "