]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Feature] Disable periodic recompile timer for file cache backend
authorVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 13 Jan 2026 14:19:53 +0000 (14:19 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Tue, 13 Jan 2026 14:19:53 +0000 (14:19 +0000)
The periodic recompile timer (default 60s) is only useful for shared
backends (Redis, HTTP, Lua) where another rspamd instance might have
compiled new hyperscan databases.

For file backend, recompilation is already triggered by:
- Config reload (forks new hs_helper process)
- Explicit RECOMPILE command (sent on map updates)

This eliminates unnecessary periodic checks for file-based deployments.

src/hs_helper.c

index f2eb772ffe9c81ed2eccdaefa2634ef96ec391f6..f0517c753604f0f7da9458eb88e0c28ad8229d87 100644 (file)
@@ -615,7 +615,11 @@ rspamd_rs_send_single_notification(struct rspamd_hs_helper_single_compile_cbdata
        msg_debug_hyperscan("sent hyperscan loaded notification");
 
        g_free(cbd);
-       ev_timer_again(ctx->event_loop, &ctx->recompile_timer);
+
+       /* Only restart periodic timer for non-file backends */
+       if (ctx->cache_backend != HS_CACHE_BACKEND_FILE) {
+               ev_timer_again(ctx->event_loop, &ctx->recompile_timer);
+       }
 }
 
 static void
@@ -1257,11 +1261,23 @@ start_hs_helper(struct rspamd_worker *worker)
        rspamd_control_worker_add_cmd_handler(worker, RSPAMD_CONTROL_WORKERS_SPAWNED,
                                                                                  rspamd_hs_helper_workers_spawned, ctx);
 
-       ctx->recompile_timer.data = worker;
-       tim = rspamd_time_jitter(ctx->recompile_time, 0);
-       msg_debug_hyperscan("setting up recompile timer for %.1f seconds", tim);
-       ev_timer_init(&ctx->recompile_timer, rspamd_hs_helper_timer, tim, 0.0);
-       ev_timer_start(ctx->event_loop, &ctx->recompile_timer);
+       /*
+        * Periodic recompile timer is only useful for non-file backends (Redis, HTTP, Lua)
+        * where another instance might have compiled new databases.
+        * For file backend, recompilation is triggered by:
+        * - Config reload (new process)
+        * - Explicit RECOMPILE command (map updates)
+        */
+       if (ctx->cache_backend != HS_CACHE_BACKEND_FILE) {
+               ctx->recompile_timer.data = worker;
+               tim = rspamd_time_jitter(ctx->recompile_time, 0);
+               msg_debug_hyperscan("setting up recompile timer for %.1f seconds", tim);
+               ev_timer_init(&ctx->recompile_timer, rspamd_hs_helper_timer, tim, 0.0);
+               ev_timer_start(ctx->event_loop, &ctx->recompile_timer);
+       }
+       else {
+               msg_debug_hyperscan("skipping periodic recompile timer for file backend");
+       }
 
        msg_debug_hyperscan("hs_helper starting event loop");
        ev_loop(ctx->event_loop, 0);