Skip to content

Cache eval-plugin glue methods for the process lifetime, not per message#34

Closed
bigio wants to merge 1 commit into
apache:trunkfrom
bigio:speed_eval_glue_cache
Closed

Cache eval-plugin glue methods for the process lifetime, not per message#34
bigio wants to merge 1 commit into
apache:trunkfrom
bigio:speed_eval_glue_cache

Conversation

@bigio

@bigio bigio commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

PerMsgStatus::finish() undefined every register_plugin_eval_glue() generated wrapper sub (and any register_generated_rule_method() plugin subs) and cleared their tracking hash after every single message, even though this glue is 100% static per-config -- forcing a fresh eval() compile of every distinct eval-plugin function on every message instead of once per process, the same "compile once, reuse" pattern Check.pm already uses for its rule subs.
It also contradicted register_generated_rule_method()'s documented contract, which says these methods are destroyed at Mail::SpamAssassin::finish() (session end), not per-message.

Move the cleanup to Mail::SpamAssassin::finish(), alongside the existing finish_tests plugin-hook cleanup. Since that code runs outside the PerMsgStatus package, bare (non-fully-qualified) method names now need explicit qualification to avoid undefining the wrong symbol.

PerMsgStatus::finish() undefined every register_plugin_eval_glue()
generated wrapper sub (and any register_generated_rule_method() plugin
subs) and cleared their tracking hash after every single message, even
though this glue is 100% static per-config -- forcing a fresh eval()
compile of every distinct eval-plugin function on every message instead
of once per process, the same "compile once, reuse" pattern Check.pm
already uses for its rule subs.
It also contradicted register_generated_rule_method()'s
documented contract, which says these methods are destroyed at
Mail::SpamAssassin::finish() (session end), not per-message.

Move the cleanup to Mail::SpamAssassin::finish(), alongside the
existing finish_tests plugin-hook cleanup. Since that code runs
outside the PerMsgStatus package, bare (non-fully-qualified) method
names now need explicit qualification to avoid undefining the wrong
symbol.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@fkoyer

fkoyer commented Jul 22, 2026

Copy link
Copy Markdown

Good catch. +1

I think we could refactor the code so the glue functions aren't necessary at all. But that would be a separate PR. This PR is still needed to cleanup @TEMPORARY_METHODS that are registered by register_generated_rule_method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants