From: Vsevolod Stakhov Date: Mon, 5 Jan 2026 15:21:45 +0000 (+0000) Subject: [Minor] Add clear logging for multipattern compilation states X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab091e7428c254695eeffee9d58b3f7290df2456;p=thirdparty%2Frspamd.git [Minor] Add clear logging for multipattern compilation states - Log when ACISM fallback trie is built - Log when hyperscan cache hit/miss occurs - Log when hot-swap to hyperscan completes - Remove misleading "start compiling" message from url.c --- diff --git a/src/libserver/url.c b/src/libserver/url.c index ebd8e5903a..9054b8982b 100644 --- a/src/libserver/url.c +++ b/src/libserver/url.c @@ -586,11 +586,6 @@ void rspamd_url_init(const char *tld_file) } } - if (url_scanner->matchers_full && url_scanner->matchers_full->len > 1000) { - msg_info("start compiling of %d TLD suffixes; it might take a long time", - url_scanner->matchers_full->len); - } - if (!rspamd_multipattern_compile(url_scanner->search_trie_strict, mp_compile_flags, &err)) { msg_err("cannot compile url matcher static patterns, fatal error: %e", err); abort(); @@ -608,7 +603,7 @@ void rspamd_url_init(const char *tld_file) if (tld_file != NULL) { if (ret) { - msg_info("initialized %ud url match suffixes from '%s'", + msg_info("loaded %ud TLD suffixes from '%s'", url_scanner->matchers_full->len - url_scanner->matchers_strict->len, tld_file); } diff --git a/src/libutil/multipattern.c b/src/libutil/multipattern.c index 7d7cfe5212..91f0968a72 100644 --- a/src/libutil/multipattern.c +++ b/src/libutil/multipattern.c @@ -686,6 +686,8 @@ rspamd_multipattern_compile(struct rspamd_multipattern *mp, int flags, GError ** mp->state = RSPAMD_MP_STATE_INIT; mp->compiled = TRUE; + msg_info("built ACISM fallback trie for %ud TLD patterns", mp->cnt); + /* Try to load from cache first */ if (!(flags & RSPAMD_MULTIPATTERN_COMPILE_NO_FS) && rspamd_multipattern_try_load_hs(mp, hash)) { @@ -694,10 +696,14 @@ rspamd_multipattern_compile(struct rspamd_multipattern *mp, int flags, GError ** rspamd_hyperscan_free(mp->hs_db, true); mp->hs_db = NULL; mp->state = RSPAMD_MP_STATE_FALLBACK; + msg_warn("hyperscan cache loaded but scratch allocation failed, " + "using ACISM fallback for %ud patterns", + mp->cnt); g_clear_error(err); } else { mp->state = RSPAMD_MP_STATE_COMPILED; + msg_info("loaded hyperscan database from cache for %ud patterns", mp->cnt); } return TRUE; } @@ -705,12 +711,17 @@ rspamd_multipattern_compile(struct rspamd_multipattern *mp, int flags, GError ** /* Cache miss: async compile only for TLD-only patterns */ if (all_tld && !(flags & RSPAMD_MULTIPATTERN_COMPILE_NO_FS)) { mp->state = RSPAMD_MP_STATE_COMPILING; + msg_info("hyperscan cache miss for %ud TLD patterns, using ACISM fallback " + "until async compilation completes", + mp->cnt); return TRUE; } /* Mixed patterns or NO_FS flag - sync compile */ if (!rspamd_multipattern_compile_hs_sync(mp, hash, flags, err)) { /* HS failed but ACISM fallback is ready for TLD patterns */ + msg_warn("hyperscan compilation failed, using ACISM fallback for %ud patterns", + mp->cnt); g_clear_error(err); } return TRUE; @@ -1142,6 +1153,7 @@ rspamd_multipattern_set_hs_db(struct rspamd_multipattern *mp, void *hs_db) } mp->state = RSPAMD_MP_STATE_COMPILED; + msg_info("hot-swapped to hyperscan database for %ud patterns", mp->cnt); return TRUE; #else (void) hs_db;