Problem/Motivation

This is a follow-up of #3501358: Do not read config in Drupal\auto_unban\BanIpManager::__construct(), because while that was important. An additional improvement is possible, only since #3538294: Regression: All stack middlewares are constructed at the same time even for cached pages, since only then it's meaningful.

The config factory has a lot of dependencies, including the event dispatcher and the module handler. Before that core issue, at least the event subscriber was anyway always initialized, but that's no longer the case.

Steps to reproduce

Proposed resolution

The config is only needed on banning an API, not checking for bans, so we can inject the ConfigManager as a service closure and only initialize it when needed.

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork auto_unban-3551605

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

berdir created an issue. See original summary.

berdir’s picture

Status: Active » Needs review

I have _not_ tested if this works on D10, but I think it should work on 10.2+.

Testing with our distribution on 11.x, this results in a 28% time (8.36 ms → 6.05 ms) and 30% peak memory (3.36 MB → 2.34 MB) based on one sample. Time might vary quite a bit, but memory usage should be stable and reliable.

andypost’s picture

Nice improvement!