Skip to content

perf: preload configured authen modules in the hypnotoad master - #53

Merged
xcompass merged 2 commits into
ubcfrom
fix/preload-authen-modules
Sep 14, 2026
Merged

xcompass merged 2 commits into
ubcfrom
fix/preload-authen-modules

Conversation

@xcompass

@xcompass xcompass commented Sep 12, 2026

Copy link
Copy Markdown
Member

Summary

Since the 2.20 merge, the SAML2 authentication module is no longer loaded at startup: the custom Mojolicious::Plugin::Saml2 was retired in favour of upstream WeBWorK::Authen::Saml2, which the dispatcher now loads with runtime_use inside each hypnotoad worker on its first request. Net::SAML2 and its dependency tree (Moose, XML::LibXML, XML::Sig, LWP, ...) therefore end up as private memory in every worker instead of copy-on-write pages shared from the master, and each recycled worker pays for it again.

This PR preloads every module configured in $authen{user_module}, $authen{admin_module} and $authen{proctor_module} in startup, before hypnotoad forks. A small helper reads the configured list without mutating it (WeBWorK::Authen::class shifts entries off the array as they are tried). Load failures are logged as warnings rather than being fatal; the dispatcher still raises the real error if a broken module is actually used.

Test plan

  • Helper list handling unit-tested locally against string, array, legacy hash, undef and empty entries
  • New code formatted per .perltidyrc
  • CI image build succeeds
  • Deploy to staging; startup log shows one Preloaded authentication module ... line per configured module
  • SAML2 login and bypass login still work on staging
  • Per-worker private memory and pod working set drop compared with v2.20.3

Since the 2.20 merge the SAML2 authentication module is no longer loaded
at startup (the custom Mojolicious::Plugin::Saml2 was retired in favour of
upstream WeBWorK::Authen::Saml2). The dispatcher loads it with runtime_use
inside each worker on its first request, so Net::SAML2 and its dependency
tree (Moose, XML::LibXML, XML::Sig, LWP, ...) are private memory in every
one of the 25 workers instead of copy-on-write pages shared from the
master. With accepts: 100 each recycled worker pays it again. This is the
main structural change behind the web pods roughly doubling their memory
between v2.18.14 and v2.20.x.

Preload every module configured in $authen{user_module},
$authen{admin_module} and $authen{proctor_module} in startup, before
hypnotoad forks. Failures are logged rather than fatal; the dispatcher
raises the real error if a module is actually used.
The push trigger used branches: ["*"], but a single "*" does not match
"/" in GitHub Actions filters, so branches such as fix/preload-authen-modules
never got an image build. Use "**" for branches and tags.

@ionparticle ionparticle left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested locally, confirmed saml2 login still works fine.

@xcompass
xcompass merged commit 828cfbc into ubc Sep 14, 2026
9 checks passed
@xcompass
xcompass deleted the fix/preload-authen-modules branch September 14, 2026 20:13
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